1
0
Disbranĉigi 0

update walking_light from emorrp1/any_tool

This commit is contained in:
Phil Morrell 2018-09-06 10:06:01 +01:00
parent c24e20d22b
commit 2720625083
No known key found for this signature in database
GPG Key ID: DF85C70ED3BD4B8C
3 changed files with 43 additions and 46 deletions

View File

@ -17,7 +17,7 @@ walking_light = {}
-- list of items that use walking light -- list of items that use walking light
local light_items = { local light_items = {
"default:torch", "walking_light:pick_mese", "default:torch",
"walking_light:helmet_diamond", "walking_light:megatorch" "walking_light:helmet_diamond", "walking_light:megatorch"
} }
@ -36,6 +36,25 @@ function walking_light.getLightItems()
return light_items return light_items
end 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 -- from http://lua-users.org/wiki/IteratorsTutorial
-- useful for removing things from a table because removing from the middle makes it skip elements otherwise -- 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 end
update_walking_light_node() update_walking_light_node()
minetest.register_tool("walking_light:pick_mese", { walking_light.register_tool('pick')
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}
}
},
})
minetest.register_tool("walking_light:helmet_diamond", { minetest.register_tool("walking_light:helmet_diamond", {
description = "Diamond Helmet with light", description = "Diamond Helmet with light",
@ -597,14 +603,6 @@ minetest.register_node("walking_light:megatorch", {
--sounds = default.node_sound_defaults(), --sounds = default.node_sound_defaults(),
}) })
minetest.register_craft({
output = 'walking_light:pick_mese',
recipe = {
{'default:torch'},
{'default:pick_mese'},
}
})
minetest.register_craft({ minetest.register_craft({
output = 'walking_light:helmet_diamond', output = 'walking_light:helmet_diamond',
recipe = { recipe = {

View File

@ -0,0 +1 @@
default

View File

@ -17,7 +17,7 @@ walking_light = {}
-- list of items that use walking light -- list of items that use walking light
local light_items = { local light_items = {
"default:torch", "walking_light:pick_mese", "default:torch",
"walking_light:helmet_diamond", "walking_light:megatorch" "walking_light:helmet_diamond", "walking_light:megatorch"
} }
@ -36,6 +36,25 @@ function walking_light.getLightItems()
return light_items return light_items
end 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 -- from http://lua-users.org/wiki/IteratorsTutorial
-- useful for removing things from a table because removing from the middle makes it skip elements otherwise -- 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 end
update_walking_light_node() update_walking_light_node()
minetest.register_tool("walking_light:pick_mese", { walking_light.register_tool('pick')
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}
}
},
})
minetest.register_tool("walking_light:helmet_diamond", { minetest.register_tool("walking_light:helmet_diamond", {
description = "Diamond Helmet with light", description = "Diamond Helmet with light",
@ -597,14 +603,6 @@ minetest.register_node("walking_light:megatorch", {
--sounds = default.node_sound_defaults(), --sounds = default.node_sound_defaults(),
}) })
minetest.register_craft({
output = 'walking_light:pick_mese',
recipe = {
{'default:torch'},
{'default:pick_mese'},
}
})
minetest.register_craft({ minetest.register_craft({
output = 'walking_light:helmet_diamond', output = 'walking_light:helmet_diamond',
recipe = { recipe = {