I think I can kinda work with them but actually I don't have a clue what I am doing. I noticed that formspec coordinates of some formspec elements are not consistent and depend on the element type.
For instance, elements end up at different places for the same coordinates depending on whether it is a button or (text) field.
You can see an example of this in my mod “L-System Tree Utility”, you'll clearly notice the buttons and fields are not nicely aligned and I have no idea how to fix this. I have tried several offsets for the buttons but they just seem to make it worse, so I decided to leave it as it is now.

The relevant code for this part of the formspec begins at line 272 in init.lua and is this:
Code: Select all
return ""..
"field[0.2,-3.5;11,10;axiom;Axiom;"..s(fields.axiom).."]"..
"button[11,0.2;1,1;edit_axiom;+]"..
"tooltip[edit_axiom;Opens larger text field for Axiom]"..
"field[0.2,-2.5;11,10;rules_a;Rules set A;"..s(fields.rules_a).."]"..
"button[11,1.2;1,1;edit_rules_a;+]"..
"tooltip[edit_rules_a;Opens larger text field for Rules set A]"..
"field[0.2,-1.5;11,10;rules_b;Rules set B;"..s(fields.rules_b).."]"..
"button[11,2.2;1,1;edit_rules_b;+]"..
"tooltip[edit_rules_b;Opens larger text field for Rules set B]"..
"field[0.2,-0.5;11,10;rules_c;Rules set C;"..s(fields.rules_c).."]"..
"button[11,3.2;1,1;edit_rules_c;+]"..
"tooltip[edit_rules_c;Opens larger text field for Rules set C]"..
"field[0.2,0.5;11,10;rules_d;Rules set D;"..s(fields.rules_d).."]"..
"button[11,4.2;1,1;edit_rules_d;+]"..
"tooltip[edit_rules_d;Opens larger text field for Rules set D]"..
"field[0.2,1.5;3,10;trunk;Trunk node name;"..s(fields.trunk).."]"..
"field[3.2,1.5;3,10;leaves;Leaves node name;"..s(fields.leaves).."]"..
"field[6.2,1.5;3,10;leaves2;Secondary leaves node name;"..s(fields.leaves2).."]"..
"field[9.2,1.5;3,10;fruit;Fruit node name;"..s(fields.fruit).."]"..
"field[0.2,2.5;3,10;trunk_type;Trunk type (single/double/crossed);"..s(fields.trunk_type).."]"..
"tooltip[trunk_type;This field specifies the shape of the tree trunk. Possible values:\n- \"single\": trunk of size 1×1\n- \"double\": trunk of size 2×2\n- \"crossed\": trunk in cross shape (3×3).]"..
"field[3.2,2.5;3,10;thin_branches;Thin branches? (true/false);"..s(fields.thin_branches).."]"..
"tooltip[thin_branches;\"true\": All branches are just 1 node wide. \"false\": Branches can be larger.]"..
"field[6.2,2.5;3,10;leaves2_chance;Secondary leaves chance (in percent);"..s(fields.leaves2_chance).."]"..
"tooltip[leaves2_chance;Chance (in percent) to replace a leaves node by a secondary leaves node]"..
"field[9.2,2.5;3,10;fruit_chance;Fruit chance (in percent);"..s(fields.fruit_chance).."]"..
"tooltip[fruit_chance;Change (in percent) to replace a leaves node by a fruit node.]"..
"field[0.2,3.5;3,10;iterations;Iterations;"..s(fields.iterations).."]"..
"tooltip[iterations;Maximum number of iterations, usually between 2 and 5.]"..
"field[3.2,3.5;3,10;random_level;Randomness level;"..s(fields.random_level).."]"..
"tooltip[random_level;Factor to lower number of iterations, usually between 0 and 3.]"..
"field[6.2,3.5;3,10;angle;Angle (in degrees);"..s(fields.angle).."]"..
"field[9.2,3.5;3,10;name;Name;"..s(fields.name).."]"..
"tooltip[name;An unique name for this tree, only used for convenience.]"..
"button[3.5,8.5;3,1;edit_save;Save tree to database]"..
"button[6.5,8.5;3,1;edit_clear;Clear fields]"
So can anyone please give me an explanation of the formspec coordinate system and how it works now, especially with regards to fields vs buttons? Also, are there even more coordinates for other formspec elements?
Note this is not a support request for that particular mod but a general question since getting formspec coordinates right is pretty important.