Generator formspec improvements
This commit is contained in:
parent
71618b2f3f
commit
cb7fba8692
15
machines.lua
15
machines.lua
@ -17,7 +17,8 @@
|
|||||||
local S=minetest.get_translator("industrialtest")
|
local S=minetest.get_translator("industrialtest")
|
||||||
|
|
||||||
-- Generators
|
-- Generators
|
||||||
local function generatorFormspec(fuelPercent)
|
local function generatorFormspec(fuelPercent,charged)
|
||||||
|
minetest.chat_send_all(charged)
|
||||||
local formspec={
|
local formspec={
|
||||||
industrialtest.formspecVersion(),
|
industrialtest.formspecVersion(),
|
||||||
"size[10.8,12]",
|
"size[10.8,12]",
|
||||||
@ -27,6 +28,8 @@ local function generatorFormspec(fuelPercent)
|
|||||||
"image[4.9,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]",
|
"image[4.9,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]",
|
||||||
industrialtest.formspecList("context","fuel",4.9,3.9,1,1),
|
industrialtest.formspecList("context","fuel",4.9,3.9,1,1),
|
||||||
"listring[context;fuel]",
|
"listring[context;fuel]",
|
||||||
|
"box[9,1;0.3,4.8;#202020]",
|
||||||
|
(charged>0 and "box[9,"..(1+4.8-(charged*4.8))..";0.3,"..(charged*4.8)..";#FF1010]" or ""),
|
||||||
industrialtest.formspecPlayerInv()
|
industrialtest.formspecPlayerInv()
|
||||||
}
|
}
|
||||||
return table.concat(formspec,"")
|
return table.concat(formspec,"")
|
||||||
@ -55,7 +58,7 @@ local definition={
|
|||||||
local inv=meta:get_inventory()
|
local inv=meta:get_inventory()
|
||||||
inv:set_size("charged",1)
|
inv:set_size("charged",1)
|
||||||
inv:set_size("fuel",1)
|
inv:set_size("fuel",1)
|
||||||
meta:set_string("formspec",generatorFormspec(0))
|
meta:set_string("formspec",generatorFormspec(0,0))
|
||||||
meta:set_int("fuelTime",0)
|
meta:set_int("fuelTime",0)
|
||||||
industrialtest.api.addPowerStorage(meta,5000,10,"oooooo")
|
industrialtest.api.addPowerStorage(meta,5000,10,"oooooo")
|
||||||
end,
|
end,
|
||||||
@ -65,10 +68,7 @@ local definition={
|
|||||||
local fuelTime=meta:get_int("fuelTime")
|
local fuelTime=meta:get_int("fuelTime")
|
||||||
local fuelList=inv:get_list("fuel")
|
local fuelList=inv:get_list("fuel")
|
||||||
local chargedList=inv:get_list("charged")
|
local chargedList=inv:get_list("charged")
|
||||||
if industrialtest.api.isFullyCharged(meta) then
|
if fuelTime==0 and not industrialtest.api.isFullyCharged(meta) then
|
||||||
return false
|
|
||||||
else
|
|
||||||
if fuelTime==0 then
|
|
||||||
local fuel,after=minetest.get_craft_result({
|
local fuel,after=minetest.get_craft_result({
|
||||||
method="fuel",
|
method="fuel",
|
||||||
width=1,
|
width=1,
|
||||||
@ -82,14 +82,13 @@ local definition={
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
fuelTime=fuelTime-elapsed
|
fuelTime=fuelTime-elapsed
|
||||||
if fuelTime<0 then
|
if fuelTime<0 then
|
||||||
fuelTime=0
|
fuelTime=0
|
||||||
end
|
end
|
||||||
meta:set_int("fuelTime",fuelTime)
|
meta:set_int("fuelTime",fuelTime)
|
||||||
meta:set_string("formspec",generatorFormspec(fuelTime/meta:get_int("maxFuelTime")*100))
|
|
||||||
industrialtest.api.addPower(meta,100)
|
industrialtest.api.addPower(meta,100)
|
||||||
|
meta:set_string("formspec",generatorFormspec(fuelTime/meta:get_int("maxFuelTime")*100,meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")))
|
||||||
if fuelTime>0 or fuelList[1]:get_count()>0 then
|
if fuelTime>0 or fuelList[1]:get_count()>0 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user