From 2720625083981ec4da6adc2f1bb37daee38c2370 Mon Sep 17 00:00:00 2001 From: Phil Morrell Date: Thu, 6 Sep 2018 10:06:01 +0100 Subject: [PATCH] update walking_light from emorrp1/any_tool --- diff/walking_light.diff/init.lua | 44 +++++++++++++++----------------- mods/walking_light/depends.txt | 1 + mods/walking_light/init.lua | 44 +++++++++++++++----------------- 3 files changed, 43 insertions(+), 46 deletions(-) create mode 100644 mods/walking_light/depends.txt diff --git a/diff/walking_light.diff/init.lua b/diff/walking_light.diff/init.lua index a24fb5a..351529f 100644 --- a/diff/walking_light.diff/init.lua +++ b/diff/walking_light.diff/init.lua @@ -17,7 +17,7 @@ walking_light = {} -- list of items that use walking light local light_items = { - "default:torch", "walking_light:pick_mese", + "default:torch", "walking_light:helmet_diamond", "walking_light:megatorch" } @@ -36,6 +36,25 @@ function walking_light.getLightItems() return light_items end +function walking_light.register_tool(tool) + item = 'walking_light:' .. tool .. '_mese' + default = 'default:' .. tool .. '_mese' + + definition = table.copy(minetest.registered_items[default]) + definition.description = definition.description .. ' with light' + definition.inventory_image = 'walking_light_mese' .. tool .. '.png' + + minetest.register_tool(item, definition) + minetest.register_craft({ + output = item, + recipe = { + {'default:torch'}, + { default }, + } + }) + + walking_light.addLightItem(item) +end -- from http://lua-users.org/wiki/IteratorsTutorial -- useful for removing things from a table because removing from the middle makes it skip elements otherwise @@ -523,20 +542,7 @@ function update_walking_light_node() end update_walking_light_node() -minetest.register_tool("walking_light:pick_mese", { - description = "Mese Pickaxe with light", - inventory_image = "walking_light_mesepick.png", - wield_image = "default_tool_mesepick.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=3, - groupcaps={ - cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, - crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, - snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3} - } - }, -}) +walking_light.register_tool('pick') minetest.register_tool("walking_light:helmet_diamond", { description = "Diamond Helmet with light", @@ -597,14 +603,6 @@ minetest.register_node("walking_light:megatorch", { --sounds = default.node_sound_defaults(), }) -minetest.register_craft({ - output = 'walking_light:pick_mese', - recipe = { - {'default:torch'}, - {'default:pick_mese'}, - } -}) - minetest.register_craft({ output = 'walking_light:helmet_diamond', recipe = { diff --git a/mods/walking_light/depends.txt b/mods/walking_light/depends.txt new file mode 100644 index 0000000..4ad96d5 --- /dev/null +++ b/mods/walking_light/depends.txt @@ -0,0 +1 @@ +default diff --git a/mods/walking_light/init.lua b/mods/walking_light/init.lua index a24fb5a..351529f 100644 --- a/mods/walking_light/init.lua +++ b/mods/walking_light/init.lua @@ -17,7 +17,7 @@ walking_light = {} -- list of items that use walking light local light_items = { - "default:torch", "walking_light:pick_mese", + "default:torch", "walking_light:helmet_diamond", "walking_light:megatorch" } @@ -36,6 +36,25 @@ function walking_light.getLightItems() return light_items end +function walking_light.register_tool(tool) + item = 'walking_light:' .. tool .. '_mese' + default = 'default:' .. tool .. '_mese' + + definition = table.copy(minetest.registered_items[default]) + definition.description = definition.description .. ' with light' + definition.inventory_image = 'walking_light_mese' .. tool .. '.png' + + minetest.register_tool(item, definition) + minetest.register_craft({ + output = item, + recipe = { + {'default:torch'}, + { default }, + } + }) + + walking_light.addLightItem(item) +end -- from http://lua-users.org/wiki/IteratorsTutorial -- useful for removing things from a table because removing from the middle makes it skip elements otherwise @@ -523,20 +542,7 @@ function update_walking_light_node() end update_walking_light_node() -minetest.register_tool("walking_light:pick_mese", { - description = "Mese Pickaxe with light", - inventory_image = "walking_light_mesepick.png", - wield_image = "default_tool_mesepick.png", - tool_capabilities = { - full_punch_interval = 1.0, - max_drop_level=3, - groupcaps={ - cracky={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, - crumbly={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3}, - snappy={times={[1]=2.0, [2]=1.0, [3]=0.5}, uses=20, maxlevel=3} - } - }, -}) +walking_light.register_tool('pick') minetest.register_tool("walking_light:helmet_diamond", { description = "Diamond Helmet with light", @@ -597,14 +603,6 @@ minetest.register_node("walking_light:megatorch", { --sounds = default.node_sound_defaults(), }) -minetest.register_craft({ - output = 'walking_light:pick_mese', - recipe = { - {'default:torch'}, - {'default:pick_mese'}, - } -}) - minetest.register_craft({ output = 'walking_light:helmet_diamond', recipe = {