2 Commits

Author SHA1 Message Date
10b415b735 feat: mcl hopper compat for common machines 2024-05-10 11:29:04 +03:00
36b792bd2a fix: iron furnace was unbreakable 2024-05-10 11:29:04 +03:00
47 changed files with 529 additions and 393 deletions

View File

@@ -19,6 +19,5 @@ Currently IndustrialTest supports following games:
## Contributors
- mrkubax10 <mrkubax10@onet.pl or mrkubax10 at irc.libera.chat> [programming, some graphics]
- HandfulOfFrogs <<handfuloffrogs@gmail.com>> [some programming, graphics]
- LuanHawk <Discord: LuanHawk#8733> [lead graphics]
- Migdyn <<temp1@cubesoftware.xyz>> [graphics]

View File

@@ -672,7 +672,6 @@ industrialtest.api.registerPlate=function(name,displayName,resources,color,regis
minetest.register_craftitem("industrialtest:"..name,{
description=displayName,
inventory_image="industrialtest_plate.png",
inventory_overlay="industrialtest_plate_overlay.png",
color=color
})
if registerCompressorRecipe then
@@ -689,16 +688,13 @@ end
-- \param displayName Display name of cell
-- \param node Node which can be picked up with this cell
-- \returns nil
industrialtest.api.registerStorageCell=function(name,displayName,node,modname,color)
color = color or "#ffffffff"
industrialtest.api.registerStorageCell=function(name,displayName,node,modname)
if not modname then
modname="industrialtest"
end
minetest.register_craftitem("industrialtest:"..name.."_cell",{
description=S(displayName.." Cell"),
inventory_image="industrialtest_cell_fluid.png",
inventory_overlay="industrialtest_cell_casing.png",
color=color,
inventory_image=modname.."_"..name.."_cell.png",
on_place=function(itemstack,user,pointed)
if pointed.type~="node" or not user or not user:is_player() then
return nil

View File

@@ -33,6 +33,12 @@ 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")
@@ -47,11 +53,10 @@ 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
@@ -80,22 +85,9 @@ 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
@@ -202,7 +194,7 @@ if industrialtest.mclAvailable then
minetest.register_tool("industrialtest:"..material.."_pickaxe",{
description=S(materialDisplayName.." Pickaxe"),
inventory_image="industrialtest_mcl_"..material.."_pickaxe.png",
groups={tool=1,pickaxe=1,dig_speed_class=config.digSpeedClass,enchantability=config.enchantability},
groups={tool=1,pickaxe=1,dig_speed_class=config.digSpeedClass},
tool_capabilities={
full_punch_interval=1,
max_drop_level=config.dropLevel,
@@ -218,7 +210,7 @@ if industrialtest.mclAvailable then
minetest.register_tool("industrialtest:"..material.."_shovel",{
description=S(materialDisplayName.." Shovel"),
inventory_image="industrialtest_mcl_"..material.."_shovel.png",
groups={tool=1,shovel=1,dig_speed_class=config.digSpeedClass,enchantability=config.enchantability},
groups={tool=1,shovel=1,dig_speed_class=config.digSpeedClass},
tool_capabilities={
full_punch_interval=1,
max_drop_level=config.dropLevel,
@@ -270,7 +262,7 @@ if industrialtest.mclAvailable then
minetest.register_tool("industrialtest:"..material.."_axe",{
description=S(materialDisplayName.." Axe"),
inventory_image="industrialtest_mcl_"..material.."_axe.png",
groups={tool=1,axe=1,dig_speed_class=config.digSpeedClass,enchantability=config.enchantability},
groups={tool=1,axe=1,dig_speed_class=config.digSpeedClass},
tool_capabilities={
full_punch_interval=1,
max_level_drop=config.levelDrop,
@@ -287,7 +279,7 @@ if industrialtest.mclAvailable then
minetest.register_tool("industrialtest:"..material.."_sword",{
description=S(materialDisplayName.." Sword"),
inventory_image="industrialtest_mcl_"..material.."_sword.png",
groups={weapon=1,sword=1,dig_speed_class=config.digSpeedClass,enchantability=config.enchantability},
groups={weapon=1,sword=1,dig_speed_class=config.digSpeedClass},
tool_capabilities={
full_punch_interval=0.625,
max_drop_level=config.maxDropLevel,
@@ -304,7 +296,7 @@ if industrialtest.mclAvailable then
minetest.register_tool("industrialtest:"..material.."_hoe",{
description=S(materialDisplayName.." Hoe"),
inventory_image="industrialtest_mcl_"..material.."_hoe.png",
groups={tool=1,hoe=1,enchantability=config.enchantability},
groups={tool=1,hoe=1},
tool_capabilities={
full_punch_interval=1,
damage_groups={fleshy=1}
@@ -372,7 +364,6 @@ if industrialtest.mclAvailable then
cook_material=config.armorCookMaterial,
sound_equip=config.armorEquipSound,
sound_unequip=config.armorUnequipSound,
enchantability=config.enchantability,
textures={
head="industrialtest_mcl_"..material.."_helmet.png",
torso="industrialtest_mcl_"..material.."_chestplate.png",
@@ -576,8 +567,7 @@ if industrialtest.mclAvailable then
},
armorCookMaterial="industrialtest:bronze_nugget",
armorEquipSound="mcl_armor_equip_iron",
armorUnequipSound="mcl_armor_unequip_iron",
enchantability=15,
armorUnequipSound="mcl_armor_unequip_iron"
})
--register other blocks that are not availabe in MCL
@@ -621,6 +611,10 @@ 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"),

View File

@@ -15,31 +15,6 @@
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
local S=minetest.get_translator("industrialtest")
local colors={
bronze="#be4325ff",
clay="#707070ff",
coal="#262523ff",
copper="#bf644aff",
diamond="#77cefbff",
gold="#eac162ff",
iron="#afaca5ff",
lapis_lazuli="#3a4cceff",
lead="#6d6393ff",
mese="#909000ff",
obsidian="#292843ff",
refined_iron="#94bab9ff",
sulfur="#b88805ff",
tin="#ebd182ff",
uranium="#3b8c09ff",
-- fluid colors
lava="#ff5712ff",
water="#277bbcff",
river_water="#0ebfc2ff",
biomass="#2a8626ff",
biofuel="#4eba49ff",
coalfuel="#462228ff",
coolant="#188676ff"
}
-- Power storage items
minetest.register_tool("industrialtest:re_battery",{
@@ -222,13 +197,13 @@ if industrialtest.mclAvailable then
count=2
})
end
industrialtest.api.registerResourceDust("coal","Coal",resources,colors.coal,true)
industrialtest.api.registerResourceDust("coal","Coal",resources,"#101010ff",true)
industrialtest.api.registerResourceDust("clay","Clay",{
{
resource=industrialtest.elementKeys.clayBlock,
count=2
}
},colors.clay,true)
},"#9090a0ff",true)
resources={
{
resource=industrialtest.elementKeys.diamondBlock,
@@ -246,7 +221,7 @@ if industrialtest.mclAvailable then
count=2
})
end
industrialtest.api.registerResourceDust("diamond","Diamond",resources,colors.diamond,true)
industrialtest.api.registerResourceDust("diamond","Diamond",resources,"#90e2c9ff",true)
minetest.register_craft({
type="cooking",
output=industrialtest.elementKeys.diamond,
@@ -273,7 +248,7 @@ if industrialtest.mclAvailable then
count=2
})
end
industrialtest.api.registerResourceDust("iron","Iron",resources,colors.iron,true)
industrialtest.api.registerResourceDust("iron","Iron",resources,"#b5b5b5ff",true)
minetest.register_craft({
type="cooking",
output=industrialtest.elementKeys.ironIngot,
@@ -294,9 +269,9 @@ if industrialtest.mclAvailable then
count=9
},
{resource="mcl_core:lapis_lazuli"}
},colors.lapis_lazuli,true)
},"#292d76ff",true)
end
industrialtest.api.registerResourceDust("obsidian","Obsidian",{{resource=industrialtest.elementKeys.obsidian}},colors.obsidian,true)
industrialtest.api.registerResourceDust("obsidian","Obsidian",{{resource=industrialtest.elementKeys.obsidian}},"#292843ff",true)
resources={
{
resource=industrialtest.elementKeys.goldBlock,
@@ -318,7 +293,7 @@ if industrialtest.mclAvailable then
count=2
})
end
industrialtest.api.registerResourceDust("gold","Gold",resources,colors.gold,true)
industrialtest.api.registerResourceDust("gold","Gold",resources,"#e4e526ff",true)
minetest.register_craft({
type="cooking",
output=industrialtest.elementKeys.goldIngot,
@@ -345,7 +320,7 @@ if industrialtest.mclAvailable then
count=2
})
end
industrialtest.api.registerResourceDust("copper","Copper",resources,colors.copper,true)
industrialtest.api.registerResourceDust("copper","Copper",resources,"#a45e25ff",true)
minetest.register_craft({
type="cooking",
output=industrialtest.elementKeys.copperIngot,
@@ -372,7 +347,7 @@ if industrialtest.mclAvailable then
count=2
})
end
industrialtest.api.registerResourceDust("tin","Tin",resources,colors.tin,true)
industrialtest.api.registerResourceDust("tin","Tin",resources,"#f1f1f1ff",true)
minetest.register_craft({
type="cooking",
output=industrialtest.elementKeys.tinIngot,
@@ -399,7 +374,7 @@ if industrialtest.mclAvailable then
count=2
})
end
industrialtest.api.registerResourceDust("uranium","Uranium",resources,colors.uranium,true)
industrialtest.api.registerResourceDust("uranium","Uranium",resources,"#3b8c09ff",true)
minetest.register_craft({
type="cooking",
output="industrialtest:uranium_ingot",
@@ -416,7 +391,7 @@ if industrialtest.mtgAvailable then
count=2
},
{resource="default:mese_crystal"}
},colors.mese,true)
},"#909000ff",true)
minetest.register_craft({
type="cooking",
output="default:mese_crystal",
@@ -429,7 +404,7 @@ industrialtest.api.registerResourceDust("bronze","Bronze",{
count=9
},
{resource=industrialtest.elementKeys.bronzeIngot}
},colors.bronze,true)
},"#e48e88ff",true)
minetest.register_craft({
type="shaped",
output="industrialtest:bronze_dust 9",
@@ -456,7 +431,7 @@ industrialtest.api.registerRotaryMaceratorModifier({
output="industrialtest:bronze_dust",
uses=4
})
industrialtest.api.registerResourceDust("sulfur","Sulfur",{},colors.sulfur,false)
industrialtest.api.registerResourceDust("sulfur","Sulfur",{},"#e3ff33ff",false)
industrialtest.api.registerExtractorRecipe({
output="industrialtest:sulfur_dust",
recipe=industrialtest.elementKeys.gunpowder
@@ -475,7 +450,7 @@ industrialtest.api.registerResourceDust("lead","Lead",{
count=2
},
{resource="industrialtest:lead_ingot"}
},colors.lead,true)
},"#eafef8ff",true)
minetest.register_craft({
type="cooking",
output="industrialtest:lead_ingot",
@@ -486,7 +461,7 @@ industrialtest.api.registerResourceDust("refined_iron","Refined Iron",{
resource="industrialtest:refined_iron_ingot",
count=1
}
},colors.refined_iron,true)
},"#7c8588ff",true)
industrialtest.api.registerRotaryMaceratorModifier({
name=industrialtest.elementKeys.ironLump,
modifier=industrialtest.elementKeys.coal,
@@ -549,14 +524,14 @@ industrialtest.api.registerPlate("bronze_plate",S("Bronze Plate"),{
resource=industrialtest.elementKeys.bronzeIngot,
count=1
}
},colors.bronze,true)
},"#e48e88ff",true)
industrialtest.api.registerPlate("copper_plate",S("Copper Plate"),{
{
resource=industrialtest.elementKeys.copperIngot,
count=1
}
},colors.copper,true)
},"#f48e44ff",true)
industrialtest.api.registerPlate("advanced_alloy",S("Advanced Alloy"),{
{
@@ -577,14 +552,14 @@ industrialtest.api.registerPlate("tin_plate",S("Tin Plate"),{
resource=industrialtest.elementKeys.tinIngot,
count=1
}
},colors.tin,true)
},"#e0e0e0ff",true)
industrialtest.api.registerPlate("lead_plate",S("Lead Plate"),{
{
resource="industrialtest:lead_ingot",
count=1
}
},colors.lead,true)
},"#eafef8ff",true)
industrialtest.api.registerPlate("iridium_plate",S("Iridium Plate"),{},false,"#ffffffff")
minetest.register_craft({
@@ -634,12 +609,12 @@ minetest.register_craft({
{"",industrialtest.elementKeys.tinIngot,""}
}
})
industrialtest.api.registerStorageCell("water","Water",industrialtest.elementKeys.waterSource,nil,colors.water)
industrialtest.api.registerStorageCell("water","Water",industrialtest.elementKeys.waterSource)
if industrialtest.mtgAvailable then
industrialtest.api.registerStorageCell("river_water","River Water","default:river_water_source",nil,colors.river_water)
industrialtest.api.registerStorageCell("river_water","River Water","default:river_water_source")
end
industrialtest.api.registerStorageCell("lava","Lava",industrialtest.elementKeys.lavaSource,nil,colors.lava)
industrialtest.api.registerStorageCell("lava","Lava",industrialtest.elementKeys.lavaSource)
minetest.register_tool("industrialtest:uranium_cell",{
description=S("Uranium Cell"),
@@ -647,9 +622,7 @@ minetest.register_tool("industrialtest:uranium_cell",{
_industrialtest_placedInNuclearReactor=1,
_industrialtest_nuclearReactorFuel=1
},
inventory_image="industrialtest_cell_fluid.png",
inventory_overlay="industrialtest_cell_casing.png",
color=colors.uranium,
inventory_image="industrialtest_uranium_cell.png",
})
minetest.register_craft({
type="shapeless",
@@ -666,9 +639,7 @@ minetest.register_tool("industrialtest:coolant_cell",{
_industrialtest_placedInNuclearReactor=1,
_industrialtest_nuclearReactorCoolant=1
},
inventory_image="industrialtest_cell_fluid.png",
inventory_overlay="industrialtest_cell_casing.png",
color=colors.coolant,
inventory_image="industrialtest_coolant_cell.png",
})
minetest.register_craft({
type="shaped",
@@ -693,9 +664,7 @@ end
minetest.register_craftitem("industrialtest:bio_cell",{
description=S("Bio Cell"),
inventory_image="industrialtest_cell_fluid.png",
inventory_overlay="industrialtest_cell_casing.png",
color=colors.biomass,
inventory_image="industrialtest_bio_cell.png"
})
minetest.register_craft({
type="shapeless",
@@ -708,9 +677,7 @@ minetest.register_craft({
minetest.register_craftitem("industrialtest:biofuel_cell",{
description=S("Biofuel Cell"),
inventory_image="industrialtest_cell_fluid.png",
inventory_overlay="industrialtest_cell_casing.png",
color=colors.biofuel,
inventory_image="industrialtest_bio_cell.png",
groups={
_industrialtest_fuel=1
},
@@ -725,9 +692,7 @@ industrialtest.api.registerExtractorRecipe({
minetest.register_craftitem("industrialtest:hydrated_coal_cell",{
description=S("Hydrated Coal Cell"),
inventory_image="industrialtest_cell_fluid.png",
inventory_overlay="industrialtest_cell_casing.png",
color=colors.coal,
inventory_image="industrialtest_hydrated_coal_cell.png"
})
minetest.register_craft({
type="shapeless",
@@ -740,9 +705,7 @@ minetest.register_craft({
minetest.register_craftitem("industrialtest:coalfuel_cell",{
description=S("Coalfuel Cell"),
inventory_image="industrialtest_cell_fluid.png",
inventory_overlay="industrialtest_cell_casing.png",
color=colors.coalfuel,
inventory_image="industrialtest_coalfuel_cell.png",
groups={
_industrialtest_fuel=1
},

View File

@@ -24,30 +24,52 @@ 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={
"list[context;src;3.4,1.8;1,1]",
industrialtest.internal.getItemSlotBg(3.4,1.8,1,1),
local formspec
if industrialtest.mtgAvailable then
formspec={
"list[context;fuel;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;leftover;6.4,2.8;1,1]",
"list[context;upgrades;9,0.9;1,4]",
"listring[context;fuel]",
"listring[context;powerStorage]",
"listring[context;target]",
"listring[context;leftover]",
"listring[context;upgrades]"
}
elseif industrialtest.mclAvailable then
formspec={
"list[context;fuel;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]"),
"list[context;powerStorage;3.4,3.9;1,1]",
industrialtest.internal.getItemSlotBg(3.4,3.9,1,1),
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;dst;6.4,1.8;1,1]",
industrialtest.internal.getItemSlotBg(6.4,1.8,1,1),
"list[context;target;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]",
industrialtest.internal.getItemSlotBg(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]",
industrialtest.internal.getItemSlotBg(9,0.9,1,4),
"listring[context;src]",
"listring[context;dst]"
}
mcl_formspec.get_itemslot_bg(9,0.9,1,4),
"listring[context;fuel]",
"listring[context;powerStorage]",
"listring[context;target]",
"listring[context;upgrades]"
}
end
return table.concat(formspec,"")
end
canningMachine.onConstruct=function(pos,meta,inv)
inv:set_size("src",1)
inv:set_size("dst",1)
inv:set_size("fuel",1)
inv:set_size("target",1)
inv:set_size("leftover",1)
inv:set_size("powerStorage",1)
inv:set_size("upgrades",4)
@@ -57,8 +79,8 @@ end
canningMachine.onTimer=function(pos,elapsed,meta,inv)
local shouldRerunTimer=false
local shouldUpdateFormspec=false
local fuelSlot=inv:get_stack("src",1)
local targetSlot=inv:get_stack("dst",1)
local fuelSlot=inv:get_stack("fuel",1)
local targetSlot=inv:get_stack("target",1)
local leftoverSlot=inv:get_stack("leftover",1)
local powerStorageSlot=inv:get_stack("powerStorage",1)
local targetMeta=targetSlot:get_meta()
@@ -80,13 +102,13 @@ canningMachine.onTimer=function(pos,elapsed,meta,inv)
end
canningMachine.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList,count)
if toList=="src" then
if toList=="fuel" 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=="dst" then
if toList=="target" then
local inv=minetest.get_meta(pos):get_inventory()
local itemstack=inv:get_stack(fromList,fromIndex)
local def=itemstack:get_definition()
@@ -96,11 +118,11 @@ canningMachine.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList
end
canningMachine.allowMetadataInventoryPut=function(pos,listname,index,stack)
if listname=="src" then
if listname=="fuel" then
local def=stack:get_definition()
return (def.groups and def.groups._industrialtest_fuel) and stack:get_count() or 0
end
if listname=="dst" then
if listname=="target" then
local def=stack:get_definition()
return (def.groups and def.groups._industrialtest_fueled) and stack:get_count() or 0
end
@@ -110,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("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
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
meta:set_float("srcTime",0)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
@@ -126,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("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
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
meta:set_float("srcTime",0)
meta:set_string("formspec",canningMachine.getFormspec(pos))
end
@@ -136,8 +158,8 @@ end
canningMachine.activeOnTimer=function(pos,elapsed,meta,inv)
local shouldUpdateFormspec=false
local fuelSlot=inv:get_stack("src",1)
local targetSlot=inv:get_stack("dst",1)
local fuelSlot=inv:get_stack("fuel",1)
local targetSlot=inv:get_stack("target",1)
local powerStorageSlot=inv:get_stack("powerStorage",1)
shouldRerunTimer,shouldUpdateFormspec=industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
@@ -171,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("src",1,fuelSlot)
inv:set_stack("dst",1,targetSlot)
inv:set_stack("fuel",1,fuelSlot)
inv:set_stack("target",1,targetSlot)
else
local def=fuelSlot:get_definition()
local leftoverSlot=inv:get_stack("leftover",1)
@@ -185,9 +207,9 @@ canningMachine.activeOnTimer=function(pos,elapsed,meta,inv)
return false,shouldUpdateFormspec
end
industrialtest.api.addFluidToItem(targetSlot,def._industrialtest_fuelAmount)
inv:set_stack("dst",1,targetSlot)
inv:set_stack("target",1,targetSlot)
fuelSlot:take_item(1)
inv:set_stack("src",1,fuelSlot)
inv:set_stack("fuel",1,fuelSlot)
leftoverSlot:add_item(ItemStack(def._industrialtest_emptyVariant))
inv:set_stack("leftover",1,leftoverSlot)
end
@@ -211,7 +233,7 @@ industrialtest.internal.registerMachine({
registerActiveVariant=true,
sounds="metal",
powerSlots={"powerStorage"},
storageSlots={"src","dst","powerStorage","upgrades"},
storageSlots={"fuel","target","powerStorage","upgrades"},
groups={
_industrialtest_hasPowerInput=1
},

View File

@@ -71,18 +71,32 @@ 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={
"list[context;charged;1,2.5;1,1]",
industrialtest.internal.getItemSlotBg(1,2.5,1,1),
"label[0.9,3.9;"..S("Charge").."]",
"list[context;discharged;3,2.5;1,1]",
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 ""),
"listring[context;charged]",
"listring[context;discharged]"
}
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
return table.concat(formspec,"")
end

View File

@@ -72,21 +72,19 @@ 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]",
"listring[current_player;main]",
(config.getFormspec and config.getFormspec(pos) or "")
"list[current_player;main;0.5,7.5;8,3;8]"
}
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),
"listring[current_player;main]",
(config.getFormspec and config.getFormspec(pos) or "")
mcl_formspec.get_itemslot_bg(0.5,10.24,9,1)
}
end
return table.concat(formspec,"")
@@ -380,7 +378,7 @@ function industrialtest.internal.registerMachine(config)
return inv, "src", mcl_util.select_stack(hop_inv, hop_list, inv, "src")
end
definition._mcl_hoppers_on_after_push=function(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
minetest.get_node_timer(pos):start(1.0)
end
end
definition.groups._industrialtest_wrenchUnmountable=1
@@ -550,22 +548,42 @@ 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={
"list[context;src;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]",
industrialtest.internal.getItemSlotBg(3.4,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.4,2.8;1,1]",
industrialtest.internal.getItemSlotBg(6.4,2.8,1,1),
"list[context;upgrades;9,0.9;1,4]",
industrialtest.internal.getItemSlotBg(9,0.9,1,4),
"listring[context;src]",
"listring[context;dst]"
}
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
return table.concat(formspec,"")
end

View File

@@ -22,34 +22,50 @@ 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")
local formspec={
"list[context;src;2,1.8;1,1]",
industrialtest.internal.getItemSlotBg(2,1.8,1,1),
(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),
"list[context;charged;6,3;1,1]",
industrialtest.internal.getItemSlotBg(6,3,1,1),
"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 ""),
"listring[context;src]",
"listring[context;dst]"
}
if industrialtest.mtgAvailable then
formspec={
"list[context;fluid;2,1.8;1,1]",
"listring[context;fluid]",
(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;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;fluid;2,1.8;1,1]",
mcl_formspec.get_itemslot_bg(2,1.8,1,1),
"listring[context;fluid]",
(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]",
mcl_formspec.get_itemslot_bg(2,4.2,1,1),
"listring[context;leftover]",
"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
return table.concat(formspec,"")
end
fluidGenerator.onConstruct=function(pos,meta,inv)
inv:set_size("charged",1)
inv:set_size("src",1)
inv:set_size("dst",1)
inv:set_size("fluid",1)
inv:set_size("leftover",1)
meta:set_float("fluidAmount",0)
meta:set_string("fluid","")
end
fluidGenerator.onTimer=function(pos,elapsed,meta,inv,config)
local fluidSlot=inv:get_stack("src",1)
local fluidSlot=inv:get_stack("fluid",1)
local chargedSlot=inv:get_stack("charged",1)
local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos)
local shouldUpdateFormspec=false
@@ -61,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("dst",ItemStack(item.leftover)) then
inv:add_item("dst",ItemStack(item.leftover))
if inv:room_for_item("leftover",ItemStack(item.leftover)) then
inv:add_item("leftover",ItemStack(item.leftover))
leftoverAddingSucceeded=true
end
leftover=true
@@ -70,7 +86,7 @@ fluidGenerator.onTimer=function(pos,elapsed,meta,inv,config)
end
if not leftover or leftoverAddingSucceeded then
fluidSlot:take_item()
inv:set_stack("src",1,fluidSlot)
inv:set_stack("fluid",1,fluidSlot)
meta:set_string("fluid",fuel.name)
meta:set_float("fluidAmount",meta:get_float("fluidAmount")+1000)
shouldUpdateFormspec=true
@@ -111,7 +127,7 @@ fluidGenerator.metadataChange=function(pos)
end
fluidGenerator.activeOnTimer=function(pos,elapsed,meta,inv,config)
local fluidSlot=inv:get_stack("src",1)
local fluidSlot=inv:get_stack("fluid",1)
local chargedSlot=inv:get_stack("charged",1)
local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos)
local shouldUpdateFormspec=false
@@ -124,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("dst",ItemStack(item.leftover)) then
inv:add_item("dst",ItemStack(item.leftover))
if inv:room_for_item("leftover",ItemStack(item.leftover)) then
inv:add_item("leftover",ItemStack(item.leftover))
leftoverAddingSucceeded=true
end
leftover=true
@@ -133,7 +149,7 @@ fluidGenerator.activeOnTimer=function(pos,elapsed,meta,inv,config)
end
if not leftover or leftoverAddingSucceeded then
fluidSlot:take_item()
inv:set_stack("src",1,fluidSlot)
inv:set_stack("fluid",1,fluidSlot)
meta:set_string("fluid",fuel.name)
meta:set_float("fluidAmount",meta:get_float("fluidAmount")+1000)
shouldUpdateFormspec=true
@@ -180,7 +196,7 @@ local function registerFluidGenerator(config)
requiresWrench=true,
registerActiveVariant=config.registerActiveVariant,
powerSlots={"charged"},
storageSlots={"src","dst"},
storageSlots={"fluid","fluidLeftover"},
sounds="metal",
groups={
_industrialtest_hasPowerOutput=1

View File

@@ -21,23 +21,38 @@ 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={
"list[context;charged;4.7,1.8;1,1]",
industrialtest.internal.getItemSlotBg(4.7,1.8,1,1),
(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),
"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 ""),
"listring[context;src]"
}
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;fuel;4.9,3.9;1,1]",
"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 "")
}
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;fuel;4.7,3.9;1,1]",
mcl_formspec.get_itemslot_bg(4.7,3.9,1,1),
"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 "")
}
end
return table.concat(formspec,"")
end
generator.onConstruct=function(pos,meta,inv)
inv:set_size("charged",1)
inv:set_size("src",1)
inv:set_size("fuel",1)
meta:set_int("fuelTime",0)
meta:set_int("maxFuelTime",1)
end
@@ -45,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("src",1)
local fuelSlot=inv:get_stack("fuel",1)
local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos)
local shouldUpdateFormspec=flowTransferred
local shouldRerunTimer=(afterFlow and meta:get_int("industrialtest.powerAmount")>0)
@@ -64,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("src",1,after.items[1])
inv:set_stack("fuel",1,after.items[1])
minetest.swap_node(pos,{
name="industrialtest:generator_active",
param2=minetest.get_node(pos).param2
@@ -77,7 +92,7 @@ end
generator.activeOnTimer=function(pos,elapsed,meta,inv)
local chargedSlot=inv:get_stack("charged",1)
local fuelSlot=inv:get_stack("src",1)
local fuelSlot=inv:get_stack("fuel",1)
local afterFlow,flowTransferred=industrialtest.api.powerFlow(pos)
local shouldUpdateFormspec=flowTransferred
local shouldRerunTimer=(afterFlow and meta:get_int("industrialtest.powerAmount")>0)
@@ -96,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("src",1,after.items[1])
inv:set_stack("fuel",1,after.items[1])
end
end
if meta:get_int("fuelTime")>0 then
@@ -126,7 +141,7 @@ industrialtest.internal.registerMachine({
ioConfig="oooooo",
registerActiveVariant=true,
powerSlots={"charged"},
storageSlots={"charged","src"},
storageSlots={"charged","fuel"},
sounds="metal",
groups={
_industrialtest_hasPowerOutput=1

View File

@@ -38,71 +38,92 @@ local function calculateMaxSrcTime(pos)
end
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 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={
"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;dst]"
local formspec
if industrialtest.mtgAvailable then
formspec={
"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]"
or "image[3.7,2.8;1,1;industrialtest_gui_electricity_bg.png]"),
"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]"
or "image[4.9,2.8;1,1;gui_furnace_arrow_bg.png^[transformR270]"),
"list[context;dst;6,2.8;2,1;]",
"list[context;upgrades;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
inductionFurnace.onConstruct=function(pos,meta,inv)
inv:set_size("src",2)
inv:set_size("dst",2)
inv:set_size("powerStorage",1)
inv:set_size("upgrades",4)
meta:set_int("heat",0)
meta:set_float("srcTime",0)
inv:set_size("src",2)
inv:set_size("dst",2)
inv:set_size("powerStorage",1)
inv:set_size("upgrades",4)
meta:set_int("heat",0)
meta:set_float("srcTime",0)
end
inductionFurnace.onTimer=function(pos,elapsed,meta,inv)
local shouldRerunTimer=false
local shouldUpdateFormspec=false
local srcList=inv:get_list("src")
local heat=meta:get_int("heat")
local shouldRerunTimer=false
local shouldUpdateFormspec=false
local srcList=inv:get_list("src")
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))
shouldRerunTimer=shouldRerunTimer or heat>0
shouldUpdateFormspec=true
end
for _,slot in ipairs(srcList) do
if not slot:is_empty() then
local result,after=minetest.get_craft_result({
method="cooking",
width=1,
items={slot}
})
if result.time>0 and inv:room_for_item("dst",result.item) then
minetest.swap_node(pos,{
name="industrialtest:induction_furnace_active",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,shouldUpdateFormspec
end
end
end
for _,slot in ipairs(srcList) do
if not slot:is_empty() then
local result,after=minetest.get_craft_result({
method="cooking",
width=1,
items={slot}
})
if result.time>0 and inv:room_for_item("dst",result.item) then
minetest.swap_node(pos,{
name="industrialtest:induction_furnace_active",
param2=minetest.get_node(pos).param2
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,shouldUpdateFormspec
end
end
end
return shouldRerunTimer,shouldUpdateFormspec
end
@@ -153,28 +174,28 @@ inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
local speed=industrialtest.api.getMachineSpeed(meta)
local requiredPower=elapsed*inductionFurnace.opPower*speed
industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
industrialtest.internal.chargeFromPowerStorageItem(meta,inv)
local shouldContinue=false
local results={}
for _,slot in ipairs(srcList) do
if slot:is_empty() then
for _,slot in ipairs(srcList) do
if slot:is_empty() then
table.insert(results,false)
else
local result,after=minetest.get_craft_result({
method="cooking",
width=1,
items={slot}
})
if result.time>0 and inv:room_for_item("dst",result.item) then
local result,after=minetest.get_craft_result({
method="cooking",
width=1,
items={slot}
})
if result.time>0 and inv:room_for_item("dst",result.item) then
table.insert(results,result.item)
shouldContinue=true
else
table.insert(results,false)
end
end
end
if not shouldContinue or powerAmount<requiredPower then
end
end
end
if not shouldContinue or powerAmount<requiredPower then
meta:set_float("srcTime",0)
minetest.swap_node(pos,{
name="industrialtest:induction_furnace",
@@ -182,10 +203,10 @@ inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
return false,true
end
end
srcTime=srcTime+elapsed*(1+heat/100)
if srcTime>=maxSrcTime then
if srcTime>=maxSrcTime then
for i,result in ipairs(results) do
if result then
local multiplier=math.min(srcList[i]:get_count(),speed)
@@ -197,8 +218,8 @@ inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
end
end
srcTime=0
end
meta:set_float("srcTime",srcTime)
end
meta:set_float("srcTime",srcTime)
if heat<100 then
meta:set_int("heat",math.min(100,heat+speed))
@@ -206,16 +227,16 @@ inductionFurnace.activeOnTimer=function(pos,elapsed,meta,inv)
industrialtest.api.addPower(meta,-requiredPower)
return true,true
return true,true
end
industrialtest.internal.registerMachine({
name="induction_furnace",
displayName=S("Induction Furnace"),
capacity=industrialtest.api.mvPowerFlow*2,
getFormspec=inductionFurnace.getFormspec,
flow=industrialtest.api.mvPowerFlow,
ioConfig="iiiiii",
name="induction_furnace",
displayName=S("Induction Furnace"),
capacity=industrialtest.api.mvPowerFlow*2,
getFormspec=inductionFurnace.getFormspec,
flow=industrialtest.api.mvPowerFlow,
ioConfig="iiiiii",
requiresWrench=true,
registerActiveVariant=true,
sounds="metal",
@@ -246,9 +267,9 @@ industrialtest.internal.registerMachine({
"industrialtest_advanced_machine_block.png^industrialtest_electric_furnace_front_active.png"
}
},
onConstruct=inductionFurnace.onConstruct,
onTimer=inductionFurnace.onTimer,
allowMetadataInventoryMove=inductionFurnace.allowMetadataInventoryMove,
onConstruct=inductionFurnace.onConstruct,
onTimer=inductionFurnace.onTimer,
allowMetadataInventoryMove=inductionFurnace.allowMetadataInventoryMove,
allowMetadataInventoryPut=inductionFurnace.allowMetadataInventoryPut,
onMetadataInventoryPut=inductionFurnace.onMetadataInventoryPut,
onMetadataInventoryMove=inductionFurnace.onMetadataInventoryMove,

View File

@@ -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]",
"listring[current_player;main]",
"listring[context;src]",
"listring[context;dst]"
"list[current_player;main;0.5,7.5;8,3;8]"
}
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),
"listring[current_player;main]",
"listring[context;src]",
"listring[context;dst]"
mcl_formspec.get_itemslot_bg(0.5,10.24,9,1)
}
end
return table.concat(formspec,"")
@@ -155,6 +155,11 @@ ironFurnace.activeOnTimer=function(pos,elapsed)
meta:set_float("maxSrcTime",output.time*0.7)
end
end
if meta:get_float("fuelTime")>0 then
meta:set_float("fuelTime",meta:get_float("fuelTime")-elapsed)
shouldUpdateFormspec=true
shouldRerunTimer=true
end
if meta:get_float("maxSrcTime")>0 then
if meta:get_float("fuelTime")>0 then
meta:set_float("srcTime",meta:get_float("srcTime")+elapsed)
@@ -175,11 +180,6 @@ ironFurnace.activeOnTimer=function(pos,elapsed)
})
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
if meta:get_float("fuelTime")>0 then
meta:set_float("fuelTime",meta:get_float("fuelTime")-elapsed)
shouldUpdateFormspec=true
shouldRerunTimer=true
end
if meta:get_float("srcTime")>=meta:get_float("maxSrcTime") then
local output,after=minetest.get_craft_result({
method="cooking",
@@ -223,23 +223,6 @@ ironFurnace.allowMetadataInventoryPut=function(pos,listname,index,stack)
return stack:get_count()
end
ironFurnace.allowMetadataInventoryTake=function(pos,listname,index,stack)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local srcSlot=inv:get_stack("src",1)
local dstSlot=inv:get_stack("dst",1)
if listname=="src" and stack:get_count()==srcSlot:get_count() then
meta:set_float("srcTime",-1)
meta:set_float("maxSrcTime",0)
if meta:get_float("maxFuelTime")>0 then
meta:set_string("formspec",ironFurnace.getFormspec(meta:get_float("fuelTime")/meta:get_float("maxFuelTime")*100,0))
end
elseif listname=="dst" and dstSlot:get_free_space()==0 then
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
return stack:get_count()
end
ironFurnace.onMetadataInventoryMove=function(pos,fromList,fromIndex,toList,toIndex,count)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
@@ -260,6 +243,22 @@ ironFurnace.onMetadataInventoryPut=function(pos,listname,index,stack)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
ironFurnace.onMetadataInventoryTake=function(pos,listname,index,stack)
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local srcSlot=inv:get_stack("src",1)
local dstSlot=inv:get_stack("dst",1)
if listname=="src" and stack:get_count()==srcSlot:get_count() then
meta:set_float("srcTime",-1)
meta:set_float("maxSrcTime",0)
if meta:get_float("maxFuelTime")>0 then
meta:set_string("formspec",ironFurnace.getFormspec(meta:get_float("fuelTime")/meta:get_float("maxFuelTime")*100,0))
end
elseif listname=="dst" and dstSlot:get_free_space()==0 then
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
end
local definition={
description=S("Iron Furnace"),
tiles={
@@ -277,9 +276,9 @@ local definition={
on_timer=ironFurnace.onTimer,
allow_metadata_inventory_move=ironFurnace.allowMetadataInventoryMove,
allow_metadata_inventory_put=ironFurnace.allowMetadataInventoryPut,
allow_metadata_inventory_take=ironFurnace.allowMetadataInventoryTake,
on_metadata_inventory_move=ironFurnace.onMetadataInventoryMove,
on_metadata_inventory_put=ironFurnace.onMetadataInventoryPut
on_metadata_inventory_put=ironFurnace.onMetadataInventoryPut,
on_metadata_inventory_take=ironFurnace.onMetadataInventoryTake
}
if industrialtest.mtgAvailable then
definition.groups={
@@ -293,21 +292,13 @@ if industrialtest.mtgAvailable then
return not (inv:get_list("src")[1]:get_count()>0 or inv:get_list("fuel")[1]:get_count()>0 or inv:get_list("dst")[1]:get_count()>0)
end
elseif industrialtest.mclAvailable then
definition.groups={
pickaxey=1,
container=2
}
definition.groups={pickaxey=1}
definition.after_dig_node=function(pos,oldnode,oldmeta)
industrialtest.internal.mclAfterDigNode(pos,oldmeta,{"src","fuel","dst"})
end
definition.sounds=mcl_sounds.node_sound_metal_defaults()
definition._mcl_blast_resistance=3
definition._mcl_hardness=3.5
definition._mcl_hoppers_on_try_pull = mcl_furnaces.hoppers_on_try_pull
definition._mcl_hoppers_on_try_push = mcl_furnaces.hoppers_on_try_push
definition._mcl_hoppers_on_after_push = function(pos)
minetest.get_node_timer(pos):start(industrialtest.updateDelay)
end
end
minetest.register_node("industrialtest:iron_furnace",definition)
definition=table.copy(definition)
@@ -326,9 +317,7 @@ definition.drop="industrialtest:iron_furnace"
definition.on_timer=ironFurnace.activeOnTimer
if industrialtest.mclAvailable then
definition.groups={
not_in_creative_inventory=1,
pickaxey=1,
container=2
not_in_creative_inventory=1
}
definition._doc_items_create_entry=false
end

View File

@@ -23,16 +23,30 @@ 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={
"list[context;fuel;1,1;"..size..","..size.."]",
industrialtest.internal.getItemSlotBg(1,1,size,size),
"list[context;charged;7,2.8;1,1]",
industrialtest.internal.getItemSlotBg(7.7,2.8,1,1),
"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 ""),
"listring[context;fuel]"
}
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
return table.concat(formspec,"")
end

View File

@@ -20,18 +20,32 @@ 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={
"list[context;charged;1,2.5;1,1]",
industrialtest.internal.getItemSlotBg(1,2.5,1,1),
"label[0.9,3.9;"..S("Charge").."]",
"list[context;discharged;3,2.5;1,1]",
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 ""),
"listring[context;charged]",
"listring[context;discharged]"
}
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
return table.concat(formspec,"")
end

View File

@@ -27,26 +27,51 @@ 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={
"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;dst]"
}
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
return table.concat(formspec,"")
end

View File

@@ -20,13 +20,23 @@ 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={
"list[context;charged;4.7,1.8;1,1]",
industrialtest.internal.getItemSlotBg(4.7,1.8,1,1),
(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]"),
"listring[context;charged]"
}
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
return table.concat(formspec,"")
end

View File

@@ -20,29 +20,45 @@ 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={
"list[context;powerStorage;3.7,3.7;1,1;0]",
industrialtest.internal.getItemSlotBg(3.7,3.7,1,1),
(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),
"list[context;upgrades;9,0.9;1,4]",
industrialtest.internal.getItemSlotBg(9,0.9,1,4),
"listring[context;src]"
}
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;tool;5.9,3.2;1,1;0]",
"listring[context;tool]",
"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;tool;5.9,3.2;1,1;0]",
mcl_formspec.get_itemslot_bg(5.9,3.2,1,1),
"listring[context;tool]",
"list[context;upgrades;9,0.9;1,4]",
mcl_formspec.get_itemslot_bg(9,0.9,1,4),
"listring[context;upgrades]"
}
end
return table.concat(formspec,"")
end
toolWorkshop.onConstruct=function(pos,meta,inv)
inv:set_size("powerStorage",1)
inv:set_size("src",1)
inv:set_size("tool",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("src",1)
local toolSlot=inv:get_stack("tool",1)
local requiredPower=industrialtest.api.getMachineSpeed(meta)*10000
local shouldRerunTimer=false
local shouldUpdateFormspec=false
@@ -70,7 +86,7 @@ end
toolWorkshop.activeOnTimer=function(pos,elapsed,meta,inv)
local powerStorageSlot=inv:get_stack("powerStorage",1)
local toolSlot=inv:get_stack("src",1)
local toolSlot=inv:get_stack("tool",1)
local speed=industrialtest.api.getMachineSpeed(meta)
local requiredPower=speed*10000
local shouldRerunTimer=false
@@ -89,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("src",1,toolSlot)
inv:set_stack("tool",1,toolSlot)
industrialtest.api.addPower(meta,-requiredPower)
shouldRerunTimer=true
shouldUpdateFormspec=true
@@ -112,7 +128,7 @@ local function isTool(stack)
end
toolWorkshop.allowMetadataInventoryMove=function(pos,fromList,fromIndex,toList,toIndex,count)
if toList=="src" then
if toList=="tool" then
local meta=minetest.get_meta(pos)
local inv=meta:get_inventory()
local movedItemStack=inv:get_stack(fromList,fromIndex)
@@ -144,7 +160,7 @@ industrialtest.internal.registerMachine({
requiresWrench=true,
registerActiveVariant=true,
powerSlots={"powerStorage"},
storageSlots={"src"},
storageSlots={"tool"},
sounds="metal",
groups={
_industrialtest_hasPowerInput=1

View File

@@ -20,13 +20,23 @@ local windMill={}
windMill.getFormspec=function(pos)
local meta=minetest.get_meta(pos)
local charging=meta:get_int("charging")
local formspec={
"list[context;charged;4.7,1.8;1,1]",
industrialtest.internal.getItemSlotBg(4.7,1.8,1,1),
(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]"),
"listring[context;charged]"
}
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
return table.concat(formspec,"")
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 B

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 405 B

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 321 B

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 282 B

After

Width:  |  Height:  |  Size: 815 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 867 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 447 B

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 402 B

After

Width:  |  Height:  |  Size: 427 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 589 B

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 790 B

After

Width:  |  Height:  |  Size: 571 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 490 B

After

Width:  |  Height:  |  Size: 776 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 732 B

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 471 B

After

Width:  |  Height:  |  Size: 977 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 748 B

After

Width:  |  Height:  |  Size: 953 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 B

After

Width:  |  Height:  |  Size: 658 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 878 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 527 B

After

Width:  |  Height:  |  Size: 834 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B