From 733eb891b10735c7c3900b09e208860d9c934ebf Mon Sep 17 00:00:00 2001 From: ezhh Date: Tue, 28 Feb 2017 20:54:57 +0000 Subject: [PATCH] Add recipes for when caverealms is present --- crafting.lua | 28 ++++++++++++ init.lua | 123 ++------------------------------------------------- torches.lua | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 152 insertions(+), 120 deletions(-) create mode 100644 crafting.lua create mode 100644 torches.lua diff --git a/crafting.lua b/crafting.lua new file mode 100644 index 0000000..92e8c9d --- /dev/null +++ b/crafting.lua @@ -0,0 +1,28 @@ + +-- recipes when caverealms is present +if minetest.get_modpath("caverealms") then + + local recipe_list = { + {"black", "spike",}, {"blue", "glow_crystal",}, + {"cyan", "glow_gem",}, {"green", "glow_emerald",}, + {"magenta", "salt_gem",}, {"orange", "fire_vine",}, + {"purple", "glow_amethyst",}, {"red", "glow_ruby",}, + {"yellow", "glow_mese",}, {"white", "glow_ore",}, + } + + for _, item in pairs(recipe_list) do + + local colour = item[1] + local ingredient = item[2] + + minetest.register_craft({ + output = "abritorch:torch_"..colour.." 4", + recipe = { + {"default:torch", "", "default:torch" }, + {"", "caverealms:"..ingredient, "" }, + {"default:torch", "", "default:torch" }, + } + }) + end + +end diff --git a/init.lua b/init.lua index 926631b..24f7068 100644 --- a/init.lua +++ b/init.lua @@ -1,121 +1,4 @@ +local modpath = minetest.get_modpath("abritorch").. DIR_DELIM -local colour_list = { - {"black", "Darkened",}, {"blue", "Blue",}, - {"cyan", "Cyan",}, {"green", "Green",}, - {"magenta", "Magenta",}, {"orange", "Orange",}, - {"purple", "Purple",}, {"red", "Red",}, - {"yellow", "Yellow",}, {"white", "Frosted",}, -} - -local enable_ceiling = true - -for i in ipairs(colour_list) do - local colour = colour_list[i][1] - local desc = colour_list[i][2] - - minetest.register_craftitem("abritorch:torch_"..colour, { - description = desc.." Torch", - inventory_image = "abritorch_torch_on_floor_"..colour..".png", - wield_image = "abritorch_torch_on_floor_"..colour..".png", - wield_scale = {x = 1, y = 1, z = 1 + 1/16}, - liquids_pointable = false, - on_place = function(itemstack, placer, pointed_thing) - local above = pointed_thing.above - local under = pointed_thing.under - local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}) - if wdir < 1 and not enable_ceiling then - return itemstack - end - local fakestack = itemstack - local retval = false - if wdir <= 1 then - retval = fakestack:set_name("abritorch:floor_"..colour) - else - retval = fakestack:set_name("abritorch:wall_"..colour) - end - if not retval then - return itemstack - end - itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, param2) - itemstack:set_name("abritorch:torch_"..colour) - - return itemstack - end - }) - - minetest.register_node("abritorch:floor_"..colour, { - description = desc.." Torch", - inventory_image = "abritorch_torch_on_floor_"..colour..".png", - wield_image = "abritorch_torch_on_floor_"..colour..".png", - wield_scale = {x = 1, y = 1, z = 1 + 1/16}, - drawtype = "mesh", - mesh = "torch_floor.obj", - tiles = { - { - name = "abritorch_torch_on_floor_animated_"..colour..".png", - animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} - } - }, - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - walkable = false, - light_source = 13, - groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1}, - drop = "abritorch:torch_"..colour, - selection_box = { - type = "wallmounted", - wall_top = {-1/16, -2/16, -1/16, 1/16, 0.5, 1/16}, - wall_bottom = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16}, - }, - }) - - minetest.register_node("abritorch:wall_"..colour, { - inventory_image = "abritorch_torch_on_floor_"..colour..".png", - wield_image = "abritorch_torch_on_floor_"..colour..".png", - wield_scale = {x = 1, y = 1, z = 1 + 1/16}, - drawtype = "mesh", - mesh = "torch_wall.obj", - tiles = { - { - name = "abritorch_torch_on_floor_animated_"..colour..".png", - animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} - } - }, - paramtype = "light", - paramtype2 = "wallmounted", - sunlight_propagates = true, - walkable = false, - light_source = 13, - groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1}, - drop = "abritorch:torch_"..colour, - selection_box = { - type = "wallmounted", - wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1}, - wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1}, - wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1}, - }, - }) - - minetest.register_abm({ - nodenames = {"abritorch:torch_"..colour}, - interval = 1, - chance = 1, - action = function(pos) - local n = minetest.get_node(pos) - local def = minetest.registered_nodes[n.name] - if n and def then - local wdir = n.param2 - local node_name = "abritorch:wall_"..colour - if wdir < 1 and not enable_ceiling then - minetest.remove_node(pos) - return - elseif wdir <= 1 then - node_name = "abritorch:floor_"..colour - end - minetest.set_node(pos, {name = node_name, param2 = wdir}) - end - end - }) -end - +dofile(modpath.."torches.lua") +dofile(modpath.."crafting.lua") \ No newline at end of file diff --git a/torches.lua b/torches.lua new file mode 100644 index 0000000..926631b --- /dev/null +++ b/torches.lua @@ -0,0 +1,121 @@ + +local colour_list = { + {"black", "Darkened",}, {"blue", "Blue",}, + {"cyan", "Cyan",}, {"green", "Green",}, + {"magenta", "Magenta",}, {"orange", "Orange",}, + {"purple", "Purple",}, {"red", "Red",}, + {"yellow", "Yellow",}, {"white", "Frosted",}, +} + +local enable_ceiling = true + +for i in ipairs(colour_list) do + local colour = colour_list[i][1] + local desc = colour_list[i][2] + + minetest.register_craftitem("abritorch:torch_"..colour, { + description = desc.." Torch", + inventory_image = "abritorch_torch_on_floor_"..colour..".png", + wield_image = "abritorch_torch_on_floor_"..colour..".png", + wield_scale = {x = 1, y = 1, z = 1 + 1/16}, + liquids_pointable = false, + on_place = function(itemstack, placer, pointed_thing) + local above = pointed_thing.above + local under = pointed_thing.under + local wdir = minetest.dir_to_wallmounted({x = under.x - above.x, y = under.y - above.y, z = under.z - above.z}) + if wdir < 1 and not enable_ceiling then + return itemstack + end + local fakestack = itemstack + local retval = false + if wdir <= 1 then + retval = fakestack:set_name("abritorch:floor_"..colour) + else + retval = fakestack:set_name("abritorch:wall_"..colour) + end + if not retval then + return itemstack + end + itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, param2) + itemstack:set_name("abritorch:torch_"..colour) + + return itemstack + end + }) + + minetest.register_node("abritorch:floor_"..colour, { + description = desc.." Torch", + inventory_image = "abritorch_torch_on_floor_"..colour..".png", + wield_image = "abritorch_torch_on_floor_"..colour..".png", + wield_scale = {x = 1, y = 1, z = 1 + 1/16}, + drawtype = "mesh", + mesh = "torch_floor.obj", + tiles = { + { + name = "abritorch_torch_on_floor_animated_"..colour..".png", + animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} + } + }, + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + light_source = 13, + groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1}, + drop = "abritorch:torch_"..colour, + selection_box = { + type = "wallmounted", + wall_top = {-1/16, -2/16, -1/16, 1/16, 0.5, 1/16}, + wall_bottom = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16}, + }, + }) + + minetest.register_node("abritorch:wall_"..colour, { + inventory_image = "abritorch_torch_on_floor_"..colour..".png", + wield_image = "abritorch_torch_on_floor_"..colour..".png", + wield_scale = {x = 1, y = 1, z = 1 + 1/16}, + drawtype = "mesh", + mesh = "torch_wall.obj", + tiles = { + { + name = "abritorch_torch_on_floor_animated_"..colour..".png", + animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3} + } + }, + paramtype = "light", + paramtype2 = "wallmounted", + sunlight_propagates = true, + walkable = false, + light_source = 13, + groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1}, + drop = "abritorch:torch_"..colour, + selection_box = { + type = "wallmounted", + wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1}, + wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1}, + wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1}, + }, + }) + + minetest.register_abm({ + nodenames = {"abritorch:torch_"..colour}, + interval = 1, + chance = 1, + action = function(pos) + local n = minetest.get_node(pos) + local def = minetest.registered_nodes[n.name] + if n and def then + local wdir = n.param2 + local node_name = "abritorch:wall_"..colour + if wdir < 1 and not enable_ceiling then + minetest.remove_node(pos) + return + elseif wdir <= 1 then + node_name = "abritorch:floor_"..colour + end + minetest.set_node(pos, {name = node_name, param2 = wdir}) + end + end + }) +end +