forked from mrkubax10/industrialtest
Move some common tool functionality to separate files for further usage
This commit is contained in:
@@ -164,20 +164,6 @@ function industrialtest.api.updateItemPowerText(itemstack)
|
||||
itemstack:set_wear(65535-meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*65534)
|
||||
end
|
||||
|
||||
-- \brief Adds power storage to item depending on it's definition
|
||||
-- \param itemstack ItemStack to which item storage should be added
|
||||
-- \returns true if power storage was successfully added, false otherwise
|
||||
function industrialtest.api.preparePowerStorageItem(itemstack)
|
||||
local meta=itemstack:get_meta()
|
||||
local def=minetest.registered_tools[itemstack:get_name()]
|
||||
if industrialtest.api.hasPowerStorage(meta) or not def or not def._industrialtest_powerStorage or not def._industrialtest_powerCapacity or not def._industrialtest_powerFlow then
|
||||
return false
|
||||
end
|
||||
industrialtest.api.addPowerStorage(meta,def._industrialtest_powerCapacity,def._industrialtest_powerFlow,"n/a")
|
||||
industrialtest.api.updateItemPowerText(itemstack)
|
||||
return true
|
||||
end
|
||||
|
||||
-- \brief Adds power to itemstack. Function checks if itemstack has power storage.
|
||||
-- \param itemstack ItemStack to which add power
|
||||
-- \param amount How much power to add
|
||||
|
||||
Reference in New Issue
Block a user