diff --git a/elepower_machines/bases/crafter.lua b/elepower_machines/bases/crafter.lua index 8195f07..c9573d1 100644 --- a/elepower_machines/bases/crafter.lua +++ b/elepower_machines/bases/crafter.lua @@ -44,11 +44,13 @@ function elepm.register_crafter(nodename, nodedef) if not result then meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent)) meta:set_int("src_time", 0) - meta:set_string("infotext", ("%s Idle"):format(nodedef.description)) + meta:set_string("infotext", ("%s Idle"):format(nodedef.description) .. + "\n" .. ele.capacity_text(capacity, storage)) else local pct = math.floor((ele.helpers.round(result.time * 10) / meta:get_int("src_time")) * 100) meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent, pct)) - meta:set_string("infotext", ("%s Out of Power!"):format(nodedef.description)) + meta:set_string("infotext", ("%s Out of Power!"):format(nodedef.description) .. + "\n" .. ele.capacity_text(capacity, storage)) end break @@ -60,7 +62,8 @@ function elepm.register_crafter(nodename, nodedef) meta:set_int("storage", storage - usage) pow_percent = math.floor((storage / capacity) * 100) meta:set_int("src_time", meta:get_int("src_time") + ele.helpers.round(machine_speed * 10)) - meta:set_string("infotext", ("%s Active"):format(nodedef.description)) + meta:set_string("infotext", ("%s Active"):format(nodedef.description) .. + "\n" .. ele.capacity_text(capacity, storage)) if nodedef.ele_active_node then local active_node = nodename.."_active" @@ -100,7 +103,8 @@ function elepm.register_crafter(nodename, nodedef) ele.helpers.swap_node(pos, machine_node) meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent)) meta:set_int("src_time", ele.helpers.round(result.time*10)) - meta:set_string("infotext", ("%s Output Full!"):format(nodedef.description)) + meta:set_string("infotext", ("%s Output Full!"):format(nodedef.description) .. + "\n" .. ele.capacity_text(capacity, storage)) break end diff --git a/elepower_machines/bases/generator.lua b/elepower_machines/bases/generator.lua index e1ef6e1..6e48c80 100644 --- a/elepower_machines/bases/generator.lua +++ b/elepower_machines/bases/generator.lua @@ -57,7 +57,8 @@ function elepm.register_fuel_generator(nodename, nodedef) end else meta:set_string("formspec", ele.formspec.get_generator_formspec(pow_percent, 0)) - meta:set_string("infotext", ("%s Idle"):format(nodedef.description)) + meta:set_string("infotext", ("%s Idle"):format(nodedef.description) .. + "\n" .. ele.capacity_text(capacity, storage)) ele.helpers.swap_node(pos, nodename) return false end @@ -66,7 +67,8 @@ function elepm.register_fuel_generator(nodename, nodedef) local percent = math.floor((burn_time / burn_totaltime) * 100) meta:set_string("formspec", ele.formspec.get_generator_formspec(pow_percent, percent)) - meta:set_string("infotext", ("%s Active"):format(nodedef.description)) + meta:set_string("infotext", ("%s Active"):format(nodedef.description) .. + "\n" .. ele.capacity_text(capacity, storage)) return true end diff --git a/elepower_machines/bases/storage.lua b/elepower_machines/bases/storage.lua index 8a8a464..1c28b01 100644 --- a/elepower_machines/bases/storage.lua +++ b/elepower_machines/bases/storage.lua @@ -27,7 +27,7 @@ function elepm.register_storage(nodename, nodedef) ele.helpers.swap_node(pos, nodename .. "_" .. level) meta:set_string("formspec", ele.formspec.get_storage_formspec(rounded)) - meta:set_string("infotext", ("%s Active"):format(nodedef.description)) + meta:set_string("infotext", ("%s Active"):format(nodedef.description) .. "\n" .. ele.capacity_text(capacity, storage)) local inv = meta:get_inventory() diff --git a/elepower_papi/machine.lua b/elepower_papi/machine.lua index d6e9877..808a548 100644 --- a/elepower_papi/machine.lua +++ b/elepower_papi/machine.lua @@ -110,6 +110,10 @@ local function retrieve_metadata(pos, placer, itemstack, pointed_thing) return false end +function ele.capacity_text(capacity, storage) + return "Charge: " .. storage .. "/" .. capacity .. " " ..ele.unit +end + -- Register a base device function ele.register_base_device(nodename, nodedef) -- Override construct callback diff --git a/elepower_papi/tool.lua b/elepower_papi/tool.lua index 831ca81..ea956e0 100644 --- a/elepower_papi/tool.lua +++ b/elepower_papi/tool.lua @@ -43,8 +43,7 @@ function ele.tools.update_tool_wear(itemstack) local percent = storage / capacity local wear = math.floor((1-percent) * 65535) - meta:set_string("description", itemdef.description .. "\nCharge: " .. - storage .. "/" .. capacity .. " " .. ele.unit) + meta:set_string("description", itemdef.description .. "\n" .. ele.capacity_text(capacity, storage)) itemstack:set_wear(wear) itemstack = ele.tools.groupcaps(itemstack)