Partial fix for not working formspecs in MCL

This commit is contained in:
mrkubax10 2023-03-01 15:35:20 +02:00
parent 6c62b8d4a3
commit 71618b2f3f
2 changed files with 24 additions and 5 deletions

View File

@ -461,6 +461,17 @@ if industrialtest.mclAvailable then
}
})
end
-- FIXME: Formspecs when used with MCL are misaligned, to fix that and also preserve compatibilty
-- with MTG MCL has to stop using legacy formspec coordinates ~mrkubax10
industrialtest.formspecVersion=function()
return ""
end
industrialtest.formspecList=function(ctx,name,x,y,w,h)
return "list["..ctx..";"..name..";"..x..","..y..";"..w..","..h.."]"..mcl_formspec.get_itemslot_bg(x,y,w,h)
end
industrialtest.formspecPlayerInv=function()
return "list[current_player;main;0.5,5.5;9,3;9]"..mcl_formspec.get_itemslot_bg(0.5,5.5,9,3).."list[current_player;main;0.5,8.74;9,1]"..mcl_formspec.get_itemslot_bg(0.5,8.74,9,1)
end
-- assign element keys for elements that are required later
industrialtest.elementKeys.stick="mcl_core:stick"
@ -609,6 +620,15 @@ elseif industrialtest.mtgAvailable then
}
})
end
industrialtest.formspecVersion=function()
return "formspec_version[4]"
end
industrialtest.formspecList=function(ctx,name,x,y,w,h)
return "list["..ctx..";"..name..";"..x..","..y..";"..w..","..h.."]"
end
industrialtest.formspecPlayerInv=function()
return "list[current_player;main;0.5,6.25;8,1]list[current_player;main;0.5,7.5;8,3;8]"
end
industrialtest.elementKeys.tinIngot="default:tin_ingot"
industrialtest.elementKeys.bronzeIngot="default:bronze_ingot"
industrialtest.elementKeys.stick="default:stick"

View File

@ -19,16 +19,15 @@ local S=minetest.get_translator("industrialtest")
-- Generators
local function generatorFormspec(fuelPercent)
local formspec={
"formspec_version[4]",
industrialtest.formspecVersion(),
"size[10.8,12]",
"label[0.5,0.5;"..S("Generator").."]",
"list[context;charged;4.9,1.8;1,1]",
industrialtest.formspecList("context","charged",4.9,1.8,1,1),
"listring[context;charged]",
"image[4.9,2.8;1,1;default_furnace_fire_bg.png^[lowpart:"..fuelPercent..":default_furnace_fire_fg.png]",
"list[context;fuel;4.9,3.9;1,1]",
industrialtest.formspecList("context","fuel",4.9,3.9,1,1),
"listring[context;fuel]",
"list[current_player;main;0.5,6.25;8,1;]",
"list[current_player;main;0.5,7.5;8,3;8]"
industrialtest.formspecPlayerInv()
}
return table.concat(formspec,"")
end