From 43824cb4f5d6b96de2dac46e63395c7319c370fc Mon Sep 17 00:00:00 2001 From: kilbith Date: Thu, 7 Jan 2016 22:51:58 +0100 Subject: [PATCH] Move craftitems and tools in separate file s --- chess.lua | 14 +-------- cooking.lua | 2 +- craftitems.lua | 60 ++++++++++++++++++++++++++++++++++++++ hive.lua | 2 +- init.lua | 5 ++-- nodes.lua | 29 ------------------ crafts.lua => recipes.lua | 39 +++++-------------------- textures/xdecor_crate.png | Bin 238 -> 210 bytes 8 files changed, 74 insertions(+), 77 deletions(-) create mode 100644 craftitems.lua rename crafts.lua => recipes.lua (91%) diff --git a/chess.lua b/chess.lua index 95a62b1..2b02094 100644 --- a/chess.lua +++ b/chess.lua @@ -594,10 +594,6 @@ function realchess.on_move(pos, from_list, from_index, to_list, to_index, count, return false end -function realchess.take(pos, listname, index, stack, player) - return 0 -end - minetest.register_node(":realchess:chessboard", { description = "Chess Board", drawtype = "nodebox", @@ -616,7 +612,7 @@ minetest.register_node(":realchess:chessboard", { on_receive_fields = realchess.fields, allow_metadata_inventory_move = realchess.move, on_metadata_inventory_move = realchess.on_move, - allow_metadata_inventory_take = realchess.take + allow_metadata_inventory_take = function() return 0 end }) local function register_piece(name, count) @@ -648,11 +644,3 @@ register_piece("bishop", 2) register_piece("queen") register_piece("king") -minetest.register_craft({ - output = "realchess:chessboard", - recipe = { - {"dye:black", "dye:white", "dye:black"}, - {"stairs:slab_wood", "stairs:slab_wood", "stairs:slab_wood"} - } -}) - diff --git a/cooking.lua b/cooking.lua index 1fc6f3d..3cad827 100644 --- a/cooking.lua +++ b/cooking.lua @@ -26,7 +26,7 @@ xdecor.register("cauldron_empty", { on_rotate = screwdriver.rotate_simple, tiles = {"xdecor_cauldron_top_empty.png", "xdecor_cauldron_sides.png"}, infotext = "Cauldron (empty)", - on_rightclick = function(pos, node, clicker, itemstack, _) + on_rightclick = function(pos, node, clicker, itemstack) local wield_item = clicker:get_wielded_item():get_name() if wield_item == "bucket:bucket_water" or wield_item == "bucket:bucket_river_water" then diff --git a/craftitems.lua b/craftitems.lua new file mode 100644 index 0000000..c919ff8 --- /dev/null +++ b/craftitems.lua @@ -0,0 +1,60 @@ +minetest.register_craftitem("xdecor:bowl", { + description = "Bowl", + inventory_image = "xdecor_bowl.png", + wield_image = "xdecor_bowl.png" +}) + +minetest.register_craftitem("xdecor:bowl_soup", { + description = "Bowl of soup", + inventory_image = "xdecor_bowl_soup.png", + wield_image = "xdecor_bowl_soup.png", + groups = {not_in_creative_inventory=1}, + stack_max = 1, + on_use = function(itemstack, user) + itemstack:replace("xdecor:bowl 1") + if minetest.get_modpath("hunger") then + minetest.item_eat(20) + else + user:set_hp(20) + end + return itemstack + end +}) + +minetest.register_tool("xdecor:flint_steel", { + description = "Flint & Steel", + inventory_image = "xdecor_flint_steel.png", + tool_capabilities = { + groupcaps = { igniter = {uses=10, maxlevel=1} } + }, + on_use = function(itemstack, user, pointed_thing) + local player = user:get_player_name() + if pointed_thing.type == "node" and + minetest.get_node(pointed_thing.above).name == "air" then + if not minetest.is_protected(pointed_thing.above, player) then + minetest.set_node(pointed_thing.above, {name="xdecor:fire"}) + else + minetest.chat_send_player(player, "This area is protected.") + end + end + + itemstack:add_wear(1000) + return itemstack + end +}) + +minetest.register_tool("xdecor:hammer", { + description = "Hammer", + inventory_image = "xdecor_hammer.png", + wield_image = "xdecor_hammer.png", + on_use = function() do return end end +}) + +minetest.register_craftitem("xdecor:honey", { + description = "Honey", + inventory_image = "xdecor_honey.png", + wield_image = "xdecor_honey.png", + groups = {not_in_creative_inventory=1}, + on_use = minetest.item_eat(2) +}) + diff --git a/hive.lua b/hive.lua index 518c6fe..40c1857 100644 --- a/hive.lua +++ b/hive.lua @@ -31,7 +31,7 @@ xdecor.register("hive", { return minetest.get_meta(pos):get_inventory():is_empty("honey") end, on_punch = function(_, _, puncher) - puncher:set_hp(puncher:get_hp()-4) + puncher:set_hp(puncher:get_hp() - 2) end, allow_metadata_inventory_put = function() return 0 end }) diff --git a/init.lua b/init.lua index df70e48..1f97386 100644 --- a/init.lua +++ b/init.lua @@ -6,13 +6,14 @@ dofile(modpath.."/handlers/nodeboxes.lua") dofile(modpath.."/handlers/registration.lua") dofile(modpath.."/chess.lua") dofile(modpath.."/cooking.lua") -dofile(modpath.."/crafts.lua") +dofile(modpath.."/craftitems.lua") dofile(modpath.."/enchanting.lua") dofile(modpath.."/hive.lua") dofile(modpath.."/itemframe.lua") dofile(modpath.."/mailbox.lua") -dofile(modpath.."/rope.lua") dofile(modpath.."/nodes.lua") +dofile(modpath.."/recipes.lua") +dofile(modpath.."/rope.lua") dofile(modpath.."/sitting.lua") dofile(modpath.."/worktable.lua") dofile(modpath.."/xwall.lua") diff --git a/nodes.lua b/nodes.lua index c34ece3..3a44feb 100644 --- a/nodes.lua +++ b/nodes.lua @@ -246,35 +246,6 @@ xdecor.register("fire", { groups = {dig_immediate=3, hot=3, not_in_creative_inventory=1} }) -minetest.register_tool("xdecor:flint_steel", { - description = "Flint & Steel", - inventory_image = "xdecor_flint_steel.png", - tool_capabilities = { - groupcaps = { igniter = {uses=10, maxlevel=1} } - }, - on_use = function(itemstack, user, pointed_thing) - local player = user:get_player_name() - if pointed_thing.type == "node" and - minetest.get_node(pointed_thing.above).name == "air" then - if not minetest.is_protected(pointed_thing.above, player) then - minetest.set_node(pointed_thing.above, {name="xdecor:fire"}) - else - minetest.chat_send_player(player, "This area is protected.") - end - end - - itemstack:add_wear(1000) - return itemstack - end -}) - -minetest.register_tool("xdecor:hammer", { - description = "Hammer", - inventory_image = "xdecor_hammer.png", - wield_image = "xdecor_hammer.png", - on_use = function() do return end end -}) - xdecor.register("ivy", { description = "Ivy", drawtype = "signlike", diff --git a/crafts.lua b/recipes.lua similarity index 91% rename from crafts.lua rename to recipes.lua index c6dc0b1..c9df8f3 100644 --- a/crafts.lua +++ b/recipes.lua @@ -24,29 +24,6 @@ minetest.register_craft({ } }) -minetest.register_craftitem("xdecor:bowl", { - description = "Bowl", - inventory_image = "xdecor_bowl.png", - wield_image = "xdecor_bowl.png" -}) - -minetest.register_craftitem("xdecor:bowl_soup", { - description = "Bowl of soup", - inventory_image = "xdecor_bowl_soup.png", - wield_image = "xdecor_bowl_soup.png", - groups = {not_in_creative_inventory = 1}, - stack_max = 1, - on_use = function(itemstack, user) - itemstack:replace("xdecor:bowl 1") - if minetest.get_modpath("hunger") then - minetest.item_eat(20) - else - user:set_hp(20) - end - return itemstack - end -}) - minetest.register_craft({ output = "xdecor:candle", recipe = { @@ -70,6 +47,14 @@ minetest.register_craft({ } }) +minetest.register_craft({ + output = "realchess:chessboard", + recipe = { + {"dye:black", "dye:white", "dye:black"}, + {"stairs:slab_wood", "stairs:slab_wood", "stairs:slab_wood"} + } +}) + minetest.register_craft({ output = "xdecor:cushion 2", recipe = { @@ -213,14 +198,6 @@ minetest.register_craft({ } }) -minetest.register_craftitem("xdecor:honey", { - description = "Honey", - inventory_image = "xdecor_honey.png", - wield_image = "xdecor_honey.png", - groups = {not_in_creative_inventory=1}, - on_use = minetest.item_eat(2) -}) - minetest.register_craft({ output = "xdecor:ivy 4", recipe = { diff --git a/textures/xdecor_crate.png b/textures/xdecor_crate.png index 5fb34365b3bedbf7af46a256143953b623faf600..1a4754f503e6ef644612ae113614a6b57d2dd306 100644 GIT binary patch delta 182 zcmV;n07?Ju0n!1GB!3uCOjJd2OC^0%C}2Pzk6$m8V=!z;B!N~dX+|U4j5^i;004DK zL_t&t*By(o3d1lAL=Qpe8ZDlS(|&-6(JpK}2ZQKZFZusZsN9>5ckgi4T1zVpdMD;N zZ}hw(2?EFC*cl33qmw{350Lwsa;G4Q@!FqcFwa6*&gb~P|1TvQZ5Jsd4ERu}kpmR> k06_#cOF3&}2uBjn9~SHs*l!kEMgRZ+07*qoM6N<$g19zE`v3p{ delta 210 zcmV;@04@L00qy~iB!3}LOjJc+Kp${RC68Y(fmSP&V=#PDC~Qb1e^e=SO(tYRA!$Y< zc@*QF0001pNklwrDQz4YB?HlBg zt7klXn4EKZ)hpO;u`JfY5UkddTNiNo#InWZ4`n$UOKFc@YybcN M07*qoM6N<$f(5Z$NdN!<