Add charge text to infotext
This commit is contained in:
parent
baff673cb8
commit
9e8a1967f2
@ -44,11 +44,13 @@ function elepm.register_crafter(nodename, nodedef)
|
|||||||
if not result then
|
if not result then
|
||||||
meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent))
|
meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent))
|
||||||
meta:set_int("src_time", 0)
|
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
|
else
|
||||||
local pct = math.floor((ele.helpers.round(result.time * 10) / meta:get_int("src_time")) * 100)
|
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("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
|
end
|
||||||
|
|
||||||
break
|
break
|
||||||
@ -60,7 +62,8 @@ function elepm.register_crafter(nodename, nodedef)
|
|||||||
meta:set_int("storage", storage - usage)
|
meta:set_int("storage", storage - usage)
|
||||||
pow_percent = math.floor((storage / capacity) * 100)
|
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_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
|
if nodedef.ele_active_node then
|
||||||
local active_node = nodename.."_active"
|
local active_node = nodename.."_active"
|
||||||
@ -100,7 +103,8 @@ function elepm.register_crafter(nodename, nodedef)
|
|||||||
ele.helpers.swap_node(pos, machine_node)
|
ele.helpers.swap_node(pos, machine_node)
|
||||||
meta:set_string("formspec", ele.formspec.get_crafter_formspec(craft_type, pow_percent))
|
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_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
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,7 +57,8 @@ function elepm.register_fuel_generator(nodename, nodedef)
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
meta:set_string("formspec", ele.formspec.get_generator_formspec(pow_percent, 0))
|
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)
|
ele.helpers.swap_node(pos, nodename)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
@ -66,7 +67,8 @@ function elepm.register_fuel_generator(nodename, nodedef)
|
|||||||
|
|
||||||
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
local percent = math.floor((burn_time / burn_totaltime) * 100)
|
||||||
meta:set_string("formspec", ele.formspec.get_generator_formspec(pow_percent, percent))
|
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
|
return true
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ function elepm.register_storage(nodename, nodedef)
|
|||||||
|
|
||||||
ele.helpers.swap_node(pos, nodename .. "_" .. level)
|
ele.helpers.swap_node(pos, nodename .. "_" .. level)
|
||||||
meta:set_string("formspec", ele.formspec.get_storage_formspec(rounded))
|
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()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
|
@ -110,6 +110,10 @@ local function retrieve_metadata(pos, placer, itemstack, pointed_thing)
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ele.capacity_text(capacity, storage)
|
||||||
|
return "Charge: " .. storage .. "/" .. capacity .. " " ..ele.unit
|
||||||
|
end
|
||||||
|
|
||||||
-- Register a base device
|
-- Register a base device
|
||||||
function ele.register_base_device(nodename, nodedef)
|
function ele.register_base_device(nodename, nodedef)
|
||||||
-- Override construct callback
|
-- Override construct callback
|
||||||
|
@ -43,8 +43,7 @@ function ele.tools.update_tool_wear(itemstack)
|
|||||||
local percent = storage / capacity
|
local percent = storage / capacity
|
||||||
local wear = math.floor((1-percent) * 65535)
|
local wear = math.floor((1-percent) * 65535)
|
||||||
|
|
||||||
meta:set_string("description", itemdef.description .. "\nCharge: " ..
|
meta:set_string("description", itemdef.description .. "\n" .. ele.capacity_text(capacity, storage))
|
||||||
storage .. "/" .. capacity .. " " .. ele.unit)
|
|
||||||
|
|
||||||
itemstack:set_wear(wear)
|
itemstack:set_wear(wear)
|
||||||
itemstack = ele.tools.groupcaps(itemstack)
|
itemstack = ele.tools.groupcaps(itemstack)
|
||||||
|
Loading…
Reference in New Issue
Block a user