Page 1 of 1

Edoting player's formspec problems

PostPosted: Mon Nov 12, 2012 21:32
by 4aiman
Hello everyone!
I spent many hours trying to change formspec of the player, but it doesn't work at all!
Player.cpp definetily stated on the line #55 that deafault player's formspec could be changed:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
 // Can be redefined via Lua
inventory_formspec = "size[8,7.5]"
//"image[1,0.6;1,2;player.png]"
"list[current_player;main;0,3.5;8,4;]"
"list[current_player;craft;3,0;3,3;]"
"list[current_player;equipment;0.5,0;1,4;]"
"list[current_player;craftpreview;7,1;1,1;]";

What I want is to alter size of craft list to 2x2 and to add some new list 1x1.
There is a function set_player_properties() which was used in the player_textures mod to give dfferent players different textures.
I tried to set inventory_formspec using that function but it didn't work.
So, could anyone help me to set player's formspec?

PostPosted: Tue Nov 13, 2012 14:34
by PilzAdam
Here is a little example code: https://github.com/PilzAdam/MiniTest/blob/master/mods/inventory/init.lua
I hope that helps a bit. If you still have questions feel free to ask again.

PostPosted: Thu Nov 22, 2012 20:54
by 4aiman
Thanks alot, PilzAdam! It works!
May I ask where did you learn from about set_inventory_formspec func? There's no mention about it in the modding API.
Is there any other "hidden" functions?

PostPosted: Fri Nov 23, 2012 11:20
by PilzAdam

PostPosted: Fri Nov 23, 2012 11:46
by 4aiman
I must've been using an old one...
Thanks, PilzAdam!

PostPosted: Sat Nov 24, 2012 13:41
by 4aiman
One more question...
Adam, I took a look at your player_textures mod and now I want to have a texture of a player to be shown in the formspec of a workbench. The problem is that workbenches are "public"... One should determine what player has "opened" workbench and get his/her texture instead of texture of it's placer. Is there any way to determine current player's name when formspec of some node is shown to him?

PostPosted: Sat Nov 24, 2012 13:45
by PilzAdam
4aiman wrote:One more question...
Adam, I took a look at your player_textures mod and now I want to have a texture of a player to be shown in the formspec of a workbench. The problem is that workbenches are "public"... One should determine what player has "opened" workbench and get his/her texture instead of texture of it's placer. Is there any way to determine current player's name when formspec of some node is shown to him?

I see no way to do this with the current API. It would be possible if there would be a callback function when a player opens the formspec, but there currently isnt.