Can now control closing for formspec
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,
|
* `playername` is the name of the player who selected the item,
|
||||||
* `itemstring` is the itemstring of the chosen 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
|
## Examples
|
||||||
Display all items from Creative inventory to player 1:
|
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
|
||||||
end
|
end
|
||||||
if item then
|
if item then
|
||||||
minetest.close_formspec(playername, formname)
|
local close = true
|
||||||
for i=1,#callbacks do
|
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
|
end
|
||||||
reset_player_info(playername)
|
reset_player_info(playername)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue