diff --git a/Readme.md b/Readme.md index 93a54b9..5b5ad5a 100644 --- a/Readme.md +++ b/Readme.md @@ -4,22 +4,43 @@ The majority of this code was taken (and altered significantly) from Calinou's [ The Letter Cutter textures use parts of the default wood and tree textures made by Blockmen and Cisoun respectively. -####Allowing letters to be made from nodes: +#### Allowing letters to be made from nodes: Use this code to allow blocks to have letters registered from them: ```lua -letters.register_letters(modname, subname, from_node, description, tiles) +letters.register_letters(modname, subname, from_node, description, tiles, def) ``` -Modname is the mod that the node belongs to. -Subname is the actual name of the node. -From_nobe is the node that the letters will be crafted from (Usually modname:subname). -Description is the description of the node. -Tiles defines the image that will be used with the node. +- Modname is the mod that the node belongs to. +- Subname is the actual name of the node. +- From_node is the node that the letters will be crafted from (Usually modname:subname). +- Description is the description of the node. +- Tiles defines the image that will be used with the node. +- Def (optional) may contain additional node definition parameters. Some might be overwritten to make the letters look and work as intended. For example, if I wanted to register marble, from the mod darkage, this is the code I would use: ```lua letters.register_letters("darkage", "marble", "darkage:marble", "Marble", "darkage_marble.png") ``` +Add letters with unifieddye. +```lua +letters.register_letters("darkage", + "marble", + "darkage:marble", + "Marble", + "darkage_marble.png", + { + paramtype2 = "colorwallmounted", + palette = "unifieddyes_palette_colorwallmounted.png", + groups = { + not_in_creative_inventory = 1, + not_in_craft_guide = 1, + oddly_breakable_by_hand = 1, + attached_node = 1, + ud_param2_colorable = 1 + } + } +) +``` You will need to add letters as a dependency to your mod, or include the registrations is the code: ```lua if minetest.get_modpath("letters") then diff --git a/init.lua b/init.lua index d6f01f9..3d11c36 100644 --- a/init.lua +++ b/init.lua @@ -30,55 +30,50 @@ letters = { letter_cutter = {} letter_cutter.known_nodes = {} -function letters.register_letters(modname, subname, from_node, description, tiles) - for _, row in ipairs(letters) do - local namel = subname.. "_letter_" ..row[1] - local nameu = subname.. "_letter_" ..row[2] - local descl = description.. " " ..row[3] - local descu = description.. " " ..row[4] - local tilesl = tiles.. "^letters_" ..row[1].. "_overlay.png^[makealpha:255,126,126" - local tilesu = tiles.. "^letters_" ..row[2].. "_overlay.png^[makealpha:255,126,126" - local groups = {not_in_creative_inventory=1, not_in_craft_guide=1, oddly_breakable_by_hand=1, attached_node=1} - minetest.register_node(":" ..modname..":"..namel, { - description = descl, - drawtype = "signlike", - tiles = {tilesl}, - inventory_image = tilesl, - wield_image = tilesl, - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - selection_box = { - type = "wallmounted", - --wall_top = - --wall_bottom = - --wall_side = - }, - groups = groups, - legacy_wallmounted = false, - }) - minetest.register_node(":" ..modname..":"..nameu, { - description = descu, - drawtype = "signlike", - tiles = {tilesu}, - inventory_image = tilesu, - wield_image = tilesu, - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - is_ground_content = false, - walkable = false, - selection_box = { - type = "wallmounted", - --wall_top = - --wall_bottom = - --wall_side = - }, - groups = groups, - legacy_wallmounted = false, - }) +function letters.register_letters(modname, subname, from_node, description, tiles, def) + + def = def and table.copy(def) or {} + + --default node + def.drawtype = "signlike" + def.paramtype = "light" + def.paramtype2 = def.paramtype2 or "wallmounted" + def.sunlight_propagates = true + def.is_ground_content = false + def.walkable = false + def.selection_box = { + type = "wallmounted" + --wall_top = + --wall_bottom = + --wall_side = + } + def.groups = def.groups or { + not_in_creative_inventory = 1, + not_in_craft_guide = 1, + oddly_breakable_by_hand = 1, + attached_node = 1 + } + def.legacy_wallmounted = false + + + for _, row in ipairs(letters) do + + def = table.copy(def) + def.description = description.. " " ..row[3] + def.inventory_image = tiles.. "^letters_" ..row[1].. "_overlay.png^[makealpha:255,126,126" + def.wield_image = def.inventory_image + def.tiles = {def.inventory_image} + + minetest.register_node(":" ..modname..":"..subname.. "_letter_" ..row[1],def) + + def = table.copy(def) + def.description = description.. " " ..row[4] + def.inventory_image = tiles.. "^letters_" ..row[2].. "_overlay.png^[makealpha:255,126,126" + def.wield_image = def.inventory_image + def.tiles = {def.inventory_image} + + minetest.register_node(":" ..modname..":"..subname.. "_letter_" ..row[2], def) + --[[minetest.register_craft({ output = from_node, recipe = {