Can now control closing for formspec
This commit is contained in:
parent
9e408e84ee
commit
e539f9dded
4
API.md
4
API.md
@ -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:
|
||||
```
|
||||
|
10
init.lua
10
init.lua
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user