Fix indentation in machines/induction_furnace.lua
This commit is contained in:
parent
2669b7bc27
commit
d01d03c3a3
@ -38,7 +38,7 @@ local function calculateMaxSrcTime(pos)
|
|||||||
end
|
end
|
||||||
|
|
||||||
inductionFurnace.getFormspec=function(pos)
|
inductionFurnace.getFormspec=function(pos)
|
||||||
local meta=minetest.get_meta(pos)
|
local meta=minetest.get_meta(pos)
|
||||||
local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100
|
local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100
|
||||||
local maxSrcTime=meta:get_float("maxSrcTime")
|
local maxSrcTime=meta:get_float("maxSrcTime")
|
||||||
local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0
|
local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0
|
||||||
@ -46,84 +46,84 @@ inductionFurnace.getFormspec=function(pos)
|
|||||||
local formspec
|
local formspec
|
||||||
if industrialtest.mtgAvailable then
|
if industrialtest.mtgAvailable then
|
||||||
formspec={
|
formspec={
|
||||||
"list[context;src;3.7,1.8;2,1]",
|
"list[context;src;3.7,1.8;2,1]",
|
||||||
(powerPercent>0 and "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
|
(powerPercent>0 and "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
|
||||||
or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
|
or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
|
||||||
"list[context;powerStorage;3.7,3.9;1,1]",
|
"list[context;powerStorage;3.7,3.9;1,1]",
|
||||||
(srcPercent>0 and "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
|
(srcPercent>0 and "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
|
||||||
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
|
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
|
||||||
"list[context;dst;6,2.8;2,1;]",
|
"list[context;dst;6,2.8;2,1;]",
|
||||||
"list[context;upgrades;9,0.9;1,4]",
|
"list[context;upgrades;9,0.9;1,4]",
|
||||||
"label[0.5,2.8;"..minetest.formspec_escape(S("Heat: @1 %",heat)).."]",
|
"label[0.5,2.8;"..minetest.formspec_escape(S("Heat: @1 %",heat)).."]",
|
||||||
"listring[context;src]",
|
"listring[context;src]",
|
||||||
"listring[context;powerStorage]",
|
"listring[context;powerStorage]",
|
||||||
"listring[context;dst]",
|
"listring[context;dst]",
|
||||||
"listring[context;upgrades]"
|
"listring[context;upgrades]"
|
||||||
}
|
}
|
||||||
elseif industrialtest.mclAvailable then
|
elseif industrialtest.mclAvailable then
|
||||||
formspec={
|
formspec={
|
||||||
"list[context;src;3.7,1.8;2,1]",
|
"list[context;src;3.7,1.8;2,1]",
|
||||||
mcl_formspec.get_itemslot_bg(3.7,1.8,2,1),
|
mcl_formspec.get_itemslot_bg(3.7,1.8,2,1),
|
||||||
(powerPercent>0 and "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
|
(powerPercent>0 and "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]"
|
||||||
or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
|
or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
|
||||||
"list[context;powerStorage;3.7,3.9;1,1]",
|
"list[context;powerStorage;3.7,3.9;1,1]",
|
||||||
mcl_formspec.get_itemslot_bg(3.7,3.9,1,1),
|
mcl_formspec.get_itemslot_bg(3.7,3.9,1,1),
|
||||||
(srcPercent>0 and "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
|
(srcPercent>0 and "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]"
|
||||||
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
|
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
|
||||||
"list[context;dst;6,2.8;2,1;]",
|
"list[context;dst;6,2.8;2,1;]",
|
||||||
mcl_formspec.get_itemslot_bg(6,2.8,2,1),
|
mcl_formspec.get_itemslot_bg(6,2.8,2,1),
|
||||||
"list[context;upgrades;9,0.9;1,4]",
|
"list[context;upgrades;9,0.9;1,4]",
|
||||||
mcl_formspec.get_itemslot_bg(9,0.9,1,4),
|
mcl_formspec.get_itemslot_bg(9,0.9,1,4),
|
||||||
"label[0.5,2.8;"..minetest.formspec_escape(S("Heat: @1 %",heat)).."]",
|
"label[0.5,2.8;"..minetest.formspec_escape(S("Heat: @1 %",heat)).."]",
|
||||||
"listring[context;src]",
|
"listring[context;src]",
|
||||||
"listring[context;powerStorage]",
|
"listring[context;powerStorage]",
|
||||||
"listring[context;dst]",
|
"listring[context;dst]",
|
||||||
"listring[context;upgrades]"
|
"listring[context;upgrades]"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
return table.concat(formspec,"")
|
return table.concat(formspec,"")
|
||||||
end
|
end
|
||||||
|
|
||||||
inductionFurnace.onConstruct=function(pos,meta,inv)
|
inductionFurnace.onConstruct=function(pos,meta,inv)
|
||||||
inv:set_size("src",2)
|
inv:set_size("src",2)
|
||||||
inv:set_size("dst",2)
|
inv:set_size("dst",2)
|
||||||
inv:set_size("powerStorage",1)
|
inv:set_size("powerStorage",1)
|
||||||
inv:set_size("upgrades",4)
|
inv:set_size("upgrades",4)
|
||||||
meta:set_int("heat",0)
|
meta:set_int("heat",0)
|
||||||
meta:set_float("srcTime",0)
|
meta:set_float("srcTime",0)
|
||||||
end
|
end
|
||||||
|
|
||||||
inductionFurnace.onTimer=function(pos,elapsed,meta,inv)
|
inductionFurnace.onTimer=function(pos,elapsed,meta,inv)
|
||||||
local shouldRerunTimer=false
|
local shouldRerunTimer=false
|
||||||
local shouldUpdateFormspec=false
|
local shouldUpdateFormspec=false
|
||||||
local srcList=inv:get_list("src")
|
local srcList=inv:get_list("src")
|
||||||
local heat=meta:get_int("heat")
|
local heat=meta:get_int("heat")
|
||||||
|
|
||||||
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
|
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
|
||||||
|
|
||||||
if heat>0 then
|
if heat>0 then
|
||||||
meta:set_int("heat",math.max(heat-math.max(2*elapsed,1),0))
|
meta:set_int("heat",math.max(heat-math.max(2*elapsed,1),0))
|
||||||
shouldRerunTimer=shouldRerunTimer or heat>0
|
shouldRerunTimer=shouldRerunTimer or heat>0
|
||||||
shouldUpdateFormspec=true
|
shouldUpdateFormspec=true
|
||||||
end
|
end
|
||||||
|
|
||||||
for _,slot in ipairs(srcList) do
|
for _,slot in ipairs(srcList) do
|
||||||
if not slot:is_empty() then
|
if not slot:is_empty() then
|
||||||
local result,after=minetest.get_craft_result({
|
local result,after=minetest.get_craft_result({
|
||||||
method="cooking",
|
method="cooking",
|
||||||
width=1,
|
width=1,
|
||||||
items={slot}
|
items={slot}
|
||||||
})
|
})
|
||||||
if result.time>0 and inv:room_for_item("dst",result.item) then
|
if result.time>0 and inv:room_for_item("dst",result.item) then
|
||||||
minetest.swap_node(pos,{
|
minetest.swap_node(pos,{
|
||||||
name="industrialtest:induction_furnace_active",
|
name="industrialtest:induction_furnace_active",
|
||||||
param2=minetest.get_node(pos).param2
|
param2=minetest.get_node(pos).param2
|
||||||
})
|
})
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||||
return false,shouldUpdateFormspec
|
return false,shouldUpdateFormspec
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return shouldRerunTimer,shouldUpdateFormspec
|
return shouldRerunTimer,shouldUpdateFormspec
|
||||||
end
|
end
|
||||||
@ -174,28 +174,28 @@ inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
local speed=industrialtest.api.getMachineSpeed(meta)
|
local speed=industrialtest.api.getMachineSpeed(meta)
|
||||||
local requiredPower=elapsed*inductionFurnace.opPower*speed
|
local requiredPower=elapsed*inductionFurnace.opPower*speed
|
||||||
|
|
||||||
industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
|
industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
|
||||||
|
|
||||||
local shouldContinue=false
|
local shouldContinue=false
|
||||||
local results={}
|
local results={}
|
||||||
for _,slot in ipairs(srcList) do
|
for _,slot in ipairs(srcList) do
|
||||||
if slot:is_empty() then
|
if slot:is_empty() then
|
||||||
table.insert(results,false)
|
table.insert(results,false)
|
||||||
else
|
else
|
||||||
local result,after=minetest.get_craft_result({
|
local result,after=minetest.get_craft_result({
|
||||||
method="cooking",
|
method="cooking",
|
||||||
width=1,
|
width=1,
|
||||||
items={slot}
|
items={slot}
|
||||||
})
|
})
|
||||||
if result.time>0 and inv:room_for_item("dst",result.item) then
|
if result.time>0 and inv:room_for_item("dst",result.item) then
|
||||||
table.insert(results,result.item)
|
table.insert(results,result.item)
|
||||||
shouldContinue=true
|
shouldContinue=true
|
||||||
else
|
else
|
||||||
table.insert(results,false)
|
table.insert(results,false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not shouldContinue or powerAmount<requiredPower then
|
if not shouldContinue or powerAmount<requiredPower then
|
||||||
meta:set_float("srcTime",0)
|
meta:set_float("srcTime",0)
|
||||||
minetest.swap_node(pos,{
|
minetest.swap_node(pos,{
|
||||||
name="industrialtest:induction_furnace",
|
name="industrialtest:induction_furnace",
|
||||||
@ -203,10 +203,10 @@ inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
})
|
})
|
||||||
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
|
||||||
return false,true
|
return false,true
|
||||||
end
|
end
|
||||||
|
|
||||||
srcTime=srcTime+elapsed*(1+heat/100)
|
srcTime=srcTime+elapsed*(1+heat/100)
|
||||||
if srcTime>=maxSrcTime then
|
if srcTime>=maxSrcTime then
|
||||||
for i,result in ipairs(results) do
|
for i,result in ipairs(results) do
|
||||||
if result then
|
if result then
|
||||||
local multiplier=math.min(srcList[i]:get_count(),speed)
|
local multiplier=math.min(srcList[i]:get_count(),speed)
|
||||||
@ -218,8 +218,8 @@ inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
srcTime=0
|
srcTime=0
|
||||||
end
|
end
|
||||||
meta:set_float("srcTime",srcTime)
|
meta:set_float("srcTime",srcTime)
|
||||||
|
|
||||||
if heat<100 then
|
if heat<100 then
|
||||||
meta:set_int("heat",math.min(100,heat+speed))
|
meta:set_int("heat",math.min(100,heat+speed))
|
||||||
@ -227,16 +227,16 @@ inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
|
|||||||
|
|
||||||
industrialtest.api.addPower(meta,-requiredPower)
|
industrialtest.api.addPower(meta,-requiredPower)
|
||||||
|
|
||||||
return true,true
|
return true,true
|
||||||
end
|
end
|
||||||
|
|
||||||
industrialtest.internal.registerMachine({
|
industrialtest.internal.registerMachine({
|
||||||
name="induction_furnace",
|
name="induction_furnace",
|
||||||
displayName=S("Induction Furnace"),
|
displayName=S("Induction Furnace"),
|
||||||
capacity=industrialtest.api.mvPowerFlow*2,
|
capacity=industrialtest.api.mvPowerFlow*2,
|
||||||
getFormspec=inductionFurnace.getFormspec,
|
getFormspec=inductionFurnace.getFormspec,
|
||||||
flow=industrialtest.api.mvPowerFlow,
|
flow=industrialtest.api.mvPowerFlow,
|
||||||
ioConfig="iiiiii",
|
ioConfig="iiiiii",
|
||||||
requiresWrench=true,
|
requiresWrench=true,
|
||||||
registerActiveVariant=true,
|
registerActiveVariant=true,
|
||||||
sounds="metal",
|
sounds="metal",
|
||||||
@ -267,9 +267,9 @@ industrialtest.internal.registerMachine({
|
|||||||
"industrialtest_advanced_machine_block.png^industrialtest_electric_furnace_front_active.png"
|
"industrialtest_advanced_machine_block.png^industrialtest_electric_furnace_front_active.png"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onConstruct=inductionFurnace.onConstruct,
|
onConstruct=inductionFurnace.onConstruct,
|
||||||
onTimer=inductionFurnace.onTimer,
|
onTimer=inductionFurnace.onTimer,
|
||||||
allowMetadataInventoryMove=inductionFurnace.allowMetadataInventoryMove,
|
allowMetadataInventoryMove=inductionFurnace.allowMetadataInventoryMove,
|
||||||
allowMetadataInventoryPut=inductionFurnace.allowMetadataInventoryPut,
|
allowMetadataInventoryPut=inductionFurnace.allowMetadataInventoryPut,
|
||||||
onMetadataInventoryPut=inductionFurnace.onMetadataInventoryPut,
|
onMetadataInventoryPut=inductionFurnace.onMetadataInventoryPut,
|
||||||
onMetadataInventoryMove=inductionFurnace.onMetadataInventoryMove,
|
onMetadataInventoryMove=inductionFurnace.onMetadataInventoryMove,
|
||||||
|
Loading…
Reference in New Issue
Block a user