Better number formating

Is it 120000 or 1200000?
This commit is contained in:
est31
2015-01-31 04:16:11 +01:00
committed by Vanessa Ezekowitz
parent 0c3f55e0c9
commit d9bf9830b0
6 changed files with 54 additions and 5 deletions

View File

@ -24,7 +24,7 @@ local run = function(pos, node)
local charge_to_give = math.floor((light + pos1.y) * 3)
charge_to_give = math.max(charge_to_give, 0)
charge_to_give = math.min(charge_to_give, 200)
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..charge_to_give.."EU)")
meta:set_string("infotext", technic.format(S("%s Active (%e EU)"), machine_name, charge_to_give))
meta:set_int("LV_EU_supply", charge_to_give)
else
meta:set_string("infotext", S("%s Idle"):format(machine_name))

View File

@ -55,7 +55,7 @@ local run = function(pos, node)
meta:set_int("MV_EU_supply", power)
end
meta:set_string("infotext", machine_name.." ("..power.."EU)")
meta:set_string("infotext", technic.format("%s (%eEU)", machine_name, power))
end
minetest.register_node("technic:wind_mill", {

View File

@ -142,7 +142,7 @@ function technic.register_battery_box(data)
.."^[lowpart:"..charge_percent
..":technic_power_meter_fg.png]")
local infotext = S("%s Battery Box: %d/%d"):format(tier,
local infotext = technic.format(S("%s Battery Box: %e/%e"), tier,
current_charge, max_charge)
if eu_input == 0 then
infotext = S("%s Idle"):format(infotext)

View File

@ -28,7 +28,7 @@ function technic.register_solar_array(data)
local charge_to_give = math.floor((light + pos.y) * data.power)
charge_to_give = math.max(charge_to_give, 0)
charge_to_give = math.min(charge_to_give, data.power * 50)
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..charge_to_give.."EU)")
meta:set_string("infotext", technic.format(S("%s Active (%e EU)"), machine_name, charge_to_give))
meta:set_int(tier.."_EU_supply", charge_to_give)
else
meta:set_string("infotext", S("%s Idle"):format(machine_name))

View File

@ -291,7 +291,7 @@ minetest.register_abm({
--dprint("Total BA demand:"..BA_eu_demand)
meta:set_string("infotext",
S("%s. Supply: %d Demand: %d"):format(
technic.format(S("%s. Supply: %e Demand: %e"),
machine_name, PR_eu_supply, RE_eu_demand))
-- If the PR supply is enough for the RE demand supply them all