Can now control closing for formspec

master
Wuzzy 2018-05-15 04:31:39 +02:00
parent 9e408e84ee
commit e539f9dded
2 changed files with 12 additions and 2 deletions

4
API.md
View File

@ -46,6 +46,10 @@ This has the function signature `callback(playername, itemstring)`.
* `playername` is the name of the player who selected the item,
* `itemstring` is the itemstring of the chosen item.
Normally, if the player pushes a button, the formspec is closed.
But if you return `false` in this callback, the formspec is *not*
Use this when you run into problems.
## Examples
Display all items from Creative inventory to player 1:
```

View File

@ -155,9 +155,15 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end
end
if item then
minetest.close_formspec(playername, formname)
local close = true
for i=1,#callbacks do
callbacks[i](playername, item)
local ret = callbacks[i](playername, item)
if ret == false then
close = false
end
end
if close then
minetest.close_formspec(playername, formname)
end
reset_player_info(playername)
end