Implement Jetpack

This commit is contained in:
2024-01-09 11:07:00 +01:00
parent 3a7ba72571
commit 6da4aef854
4 changed files with 178 additions and 4 deletions

14
api.lua
View File

@@ -113,12 +113,18 @@ end
-- \returns true if value was successfully added, false otherwise
industrialtest.api.prepareToolItem=function(itemstack)
local def=minetest.registered_tools[itemstack:get_name()]
if not def or not def._industrialtest_tool or not def.tool_capabilities or not def.tool_capabilities.uses then
if not def then
return false
end
local meta=itemstack:get_meta()
meta:set_int("industrialtest.uses",def.tool_capabilities.uses)
return true
if def._industrialtest_tool and def.tool_capabilities and def.tool_capabilities.uses then
local meta=itemstack:get_meta()
meta:set_int("industrialtest.uses",def.tool_capabilities.uses)
return true
elseif def.groups and def.groups._industrialtest_emptyOnConstruct and itemstack:get_wear()==0 then
itemstack:set_wear(65534)
return true
end
return false
end
-- \brief Adds wear to item after it's use
-- \param itemstack ItemStack to which wear should be added