From 2669b7bc27f2b793ef45c58c073f4f593ff25b2f Mon Sep 17 00:00:00 2001 From: mrkubax10 Date: Fri, 10 May 2024 19:10:16 +0200 Subject: [PATCH] Normalize machine source and destination inventory list names --- machines/canning_machine.lua | 58 ++++++++++++++++++------------------ machines/fluid_generator.lua | 38 +++++++++++------------ machines/generator.lua | 20 ++++++------- machines/tool_workshop.lua | 20 ++++++------- 4 files changed, 68 insertions(+), 68 deletions(-) diff --git a/machines/canning_machine.lua b/machines/canning_machine.lua index 93a3a6c..7190237 100644 --- a/machines/canning_machine.lua +++ b/machines/canning_machine.lua @@ -27,24 +27,24 @@ canningMachine.getFormspec=function(pos) local formspec if industrialtest.mtgAvailable then formspec={ - "list[context;fuel;3.4,1.8;1,1]", + "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;target;6.4,1.8;1,1]", + "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;fuel]", + "listring[context;src]", "listring[context;powerStorage]", - "listring[context;target]", + "listring[context;dst]", "listring[context;leftover]", "listring[context;upgrades]" } elseif industrialtest.mclAvailable then formspec={ - "list[context;fuel;3.4,1.8;1,1]", + "list[context;src;3.4,1.8;1,1]", mcl_formspec.get_itemslot_bg(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]"), @@ -52,15 +52,15 @@ canningMachine.getFormspec=function(pos) mcl_formspec.get_itemslot_bg(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;target;6.4,1.8;1,1]", + "list[context;dst;6.4,1.8;1,1]", mcl_formspec.get_itemslot_bg(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), "list[context;upgrades;9,0.9;1,4]", mcl_formspec.get_itemslot_bg(9,0.9,1,4), - "listring[context;fuel]", + "listring[context;src]", "listring[context;powerStorage]", - "listring[context;target]", + "listring[context;dst]", "listring[context;upgrades]" } end @@ -68,8 +68,8 @@ canningMachine.getFormspec=function(pos) end canningMachine.onConstruct=function(pos,meta,inv) - inv:set_size("fuel",1) - inv:set_size("target",1) + inv:set_size("src",1) + inv:set_size("dst",1) inv:set_size("leftover",1) inv:set_size("powerStorage",1) inv:set_size("upgrades",4) @@ -79,8 +79,8 @@ end canningMachine.onTimer=function(pos,elapsed,meta,inv) local shouldRerunTimer=false local shouldUpdateFormspec=false - local fuelSlot=inv:get_stack("fuel",1) - local targetSlot=inv:get_stack("target",1) + local fuelSlot=inv:get_stack("src",1) + local targetSlot=inv:get_stack("dst",1) local leftoverSlot=inv:get_stack("leftover",1) local powerStorageSlot=inv:get_stack("powerStorage",1) local targetMeta=targetSlot:get_meta() @@ -102,13 +102,13 @@ canningMachine.onTimer=function(pos,elapsed,meta,inv) end canningMachine.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList,count) - if toList=="fuel" then + if toList=="src" then local inv=minetest.get_meta(pos):get_inventory() local itemstack=inv:get_stack(fromList,fromIndex) local def=itemstack:get_definition() return (def.groups and def.groups._industrialtest_fuel) and count or 0 end - if toList=="target" then + if toList=="dst" then local inv=minetest.get_meta(pos):get_inventory() local itemstack=inv:get_stack(fromList,fromIndex) local def=itemstack:get_definition() @@ -118,11 +118,11 @@ canningMachine.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList end canningMachine.allowMetadataInventoryPut=function(pos,listname,index,stack) - if listname=="fuel" then + if listname=="src" then local def=stack:get_definition() return (def.groups and def.groups._industrialtest_fuel) and stack:get_count() or 0 end - if listname=="target" then + if listname=="dst" then local def=stack:get_definition() return (def.groups and def.groups._industrialtest_fueled) and stack:get_count() or 0 end @@ -132,9 +132,9 @@ end canningMachine.allowMetadataInventoryTake=function(pos,listname,index,stack) local meta=minetest.get_meta(pos) local inv=meta:get_inventory() - local fuelSlot=inv:get_stack("fuel",1) - local targetSlot=inv:get_stack("target",1) - if ((listname=="fuel" and stack:get_count()==fuelSlot:get_count()) or (listname=="target" and stack:get_count()==targetSlot:get_count())) and meta:get_float("srcTime")>0 then + local fuelSlot=inv:get_stack("src",1) + local targetSlot=inv:get_stack("dst",1) + if ((listname=="src" and stack:get_count()==fuelSlot:get_count()) or (listname=="dst" and stack:get_count()==targetSlot:get_count())) and meta:get_float("srcTime")>0 then meta:set_float("srcTime",0) minetest.get_node_timer(pos):start(industrialtest.updateDelay) end @@ -148,9 +148,9 @@ end canningMachine.onMetadataInventoryMove=function(pos,fromList,fromIndex,toList,toIndex,count) local meta=minetest.get_meta(pos) local inv=meta:get_inventory() - local fuelSlot=inv:get_stack("fuel",1) - local targetSlot=inv:get_stack("target",1) - if ((fromList=="fuel" and count==fuelSlot:get_count()) or (fromList=="target" and count==targetSlot:get_count())) and meta:get_float("srcTime")>0 then + local fuelSlot=inv:get_stack("src",1) + local targetSlot=inv:get_stack("dst",1) + if ((fromList=="src" and count==fuelSlot:get_count()) or (fromList=="dst" and count==targetSlot:get_count())) and meta:get_float("srcTime")>0 then meta:set_float("srcTime",0) meta:set_string("formspec",canningMachine.getFormspec(pos)) end @@ -158,8 +158,8 @@ end canningMachine.activeOnTimer=function(pos,elapsed,meta,inv) local shouldUpdateFormspec=false - local fuelSlot=inv:get_stack("fuel",1) - local targetSlot=inv:get_stack("target",1) + local fuelSlot=inv:get_stack("src",1) + local targetSlot=inv:get_stack("dst",1) local powerStorageSlot=inv:get_stack("powerStorage",1) shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv) @@ -193,8 +193,8 @@ canningMachine.activeOnTimer=function(pos,elapsed,meta,inv) if srcTime>=canningMachine.canningTime then if industrialtest.api.itemHasFluidStorage(fuelSlot) then industrialtest.api.transferFluidToItem(fuelSlot,targetSlot,fuelMeta:get_int("industrialtest.fluidAmount")) - inv:set_stack("fuel",1,fuelSlot) - inv:set_stack("target",1,targetSlot) + inv:set_stack("src",1,fuelSlot) + inv:set_stack("dst",1,targetSlot) else local def=fuelSlot:get_definition() local leftoverSlot=inv:get_stack("leftover",1) @@ -207,9 +207,9 @@ canningMachine.activeOnTimer=function(pos,elapsed,meta,inv) return false,shouldUpdateFormspec end industrialtest.api.addFluidToItem(targetSlot,def._industrialtest_fuelAmount) - inv:set_stack("target",1,targetSlot) + inv:set_stack("dst",1,targetSlot) fuelSlot:take_item(1) - inv:set_stack("fuel",1,fuelSlot) + inv:set_stack("src",1,fuelSlot) leftoverSlot:add_item(ItemStack(def._industrialtest_emptyVariant)) inv:set_stack("leftover",1,leftoverSlot) end @@ -233,7 +233,7 @@ industrialtest.internal.registerMachine({ registerActiveVariant=true, sounds="metal", powerSlots={"powerStorage"}, - storageSlots={"fuel","target","powerStorage","upgrades"}, + storageSlots={"src","dst","powerStorage","upgrades"}, groups={ _industrialtest_hasPowerInput=1 }, diff --git a/machines/fluid_generator.lua b/machines/fluid_generator.lua index 712714a..d3c8b51 100644 --- a/machines/fluid_generator.lua +++ b/machines/fluid_generator.lua @@ -27,11 +27,11 @@ fluidGenerator.getFormspec=function(pos,config) local tile=(fuel and fuel.texture or "industrialtest_gui_fluid_bg.png") if industrialtest.mtgAvailable then formspec={ - "list[context;fluid;2,1.8;1,1]", - "listring[context;fluid]", + "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;leftover;2,4.2;1,1]", - "listring[context;leftover]", + "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]", @@ -39,13 +39,13 @@ fluidGenerator.getFormspec=function(pos,config) } elseif industrialtest.mclAvailable then formspec={ - "list[context;fluid;2,1.8;1,1]", + "list[context;src;2,1.8;1,1]", mcl_formspec.get_itemslot_bg(2,1.8,1,1), - "listring[context;fluid]", + "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;leftover;2,4.2;1,1]", + "list[context;dst;2,4.2;1,1]", mcl_formspec.get_itemslot_bg(2,4.2,1,1), - "listring[context;leftover]", + "listring[context;dst]", "list[context;charged;6,3;1,1]", mcl_formspec.get_itemslot_bg(6,3,1,1), "listring[context;charged]", @@ -58,14 +58,14 @@ end fluidGenerator.onConstruct=function(pos,meta,inv) inv:set_size("charged",1) - inv:set_size("fluid",1) - inv:set_size("leftover",1) + inv:set_size("src",1) + inv:set_size("dst",1) meta:set_float("fluidAmount",0) meta:set_string("fluid","") end fluidGenerator.onTimer=function(pos,elapsed,meta,inv,config) - local fluidSlot=inv:get_stack("fluid",1) + local fluidSlot=inv:get_stack("src",1) local chargedSlot=inv:get_stack("charged",1) local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos) local shouldUpdateFormspec=false @@ -77,8 +77,8 @@ fluidGenerator.onTimer=function(pos,elapsed,meta,inv,config) local leftoverAddingSucceeded=false for _,item in ipairs(fuel.storageItems) do if item.name==fluidSlot:get_name() and item.leftover then - if inv:room_for_item("leftover",ItemStack(item.leftover)) then - inv:add_item("leftover",ItemStack(item.leftover)) + if inv:room_for_item("dst",ItemStack(item.leftover)) then + inv:add_item("dst",ItemStack(item.leftover)) leftoverAddingSucceeded=true end leftover=true @@ -86,7 +86,7 @@ fluidGenerator.onTimer=function(pos,elapsed,meta,inv,config) end if not leftover or leftoverAddingSucceeded then fluidSlot:take_item() - inv:set_stack("fluid",1,fluidSlot) + inv:set_stack("src",1,fluidSlot) meta:set_string("fluid",fuel.name) meta:set_float("fluidAmount",meta:get_float("fluidAmount")+1000) shouldUpdateFormspec=true @@ -127,7 +127,7 @@ fluidGenerator.metadataChange=function(pos) end fluidGenerator.activeOnTimer=function(pos,elapsed,meta,inv,config) - local fluidSlot=inv:get_stack("fluid",1) + local fluidSlot=inv:get_stack("src",1) local chargedSlot=inv:get_stack("charged",1) local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos) local shouldUpdateFormspec=false @@ -140,8 +140,8 @@ fluidGenerator.activeOnTimer=function(pos,elapsed,meta,inv,config) local leftoverAddingSucceeded=false for _,item in ipairs(fuel.storageItems) do if item.name==fluidSlot:get_name() and item.leftover then - if inv:room_for_item("leftover",ItemStack(item.leftover)) then - inv:add_item("leftover",ItemStack(item.leftover)) + if inv:room_for_item("dst",ItemStack(item.leftover)) then + inv:add_item("dst",ItemStack(item.leftover)) leftoverAddingSucceeded=true end leftover=true @@ -149,7 +149,7 @@ fluidGenerator.activeOnTimer=function(pos,elapsed,meta,inv,config) end if not leftover or leftoverAddingSucceeded then fluidSlot:take_item() - inv:set_stack("fluid",1,fluidSlot) + inv:set_stack("src",1,fluidSlot) meta:set_string("fluid",fuel.name) meta:set_float("fluidAmount",meta:get_float("fluidAmount")+1000) shouldUpdateFormspec=true @@ -196,7 +196,7 @@ local function registerFluidGenerator(config) requiresWrench=true, registerActiveVariant=config.registerActiveVariant, powerSlots={"charged"}, - storageSlots={"fluid","fluidLeftover"}, + storageSlots={"src","dst"}, sounds="metal", groups={ _industrialtest_hasPowerOutput=1 diff --git a/machines/generator.lua b/machines/generator.lua index 5cdc291..a14f12e 100644 --- a/machines/generator.lua +++ b/machines/generator.lua @@ -28,8 +28,8 @@ generator.getFormspec=function(pos) "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;fuel;4.9,3.9;1,1]", - "listring[context;fuel]", + "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 "") } @@ -40,9 +40,9 @@ generator.getFormspec=function(pos) "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;fuel;4.7,3.9;1,1]", + "list[context;src;4.7,3.9;1,1]", mcl_formspec.get_itemslot_bg(4.7,3.9,1,1), - "listring[context;fuel]", + "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 "") } @@ -52,7 +52,7 @@ end generator.onConstruct=function(pos,meta,inv) inv:set_size("charged",1) - inv:set_size("fuel",1) + inv:set_size("src",1) meta:set_int("fuelTime",0) meta:set_int("maxFuelTime",1) end @@ -60,7 +60,7 @@ end generator.onTimer=function(pos,elapsed,meta,inv) local powerFlow=meta:get_int("industrialtest.powerFlow") local chargedSlot=inv:get_stack("charged",1) - local fuelSlot=inv:get_stack("fuel",1) + local fuelSlot=inv:get_stack("src",1) local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos) local shouldUpdateFormspec=flowTransferred local shouldRerunTimer=(afterFlow and meta:get_int("industrialtest.powerAmount")>0) @@ -79,7 +79,7 @@ generator.onTimer=function(pos,elapsed,meta,inv) if output.time>0 then meta:set_int("fuelTime",output.time) meta:set_int("maxFuelTime",output.time) - inv:set_stack("fuel",1,after.items[1]) + inv:set_stack("src",1,after.items[1]) minetest.swap_node(pos,{ name="industrialtest:generator_active", param2=minetest.get_node(pos).param2 @@ -92,7 +92,7 @@ end generator.activeOnTimer=function(pos,elapsed,meta,inv) local chargedSlot=inv:get_stack("charged",1) - local fuelSlot=inv:get_stack("fuel",1) + local fuelSlot=inv:get_stack("src",1) local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos) local shouldUpdateFormspec=flowTransferred local shouldRerunTimer=(afterFlow and meta:get_int("industrialtest.powerAmount")>0) @@ -111,7 +111,7 @@ generator.activeOnTimer=function(pos,elapsed,meta,inv) if output.time>0 then meta:set_int("fuelTime",output.time) meta:set_int("maxFuelTime",output.time) - inv:set_stack("fuel",1,after.items[1]) + inv:set_stack("src",1,after.items[1]) end end if meta:get_int("fuelTime")>0 then @@ -141,7 +141,7 @@ industrialtest.internal.registerMachine({ ioConfig="oooooo", registerActiveVariant=true, powerSlots={"charged"}, - storageSlots={"charged","fuel"}, + storageSlots={"charged","src"}, sounds="metal", groups={ _industrialtest_hasPowerOutput=1 diff --git a/machines/tool_workshop.lua b/machines/tool_workshop.lua index 8882155..99109fc 100644 --- a/machines/tool_workshop.lua +++ b/machines/tool_workshop.lua @@ -27,8 +27,8 @@ toolWorkshop.getFormspec=function(pos) "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;tool;5.9,3.2;1,1;0]", - "listring[context;tool]", + "list[context;src;5.9,3.2;1,1;0]", + "listring[context;src]", "list[context;upgrades;9,0.9;1,4]", "listring[context;upgrades]" } @@ -39,9 +39,9 @@ toolWorkshop.getFormspec=function(pos) "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;tool;5.9,3.2;1,1;0]", + "list[context;src;5.9,3.2;1,1;0]", mcl_formspec.get_itemslot_bg(5.9,3.2,1,1), - "listring[context;tool]", + "listring[context;src]", "list[context;upgrades;9,0.9;1,4]", mcl_formspec.get_itemslot_bg(9,0.9,1,4), "listring[context;upgrades]" @@ -52,13 +52,13 @@ end toolWorkshop.onConstruct=function(pos,meta,inv) inv:set_size("powerStorage",1) - inv:set_size("tool",1) + inv:set_size("src",1) inv:set_size("upgrades",4) end toolWorkshop.onTimer=function(pos,elapsed,meta,inv) local powerStorageSlot=inv:get_stack("powerStorage",1) - local toolSlot=inv:get_stack("tool",1) + local toolSlot=inv:get_stack("src",1) local requiredPower=industrialtest.api.getMachineSpeed(meta)*10000 local shouldRerunTimer=false local shouldUpdateFormspec=false @@ -86,7 +86,7 @@ end toolWorkshop.activeOnTimer=function(pos,elapsed,meta,inv) local powerStorageSlot=inv:get_stack("powerStorage",1) - local toolSlot=inv:get_stack("tool",1) + local toolSlot=inv:get_stack("src",1) local speed=industrialtest.api.getMachineSpeed(meta) local requiredPower=speed*10000 local shouldRerunTimer=false @@ -105,7 +105,7 @@ toolWorkshop.activeOnTimer=function(pos,elapsed,meta,inv) if toolSlot:get_count()>0 and toolSlot:get_wear()>0 and meta:get_int("industrialtest.powerAmount")>=requiredPower then local removed=math.min(toolSlot:get_wear(),speed*200) toolSlot:set_wear(toolSlot:get_wear()-removed) - inv:set_stack("tool",1,toolSlot) + inv:set_stack("src",1,toolSlot) industrialtest.api.addPower(meta,-requiredPower) shouldRerunTimer=true shouldUpdateFormspec=true @@ -128,7 +128,7 @@ local function isTool(stack) end toolWorkshop.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList,toIndex,count) - if toList=="tool" then + if toList=="src" then local meta=minetest.get_meta(pos) local inv=meta:get_inventory() local movedItemStack=inv:get_stack(fromList,fromIndex) @@ -160,7 +160,7 @@ industrialtest.internal.registerMachine({ requiresWrench=true, registerActiveVariant=true, powerSlots={"powerStorage"}, - storageSlots={"tool"}, + storageSlots={"src"}, sounds="metal", groups={ _industrialtest_hasPowerInput=1