From 8801ef515bc1ed6bcda25d8fd824268d7c666e21 Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sat, 11 May 2024 11:54:33 +0200 Subject: [PATCH 1/3] Deduplicate formspec code --- compatibility.lua | 26 +++++++----- machines/canning_machine.lua | 34 +++------------ machines/chargepad.lua | 38 ++++++----------- machines/common.lua | 54 ++++++++---------------- machines/fluid_generator.lua | 43 ++++++------------- machines/generator.lua | 38 ++++++----------- machines/induction_furnace.lua | 29 +++---------- machines/nuclear_reactor.lua | 35 +++++---------- machines/power_storage.lua | 38 ++++++----------- machines/rotary_macerator.lua | 68 ++++++++++-------------------- machines/solar_panel_generator.lua | 24 +++-------- machines/tool_workshop.lua | 40 ++++++------------ machines/wind_mill.lua | 24 +++-------- 13 files changed, 156 insertions(+), 335 deletions(-) diff --git a/compatibility.lua b/compatibility.lua index cc3f681..c1bff8b 100644 --- a/compatibility.lua +++ b/compatibility.lua @@ -33,12 +33,6 @@ for _,mod in ipairs(requiredMclModules) do end end -if industrialtest.mtgAvailable then - industrialtest.stackMax=99 -elseif industrialtest.mclAvailable then - industrialtest.stackMax=64 -end - industrialtest.mods={} if industrialtest.mtgAvailable then industrialtest.mods._3dArmor=minetest.get_modpath("3d_armor") @@ -53,10 +47,11 @@ if industrialtest.mtgAvailable and not industrialtest.mods._3dArmor then end industrialtest.elementKeys={} - industrialtest.internal={} if industrialtest.mclAvailable then + industrialtest.stackMax=64 + industrialtest.internal.mclMakeStrippedTrunk=function(itemstack,placer,pointedThing,electricTool) -- Taken from https://git.minetest.land/MineClone2/MineClone2/src/branch/master/mods/ITEMS/mcl_tools/init.lua#L360 if pointedThing.type ~= "node" then return end @@ -85,9 +80,22 @@ if industrialtest.mclAvailable then end return itemstack end + industrialtest.internal.explode=function(pos,radius,dropChance) mcl_explosions.explode(pos,radius,{drop_chance=dropChance}) end + + industrialtest.internal.getItemSlotBg=mcl_formspec.get_itemslot_bg +elseif industrialtest.mtgAvailable then + industrialtest.stackMax=99 + + industrialtest.internal.explode=function(pos,radius) + tnt.boom(pos,{radius=radius}) + end + + industrialtest.internal.getItemSlotBg=function() + return "" + end end -- compatibilty that adds not existing elements @@ -611,10 +619,6 @@ if industrialtest.mclAvailable then y_min=mcl_vars.mg_overworld_min }) elseif industrialtest.mtgAvailable then - industrialtest.internal.explode=function(pos,radius) - tnt.boom(pos,{radius=radius}) - end - industrialtest.internal.registerMetal=function(name,displayName,hardness) minetest.register_craftitem("industrialtest:"..name.."_lump",{ description=S(displayName.." Lump"), diff --git a/machines/canning_machine.lua b/machines/canning_machine.lua index 7190237..381eee9 100644 --- a/machines/canning_machine.lua +++ b/machines/canning_machine.lua @@ -24,46 +24,26 @@ canningMachine.getFormspec=function(pos) local meta=minetest.get_meta(pos) local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100 local srcPercent=meta:get_float("srcTime")/canningMachine.canningTime*100 - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;src;3.4,1.8;1,1]", - (powerPercent>0 and "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" - or "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png]"), - "list[context;powerStorage;3.4,3.9;1,1]", - (srcPercent>0 and "image[4.9,1.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]" - or "image[4.9,1.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"), - "list[context;dst;6.4,1.8;1,1]", - "list[context;leftover;6.4,2.8;1,1]", - "list[context;upgrades;9,0.9;1,4]", - "listring[context;src]", - "listring[context;powerStorage]", - "listring[context;dst]", - "listring[context;leftover]", - "listring[context;upgrades]" - } - elseif industrialtest.mclAvailable then - formspec={ + local formspec={ "list[context;src;3.4,1.8;1,1]", - mcl_formspec.get_itemslot_bg(3.4,1.8,1,1), + industrialtest.internal.getItemSlotBg(3.4,1.8,1,1), (powerPercent>0 and "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" or "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png]"), "list[context;powerStorage;3.4,3.9;1,1]", - mcl_formspec.get_itemslot_bg(3.4,3.9,1,1), + industrialtest.internal.getItemSlotBg(3.4,3.9,1,1), (srcPercent>0 and "image[4.9,1.8;1,1;gui_furnace_arrow_bg.png^[lowpart:"..srcPercent..":gui_furnace_arrow_fg.png^[transformR270]" or "image[4.9,1.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"), "list[context;dst;6.4,1.8;1,1]", - mcl_formspec.get_itemslot_bg(6.4,1.8,1,1), + industrialtest.internal.getItemSlotBg(6.4,1.8,1,1), "list[context;leftover;6.4,2.8;1,1]", - mcl_formspec.get_itemslot_bg(6.4,2.8,1,1), + industrialtest.internal.getItemSlotBg(6.4,2.8,1,1), "list[context;upgrades;9,0.9;1,4]", - mcl_formspec.get_itemslot_bg(9,0.9,1,4), + industrialtest.internal.getItemSlotBg(9,0.9,1,4), "listring[context;src]", "listring[context;powerStorage]", "listring[context;dst]", "listring[context;upgrades]" - } - end + } return table.concat(formspec,"") end diff --git a/machines/chargepad.lua b/machines/chargepad.lua index 7c14396..c0c4b13 100644 --- a/machines/chargepad.lua +++ b/machines/chargepad.lua @@ -71,32 +71,18 @@ end chargepad.getFormspec=function(pos) local meta=minetest.get_meta(pos) local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity") - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;charged;1,2.5;1,1]", - "listring[context;charged]", - "label[0.9,3.9;"..S("Charge").."]", - "list[context;discharged;3,2.5;1,1]", - "listring[context;discharged]", - "label[2.7,3.9;"..S("Discharge").."]", - "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 "") - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;charged;1,2.5;1,1]", - "listring[context;charged]", - mcl_formspec.get_itemslot_bg(1,2.5,1,1), - "label[0.9,3.9;"..S("Charge").."]", - "list[context;discharged;3,2.5;1,1]", - "listring[context;discharged]", - mcl_formspec.get_itemslot_bg(3,2.5,1,1), - "label[2.7,3.9;"..S("Discharge").."]", - "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 "") - } - end + local formspec={ + "list[context;charged;1,2.5;1,1]", + "listring[context;charged]", + industrialtest.internal.getItemSlotBg(1,2.5,1,1), + "label[0.9,3.9;"..S("Charge").."]", + "list[context;discharged;3,2.5;1,1]", + "listring[context;discharged]", + industrialtest.internal.getItemSlotBg(3,2.5,1,1), + "label[2.7,3.9;"..S("Discharge").."]", + "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 "") + } return table.concat(formspec,"") end diff --git a/machines/common.lua b/machines/common.lua index 4102de2..e105753 100644 --- a/machines/common.lua +++ b/machines/common.lua @@ -548,42 +548,24 @@ simpleElectricItemProcessor.getFormspec=function(pos) local meta=minetest.get_meta(pos) local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100 local srcPercent=meta:get_float("srcTime")/meta:get_float("maxSrcTime")*100 - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;src;3.4,1.8;1,1]", - "listring[context;src]", - (powerPercent>0 and "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" - or "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png]"), - "list[context;powerStorage;3.4,3.9;1,1]", - "listring[context;powerStorage]", - (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]"), - "list[context;dst;6.4,2.8;1,1]", - "listring[context;dst]", - "list[context;upgrades;9,0.9;1,4]", - "listring[context;upgrades]" - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;src;3.4,1.8;1,1]", - mcl_formspec.get_itemslot_bg(3.4,1.8,1,1), - "listring[context;src]", - (powerPercent>0 and "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" - or "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png]"), - "list[context;powerStorage;3.4,3.9;1,1]", - mcl_formspec.get_itemslot_bg(3.4,3.9,1,1), - "listring[context;powerStorage]", - (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]"), - "list[context;dst;6.4,2.8;1,1]", - mcl_formspec.get_itemslot_bg(6.4,2.8,1,1), - "listring[context;dst]", - "list[context;upgrades;9,0.9;1,4]", - mcl_formspec.get_itemslot_bg(9,0.9,1,4), - "listring[context;upgrades]" - } - end + local formspec={ + "list[context;src;3.4,1.8;1,1]", + industrialtest.internal.getItemSlotBg(3.4,1.8,1,1), + "listring[context;src]", + (powerPercent>0 and "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" + or "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png]"), + "list[context;powerStorage;3.4,3.9;1,1]", + industrialtest.internal.getItemSlotBg(3.4,3.9,1,1), + "listring[context;powerStorage]", + (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]"), + "list[context;dst;6.4,2.8;1,1]", + industrialtest.internal.getItemSlotBg(6.4,2.8,1,1), + "listring[context;dst]", + "list[context;upgrades;9,0.9;1,4]", + industrialtest.internal.getItemSlotBg(9,0.9,1,4), + "listring[context;upgrades]" + } return table.concat(formspec,"") end diff --git a/machines/fluid_generator.lua b/machines/fluid_generator.lua index d3c8b51..a92750c 100644 --- a/machines/fluid_generator.lua +++ b/machines/fluid_generator.lua @@ -22,37 +22,22 @@ fluidGenerator.getFormspec=function(pos,config) local fluidPercent=meta:get_float("fluidAmount")/100 local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity") local fluid=meta:get_string("fluid") - local formspec local fuel=config.getFuel(fluid) local tile=(fuel and fuel.texture or "industrialtest_gui_fluid_bg.png") - if industrialtest.mtgAvailable then - formspec={ - "list[context;src;2,1.8;1,1]", - "listring[context;src]", - (fluidPercent>0 and "image[2,3;1,1;industrialtest_gui_fluid_bg.png^[lowpart:"..fluidPercent..":"..tile.."]" or "image[2,3;1,1;industrialtest_gui_fluid_bg.png]"), - "list[context;dst;2,4.2;1,1]", - "listring[context;dst]", - "list[context;charged;6,3;1,1]", - "listring[context;charged]", - "box[9,1;0.3,4.8;#202020]", - (powerPercent>0 and "box[9,"..(1+4.8-(powerPercent*4.8))..";0.3,"..(powerPercent*4.8)..";#FF1010]" or "") - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;src;2,1.8;1,1]", - mcl_formspec.get_itemslot_bg(2,1.8,1,1), - "listring[context;src]", - (fluidPercent>0 and "image[2,3;1,1;industrialtest_gui_fluid_bg.png^[lowpart:"..fluidPercent..":"..tile.."]" or "image[2,3;1,1;industrialtest_gui_fluid_bg.png]"), - "list[context;dst;2,4.2;1,1]", - mcl_formspec.get_itemslot_bg(2,4.2,1,1), - "listring[context;dst]", - "list[context;charged;6,3;1,1]", - mcl_formspec.get_itemslot_bg(6,3,1,1), - "listring[context;charged]", - "box[9,1;0.3,4.8;#202020]", - (powerPercent>0 and "box[9,"..(1+4.8-(powerPercent*4.8))..";0.3,"..(powerPercent*4.8)..";#FF1010]" or "") - } - end + local formspec={ + "list[context;src;2,1.8;1,1]", + industrialtest.internal.getItemSlotBg(2,1.8,1,1), + "listring[context;src]", + (fluidPercent>0 and "image[2,3;1,1;industrialtest_gui_fluid_bg.png^[lowpart:"..fluidPercent..":"..tile.."]" or "image[2,3;1,1;industrialtest_gui_fluid_bg.png]"), + "list[context;dst;2,4.2;1,1]", + industrialtest.internal.getItemSlotBg(2,4.2,1,1), + "listring[context;dst]", + "list[context;charged;6,3;1,1]", + industrialtest.internal.getItemSlotBg(6,3,1,1), + "listring[context;charged]", + "box[9,1;0.3,4.8;#202020]", + (powerPercent>0 and "box[9,"..(1+4.8-(powerPercent*4.8))..";0.3,"..(powerPercent*4.8)..";#FF1010]" or "") + } return table.concat(formspec,"") end diff --git a/machines/generator.lua b/machines/generator.lua index a14f12e..dd6b459 100644 --- a/machines/generator.lua +++ b/machines/generator.lua @@ -21,32 +21,18 @@ generator.getFormspec=function(pos) local meta=minetest.get_meta(pos) local fuelPercent=meta:get_int("fuelTime")/meta:get_int("maxFuelTime")*100 local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity") - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;charged;4.9,1.8;1,1]", - "listring[context;charged]", - (fuelPercent>0 and "image[4.9,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]" - or "image[4.9,2.8;1,1;default_furnace_fire_bg.png]"), - "list[context;src;4.9,3.9;1,1]", - "listring[context;src]", - "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 "") - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;charged;4.7,1.8;1,1]", - mcl_formspec.get_itemslot_bg(4.7,1.8,1,1), - "listring[context;charged]", - (fuelPercent>0 and "image[4.7,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]" - or "image[4.7,2.8;1,1;default_furnace_fire_bg.png]"), - "list[context;src;4.7,3.9;1,1]", - mcl_formspec.get_itemslot_bg(4.7,3.9,1,1), - "listring[context;src]", - "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 "") - } - end + local formspec={ + "list[context;charged;4.7,1.8;1,1]", + industrialtest.internal.getItemSlotBg(4.7,1.8,1,1), + "listring[context;charged]", + (fuelPercent>0 and "image[4.7,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]" + or "image[4.7,2.8;1,1;default_furnace_fire_bg.png]"), + "list[context;src;4.7,3.9;1,1]", + industrialtest.internal.getItemSlotBg(4.7,3.9,1,1), + "listring[context;src]", + "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 "") + } return table.concat(formspec,"") end diff --git a/machines/induction_furnace.lua b/machines/induction_furnace.lua index 73640f7..1618ad1 100644 --- a/machines/induction_furnace.lua +++ b/machines/induction_furnace.lua @@ -43,44 +43,25 @@ inductionFurnace.getFormspec=function(pos) local maxSrcTime=meta:get_float("maxSrcTime") local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0 local heat=meta:get_int("heat") - local formspec - if industrialtest.mtgAvailable then - formspec={ + local formspec={ "list[context;src;3.7,1.8;2,1]", + industrialtest.internal.getItemSlotBg(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]" or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"), "list[context;powerStorage;3.7,3.9;1,1]", + industrialtest.internal.getItemSlotBg(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]" or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"), "list[context;dst;6,2.8;2,1;]", + industrialtest.internal.getItemSlotBg(6,2.8,2,1), "list[context;upgrades;9,0.9;1,4]", + industrialtest.internal.getItemSlotBg(9,0.9,1,4), "label[0.5,2.8;"..minetest.formspec_escape(S("Heat: @1 %",heat)).."]", "listring[context;src]", "listring[context;powerStorage]", "listring[context;dst]", "listring[context;upgrades]" } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;src;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]" - or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"), - "list[context;powerStorage;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]" - or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"), - "list[context;dst;6,2.8;2,1;]", - mcl_formspec.get_itemslot_bg(6,2.8,2,1), - "list[context;upgrades;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)).."]", - "listring[context;src]", - "listring[context;powerStorage]", - "listring[context;dst]", - "listring[context;upgrades]" - } - end return table.concat(formspec,"") end diff --git a/machines/nuclear_reactor.lua b/machines/nuclear_reactor.lua index 3bebb87..425e05f 100644 --- a/machines/nuclear_reactor.lua +++ b/machines/nuclear_reactor.lua @@ -23,30 +23,17 @@ reactor.getFormspec=function(pos) local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity") local size=math.floor(meta:get_int("size")/3) local switchText=(meta:get_int("enabled")==0 and S("Start") or S("Stop")) - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;fuel;1,1;"..size..","..size.."]", - "listring[context;fuel]", - "list[context;charged;7.7,2.8;1,1]", - "listring[context;charged]", - "button[7.7,1;1,0.8;toggle;"..minetest.formspec_escape(switchText).."]", - "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 ""), - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;fuel;1,1;"..size..","..size.."]", - mcl_formspec.get_itemslot_bg(1,1,size,size), - "listring[context;fuel]", - "list[context;charged;7,2.8;1,1]", - mcl_formspec.get_itemslot_bg(7.7,2.8,1,1), - "listring[context;charged]", - "button[7.7,1;1,0.8;toggle;"..minetest.formspec_escape(switchText).."]", - "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 "") - } - end + local formspec={ + "list[context;fuel;1,1;"..size..","..size.."]", + industrialtest.internal.getItemSlotBg(1,1,size,size), + "listring[context;fuel]", + "list[context;charged;7,2.8;1,1]", + industrialtest.internal.getItemSlotBg(7.7,2.8,1,1), + "listring[context;charged]", + "button[7.7,1;1,0.8;toggle;"..minetest.formspec_escape(switchText).."]", + "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 "") + } return table.concat(formspec,"") end diff --git a/machines/power_storage.lua b/machines/power_storage.lua index 93492ec..ced1088 100644 --- a/machines/power_storage.lua +++ b/machines/power_storage.lua @@ -20,32 +20,18 @@ local powerStorage={} powerStorage.getFormspec=function(pos) local meta=minetest.get_meta(pos) local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity") - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;charged;1,2.5;1,1]", - "listring[context;charged]", - "label[0.9,3.9;"..S("Charge").."]", - "list[context;discharged;3,2.5;1,1]", - "listring[context;discharged]", - "label[2.7,3.9;"..S("Discharge").."]", - "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 "") - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;charged;1,2.5;1,1]", - "listring[context;charged]", - mcl_formspec.get_itemslot_bg(1,2.5,1,1), - "label[0.9,3.9;"..S("Charge").."]", - "list[context;discharged;3,2.5;1,1]", - "listring[context;discharged]", - mcl_formspec.get_itemslot_bg(3,2.5,1,1), - "label[2.7,3.9;"..S("Discharge").."]", - "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 "") - } - end + local formspec={ + "list[context;charged;1,2.5;1,1]", + "listring[context;charged]", + industrialtest.internal.getItemSlotBg(1,2.5,1,1), + "label[0.9,3.9;"..S("Charge").."]", + "list[context;discharged;3,2.5;1,1]", + "listring[context;discharged]", + industrialtest.internal.getItemSlotBg(3,2.5,1,1), + "label[2.7,3.9;"..S("Discharge").."]", + "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 "") + } return table.concat(formspec,"") end diff --git a/machines/rotary_macerator.lua b/machines/rotary_macerator.lua index 2007ec6..03783a7 100644 --- a/machines/rotary_macerator.lua +++ b/machines/rotary_macerator.lua @@ -27,51 +27,29 @@ rotaryMacerator.getFormspec=function(pos) local srcPercent=maxSrcTime>0 and meta:get_float("srcTime")/maxSrcTime*100 or 0 local rpm=meta:get_int("rpm") local buttonMaintainSpeedText=meta:get_int("maintainSpeed")==1 and S("Don't maintain speed") or S("Maintain speed") - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;src;3.8,1.8;1,1]", - "list[context;modifier;4.9,1.8;1,1]", - (powerPercent>0 and "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" - or "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png]"), - "list[context;powerStorage;3.8,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]" - or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"), - "list[context;dst;6,2.8;1,1;]", - "list[context;upgrades;9,0.9;1,4]", - "label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]", - "button[0.5,3.4;3,0.8;maintainSpeed;"..minetest.formspec_escape(buttonMaintainSpeedText).."]", - "listring[context;src]", - "listring[context;modifier]", - "listring[context;powerStorage]", - "listring[context;dst]", - "listring[context;upgrades]" - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;src;3.8,1.8;1,1]", - mcl_formspec.get_itemslot_bg(3.8,1.8,1,1), - "list[context;modifier;4.9,1.8;1,1]", - mcl_formspec.get_itemslot_bg(4.9,1.8,1,1), - (powerPercent>0 and "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" - or "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png]"), - "list[context;powerStorage;3.8,3.9;1,1]", - mcl_formspec.get_itemslot_bg(3.8,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]" - or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"), - "list[context;dst;6,2.8;1,1;]", - mcl_formspec.get_itemslot_bg(6,2.8,1,1), - "list[context;upgrades;9,0.9;1,4]", - mcl_formspec.get_itemslot_bg(9,0.9,1,4), - "label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]", - "button[0.5,3.4;3,0.8;maintainSpeed;"..minetest.formspec_escape(buttonMaintainSpeedText).."]", - "listring[context;src]", - "listring[context;modifier]", - "listring[context;powerStorage]", - "listring[context;dst]", - "listring[context;upgrades]" - } - end + local formspec={ + "list[context;src;3.8,1.8;1,1]", + industrialtest.internal.getItemSlotBg(3.8,1.8,1,1), + "list[context;modifier;4.9,1.8;1,1]", + industrialtest.internal.getItemSlotBg(4.9,1.8,1,1), + (powerPercent>0 and "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" + or "image[3.8,2.8;1,1;industrialtest_gui_electricity_bg.png]"), + "list[context;powerStorage;3.8,3.9;1,1]", + industrialtest.internal.getItemSlotBg(3.8,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]" + or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"), + "list[context;dst;6,2.8;1,1;]", + industrialtest.internal.getItemSlotBg(6,2.8,1,1), + "list[context;upgrades;9,0.9;1,4]", + industrialtest.internal.getItemSlotBg(9,0.9,1,4), + "label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]", + "button[0.5,3.4;3,0.8;maintainSpeed;"..minetest.formspec_escape(buttonMaintainSpeedText).."]", + "listring[context;src]", + "listring[context;modifier]", + "listring[context;powerStorage]", + "listring[context;dst]", + "listring[context;upgrades]" + } return table.concat(formspec,"") end diff --git a/machines/solar_panel_generator.lua b/machines/solar_panel_generator.lua index 3a3f8a8..a42aee5 100644 --- a/machines/solar_panel_generator.lua +++ b/machines/solar_panel_generator.lua @@ -20,23 +20,13 @@ local solarPanel={} solarPanel.getFormspec=function(pos) local amount=minetest.get_natural_light(vector.offset(pos,0,1,0))/15.0 local charging=amount>0.5 - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;charged;4.9,1.8;1,1]", - "listring[context;charged]", - (charging and "image[4.9,2.8;1,1;industrialtest_gui_sun_fg.png]" - or "image[4.9,2.8;1,1;industrialtest_gui_sun_bg.png]") - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;charged;4.7,1.8;1,1]", - mcl_formspec.get_itemslot_bg(4.7,1.8,1,1), - "listring[context;charged]", - (charging and "image[4.7,2.8;1,1;industrialtest_gui_sun_fg.png]" - or "image[4.7,2.8;1,1;industrialtest_gui_sun_bg.png]") - } - end + local formspec={ + "list[context;charged;4.7,1.8;1,1]", + industrialtest.internal.getItemSlotBg(4.7,1.8,1,1), + "listring[context;charged]", + (charging and "image[4.7,2.8;1,1;industrialtest_gui_sun_fg.png]" + or "image[4.7,2.8;1,1;industrialtest_gui_sun_bg.png]") + } return table.concat(formspec,"") end diff --git a/machines/tool_workshop.lua b/machines/tool_workshop.lua index 99109fc..681f42d 100644 --- a/machines/tool_workshop.lua +++ b/machines/tool_workshop.lua @@ -20,33 +20,19 @@ local toolWorkshop={} toolWorkshop.getFormspec=function(pos) local meta=minetest.get_meta(pos) local powerPercent=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity")*100 - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;powerStorage;3.7,3.7;1,1;0]", - "listring[context;powerStorage]", - (powerPercent>0 and "image[3.7,2.5;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" - or "image[3.7,2.5;1,1;industrialtest_gui_electricity_bg.png]"), - "list[context;src;5.9,3.2;1,1;0]", - "listring[context;src]", - "list[context;upgrades;9,0.9;1,4]", - "listring[context;upgrades]" - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;powerStorage;3.7,3.7;1,1;0]", - mcl_formspec.get_itemslot_bg(3.7,3.7,1,1), - "listring[context;powerStorage]", - (powerPercent>0 and "image[3.7,2.5;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" - or "image[3.7,2.5;1,1;industrialtest_gui_electricity_bg.png]"), - "list[context;src;5.9,3.2;1,1;0]", - mcl_formspec.get_itemslot_bg(5.9,3.2,1,1), - "listring[context;src]", - "list[context;upgrades;9,0.9;1,4]", - mcl_formspec.get_itemslot_bg(9,0.9,1,4), - "listring[context;upgrades]" - } - end + local formspec={ + "list[context;powerStorage;3.7,3.7;1,1;0]", + industrialtest.internal.getItemSlotBg(3.7,3.7,1,1), + "listring[context;powerStorage]", + (powerPercent>0 and "image[3.7,2.5;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" + or "image[3.7,2.5;1,1;industrialtest_gui_electricity_bg.png]"), + "list[context;src;5.9,3.2;1,1;0]", + industrialtest.internal.getItemSlotBg(5.9,3.2,1,1), + "listring[context;src]", + "list[context;upgrades;9,0.9;1,4]", + industrialtest.internal.getItemSlotBg(9,0.9,1,4), + "listring[context;upgrades]" + } return table.concat(formspec,"") end diff --git a/machines/wind_mill.lua b/machines/wind_mill.lua index 55fd747..3e82505 100644 --- a/machines/wind_mill.lua +++ b/machines/wind_mill.lua @@ -20,23 +20,13 @@ local windMill={} windMill.getFormspec=function(pos) local meta=minetest.get_meta(pos) local charging=meta:get_int("charging") - local formspec - if industrialtest.mtgAvailable then - formspec={ - "list[context;charged;4.9,1.8;1,1]", - "listring[context;charged]", - (charging>0 and "image[4.9,3;1,1;industrialtest_gui_wind_bg.png^[lowpart:"..charging..":industrialtest_gui_wind_fg.png]" - or "image[4.9,3;1,1;industrialtest_gui_wind_bg.png]") - } - elseif industrialtest.mclAvailable then - formspec={ - "list[context;charged;4.7,1.8;1,1]", - mcl_formspec.get_itemslot_bg(4.7,1.8,1,1), - "listring[context;charged]", - (charging>0 and "image[4.7,3;1,1;industrialtest_gui_wind_bg.png^[lowpart:"..charging..":industrialtest_gui_wind_fg.png]" - or "image[4.7,3;1,1;industrialtest_gui_wind_bg.png]") - } - end + local formspec={ + "list[context;charged;4.7,1.8;1,1]", + industrialtest.internal.getItemSlotBg(4.7,1.8,1,1), + "listring[context;charged]", + (charging>0 and "image[4.7,3;1,1;industrialtest_gui_wind_bg.png^[lowpart:"..charging..":industrialtest_gui_wind_fg.png]" + or "image[4.7,3;1,1;industrialtest_gui_wind_bg.png]") + } return table.concat(formspec,"") end From 961e08647ffdcfe5c4416396e77672ba9b39b010 Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sat, 11 May 2024 12:03:27 +0200 Subject: [PATCH 2/3] Add HandfulOfFrogs to contributors section in README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 568f241..d9c2325 100644 --- a/README.md +++ b/README.md @@ -19,5 +19,6 @@ Currently IndustrialTest supports following games: ## Contributors - mrkubax10 [programming, some graphics] +- HandfulOfFrogs <> [some programming, graphics] - LuanHawk [lead graphics] - Migdyn <> [graphics] From 36c5b3c8ac1823605c2cda225051c0d7719c849e Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Sat, 11 May 2024 12:53:18 +0200 Subject: [PATCH 3/3] Fix listrings in machine formspecs to make it possible to move items with shift Fixes #12 --- machines/canning_machine.lua | 4 +--- machines/chargepad.lua | 6 +++--- machines/common.lua | 16 ++++++++-------- machines/fluid_generator.lua | 7 +++---- machines/generator.lua | 5 ++--- machines/induction_furnace.lua | 4 +--- machines/iron_furnace.lua | 16 ++++++++-------- machines/nuclear_reactor.lua | 5 ++--- machines/power_storage.lua | 6 +++--- machines/rotary_macerator.lua | 5 +---- machines/solar_panel_generator.lua | 4 ++-- machines/tool_workshop.lua | 4 +--- machines/wind_mill.lua | 4 ++-- 13 files changed, 37 insertions(+), 49 deletions(-) diff --git a/machines/canning_machine.lua b/machines/canning_machine.lua index 381eee9..8421c53 100644 --- a/machines/canning_machine.lua +++ b/machines/canning_machine.lua @@ -40,9 +40,7 @@ canningMachine.getFormspec=function(pos) "list[context;upgrades;9,0.9;1,4]", industrialtest.internal.getItemSlotBg(9,0.9,1,4), "listring[context;src]", - "listring[context;powerStorage]", - "listring[context;dst]", - "listring[context;upgrades]" + "listring[context;dst]" } return table.concat(formspec,"") end diff --git a/machines/chargepad.lua b/machines/chargepad.lua index c0c4b13..7ea9936 100644 --- a/machines/chargepad.lua +++ b/machines/chargepad.lua @@ -73,15 +73,15 @@ chargepad.getFormspec=function(pos) local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity") local formspec={ "list[context;charged;1,2.5;1,1]", - "listring[context;charged]", industrialtest.internal.getItemSlotBg(1,2.5,1,1), "label[0.9,3.9;"..S("Charge").."]", "list[context;discharged;3,2.5;1,1]", - "listring[context;discharged]", industrialtest.internal.getItemSlotBg(3,2.5,1,1), "label[2.7,3.9;"..S("Discharge").."]", "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 "") + (charged>0 and "box[9,"..(1+4.8-(charged*4.8))..";0.3,"..(charged*4.8)..";#FF1010]" or ""), + "listring[context;charged]", + "listring[context;discharged]" } return table.concat(formspec,"") end diff --git a/machines/common.lua b/machines/common.lua index e105753..f5de182 100644 --- a/machines/common.lua +++ b/machines/common.lua @@ -72,19 +72,21 @@ machine.getFormspec=function(pos,config) "formspec_version[4]", "size[10.8,12]", "label[0.5,0.5;"..config.displayName.."]", - (config.getFormspec and config.getFormspec(pos) or ""), "list[current_player;main;0.5,6.25;8,1]", - "list[current_player;main;0.5,7.5;8,3;8]" + "list[current_player;main;0.5,7.5;8,3;8]", + "listring[current_player;main]", + (config.getFormspec and config.getFormspec(pos) or "") } elseif industrialtest.mclAvailable then formspec={ "size[10.04,12]", "label[0.25,0.25;"..config.displayName.."]", - (config.getFormspec and config.getFormspec(pos) or ""), "list[current_player;main;0.5,7;9,3;9]", mcl_formspec.get_itemslot_bg(0.5,7,9,3), "list[current_player;main;0.5,10.24;9,1]", - mcl_formspec.get_itemslot_bg(0.5,10.24,9,1) + mcl_formspec.get_itemslot_bg(0.5,10.24,9,1), + "listring[current_player;main]", + (config.getFormspec and config.getFormspec(pos) or "") } end return table.concat(formspec,"") @@ -551,20 +553,18 @@ simpleElectricItemProcessor.getFormspec=function(pos) local formspec={ "list[context;src;3.4,1.8;1,1]", industrialtest.internal.getItemSlotBg(3.4,1.8,1,1), - "listring[context;src]", (powerPercent>0 and "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" or "image[3.4,2.8;1,1;industrialtest_gui_electricity_bg.png]"), "list[context;powerStorage;3.4,3.9;1,1]", industrialtest.internal.getItemSlotBg(3.4,3.9,1,1), - "listring[context;powerStorage]", (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]"), "list[context;dst;6.4,2.8;1,1]", industrialtest.internal.getItemSlotBg(6.4,2.8,1,1), - "listring[context;dst]", "list[context;upgrades;9,0.9;1,4]", industrialtest.internal.getItemSlotBg(9,0.9,1,4), - "listring[context;upgrades]" + "listring[context;src]", + "listring[context;dst]" } return table.concat(formspec,"") end diff --git a/machines/fluid_generator.lua b/machines/fluid_generator.lua index a92750c..7c637fa 100644 --- a/machines/fluid_generator.lua +++ b/machines/fluid_generator.lua @@ -27,16 +27,15 @@ fluidGenerator.getFormspec=function(pos,config) local formspec={ "list[context;src;2,1.8;1,1]", industrialtest.internal.getItemSlotBg(2,1.8,1,1), - "listring[context;src]", (fluidPercent>0 and "image[2,3;1,1;industrialtest_gui_fluid_bg.png^[lowpart:"..fluidPercent..":"..tile.."]" or "image[2,3;1,1;industrialtest_gui_fluid_bg.png]"), "list[context;dst;2,4.2;1,1]", industrialtest.internal.getItemSlotBg(2,4.2,1,1), - "listring[context;dst]", "list[context;charged;6,3;1,1]", industrialtest.internal.getItemSlotBg(6,3,1,1), - "listring[context;charged]", "box[9,1;0.3,4.8;#202020]", - (powerPercent>0 and "box[9,"..(1+4.8-(powerPercent*4.8))..";0.3,"..(powerPercent*4.8)..";#FF1010]" or "") + (powerPercent>0 and "box[9,"..(1+4.8-(powerPercent*4.8))..";0.3,"..(powerPercent*4.8)..";#FF1010]" or ""), + "listring[context;src]", + "listring[context;dst]" } return table.concat(formspec,"") end diff --git a/machines/generator.lua b/machines/generator.lua index dd6b459..718d2c2 100644 --- a/machines/generator.lua +++ b/machines/generator.lua @@ -24,14 +24,13 @@ generator.getFormspec=function(pos) local formspec={ "list[context;charged;4.7,1.8;1,1]", industrialtest.internal.getItemSlotBg(4.7,1.8,1,1), - "listring[context;charged]", (fuelPercent>0 and "image[4.7,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]" or "image[4.7,2.8;1,1;default_furnace_fire_bg.png]"), "list[context;src;4.7,3.9;1,1]", industrialtest.internal.getItemSlotBg(4.7,3.9,1,1), - "listring[context;src]", "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 "") + (charged>0 and "box[9,"..(1+4.8-(charged*4.8))..";0.3,"..(charged*4.8)..";#FF1010]" or ""), + "listring[context;src]" } return table.concat(formspec,"") end diff --git a/machines/induction_furnace.lua b/machines/induction_furnace.lua index 1618ad1..61ead22 100644 --- a/machines/induction_furnace.lua +++ b/machines/induction_furnace.lua @@ -58,9 +58,7 @@ inductionFurnace.getFormspec=function(pos) industrialtest.internal.getItemSlotBg(9,0.9,1,4), "label[0.5,2.8;"..minetest.formspec_escape(S("Heat: @1 %",heat)).."]", "listring[context;src]", - "listring[context;powerStorage]", - "listring[context;dst]", - "listring[context;upgrades]" + "listring[context;dst]" } return table.concat(formspec,"") end diff --git a/machines/iron_furnace.lua b/machines/iron_furnace.lua index 2676300..7031464 100644 --- a/machines/iron_furnace.lua +++ b/machines/iron_furnace.lua @@ -25,17 +25,17 @@ ironFurnace.getFormspec=function(fuelPercent,srcPercent) "size[10.8,12]", "label[0.5,0.5;"..S("Iron Furnace").."]", "list[context;src;3.4,1.8;1,1]", - "listring[context;src]", (fuelPercent>0 and "image[3.4,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]" or "image[3.4,2.8;1,1;default_furnace_fire_bg.png]"), "list[context;fuel;3.4,3.9;1,1]", - "listring[context;fuel]", (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]"), "list[context;dst;6.4,2.8;1,1]", - "listring[context;dst]", "list[current_player;main;0.5,6.25;8,1]", - "list[current_player;main;0.5,7.5;8,3;8]" + "list[current_player;main;0.5,7.5;8,3;8]", + "listring[current_player;main]", + "listring[context;src]", + "listring[context;dst]" } elseif industrialtest.mclAvailable then formspec={ @@ -43,21 +43,21 @@ ironFurnace.getFormspec=function(fuelPercent,srcPercent) "label[0.25,0.25;"..S("Iron Furnace").."]", "list[context;src;3.4,1.8;1,1]", mcl_formspec.get_itemslot_bg(3.4,1.8,1,1), - "listring[context;src]", (fuelPercent>0 and "image[3.4,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]" or "image[3.4,2.8;1,1;default_furnace_fire_bg.png]"), "list[context;fuel;3.4,3.9;1,1]", mcl_formspec.get_itemslot_bg(3.4,3.9,1,1), - "listring[context;fuel]", (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]"), "list[context;dst;6.4,2.8;1,1]", mcl_formspec.get_itemslot_bg(6.4,2.8,1,1), - "listring[context;dst]", "list[current_player;main;0.5,7;9,3;9]", mcl_formspec.get_itemslot_bg(0.5,7,9,3), "list[current_player;main;0.5,10.24;9,1]", - mcl_formspec.get_itemslot_bg(0.5,10.24,9,1) + mcl_formspec.get_itemslot_bg(0.5,10.24,9,1), + "listring[current_player;main]", + "listring[context;src]", + "listring[context;dst]" } end return table.concat(formspec,"") diff --git a/machines/nuclear_reactor.lua b/machines/nuclear_reactor.lua index 425e05f..5f9e583 100644 --- a/machines/nuclear_reactor.lua +++ b/machines/nuclear_reactor.lua @@ -26,13 +26,12 @@ reactor.getFormspec=function(pos) local formspec={ "list[context;fuel;1,1;"..size..","..size.."]", industrialtest.internal.getItemSlotBg(1,1,size,size), - "listring[context;fuel]", "list[context;charged;7,2.8;1,1]", industrialtest.internal.getItemSlotBg(7.7,2.8,1,1), - "listring[context;charged]", "button[7.7,1;1,0.8;toggle;"..minetest.formspec_escape(switchText).."]", "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 "") + (charged>0 and "box[9,"..(1+4.8-(charged*4.8))..";0.3,"..(charged*4.8)..";#FF1010]" or ""), + "listring[context;fuel]" } return table.concat(formspec,"") end diff --git a/machines/power_storage.lua b/machines/power_storage.lua index ced1088..330c1a1 100644 --- a/machines/power_storage.lua +++ b/machines/power_storage.lua @@ -22,15 +22,15 @@ powerStorage.getFormspec=function(pos) local charged=meta:get_int("industrialtest.powerAmount")/meta:get_int("industrialtest.powerCapacity") local formspec={ "list[context;charged;1,2.5;1,1]", - "listring[context;charged]", industrialtest.internal.getItemSlotBg(1,2.5,1,1), "label[0.9,3.9;"..S("Charge").."]", "list[context;discharged;3,2.5;1,1]", - "listring[context;discharged]", industrialtest.internal.getItemSlotBg(3,2.5,1,1), "label[2.7,3.9;"..S("Discharge").."]", "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 "") + (charged>0 and "box[9,"..(1+4.8-(charged*4.8))..";0.3,"..(charged*4.8)..";#FF1010]" or ""), + "listring[context;charged]", + "listring[context;discharged]" } return table.concat(formspec,"") end diff --git a/machines/rotary_macerator.lua b/machines/rotary_macerator.lua index 03783a7..bfa75b9 100644 --- a/machines/rotary_macerator.lua +++ b/machines/rotary_macerator.lua @@ -45,10 +45,7 @@ rotaryMacerator.getFormspec=function(pos) "label[0.5,2.8;"..minetest.formspec_escape(S("Speed: @1",rpm)).."]", "button[0.5,3.4;3,0.8;maintainSpeed;"..minetest.formspec_escape(buttonMaintainSpeedText).."]", "listring[context;src]", - "listring[context;modifier]", - "listring[context;powerStorage]", - "listring[context;dst]", - "listring[context;upgrades]" + "listring[context;dst]" } return table.concat(formspec,"") end diff --git a/machines/solar_panel_generator.lua b/machines/solar_panel_generator.lua index a42aee5..de240b7 100644 --- a/machines/solar_panel_generator.lua +++ b/machines/solar_panel_generator.lua @@ -23,9 +23,9 @@ solarPanel.getFormspec=function(pos) local formspec={ "list[context;charged;4.7,1.8;1,1]", industrialtest.internal.getItemSlotBg(4.7,1.8,1,1), - "listring[context;charged]", (charging and "image[4.7,2.8;1,1;industrialtest_gui_sun_fg.png]" - or "image[4.7,2.8;1,1;industrialtest_gui_sun_bg.png]") + or "image[4.7,2.8;1,1;industrialtest_gui_sun_bg.png]"), + "listring[context;charged]" } return table.concat(formspec,"") end diff --git a/machines/tool_workshop.lua b/machines/tool_workshop.lua index 681f42d..57e9e85 100644 --- a/machines/tool_workshop.lua +++ b/machines/tool_workshop.lua @@ -23,15 +23,13 @@ toolWorkshop.getFormspec=function(pos) local formspec={ "list[context;powerStorage;3.7,3.7;1,1;0]", industrialtest.internal.getItemSlotBg(3.7,3.7,1,1), - "listring[context;powerStorage]", (powerPercent>0 and "image[3.7,2.5;1,1;industrialtest_gui_electricity_bg.png^[lowpart:"..powerPercent..":industrialtest_gui_electricity_fg.png]" or "image[3.7,2.5;1,1;industrialtest_gui_electricity_bg.png]"), "list[context;src;5.9,3.2;1,1;0]", industrialtest.internal.getItemSlotBg(5.9,3.2,1,1), - "listring[context;src]", "list[context;upgrades;9,0.9;1,4]", industrialtest.internal.getItemSlotBg(9,0.9,1,4), - "listring[context;upgrades]" + "listring[context;src]" } return table.concat(formspec,"") end diff --git a/machines/wind_mill.lua b/machines/wind_mill.lua index 3e82505..056d22f 100644 --- a/machines/wind_mill.lua +++ b/machines/wind_mill.lua @@ -23,9 +23,9 @@ windMill.getFormspec=function(pos) local formspec={ "list[context;charged;4.7,1.8;1,1]", industrialtest.internal.getItemSlotBg(4.7,1.8,1,1), - "listring[context;charged]", (charging>0 and "image[4.7,3;1,1;industrialtest_gui_wind_bg.png^[lowpart:"..charging..":industrialtest_gui_wind_fg.png]" - or "image[4.7,3;1,1;industrialtest_gui_wind_bg.png]") + or "image[4.7,3;1,1;industrialtest_gui_wind_bg.png]"), + "listring[context;charged]" } return table.concat(formspec,"") end