Inventories: 0 is used to prevent take, not -1

master
rubenwardy 2021-02-21 04:23:48 +00:00
parent c455aff265
commit f1f051c3cb
2 changed files with 5 additions and 5 deletions

View File

@ -142,7 +142,7 @@ before accessing it:
minetest.create_detached_inventory("inventory_name")
```
The create_detached_inventory function accepts 3 arguments, where only the first - the inventory name -
The create_detached_inventory function accepts 3 arguments, where only the first - the inventory name -
is required.
The second argument takes a table of callbacks, which can be used to control how
players interact with the inventory:
@ -159,7 +159,7 @@ minetest.create_detached_inventory("inventory_name", {
end,
allow_take = function(inv, listname, index, stack, player)
return -1 -- don't allow taking
return 0 -- don't allow taking
end,
on_put = function(inv, listname, index, stack, player)
@ -171,7 +171,7 @@ minetest.create_detached_inventory("inventory_name", {
```
Permission callbacks - ie: those starting with `allow_` - return the number
of items to transfer, with -1 being used to prevent transfer completely.
of items to transfer, with 0 being used to prevent transfer completely.
On the contrary, action callbacks - starting with `on_` - don't have a return value.

View File

@ -140,7 +140,7 @@ minetest.create_detached_inventory("inventory_name", {
end,
allow_take = function(inv, listname, index, stack, player)
return -1 -- non permette di rimuoverli
return 0 -- non permette di rimuoverli
end,
on_put = function(inv, listname, index, stack, player)
@ -151,7 +151,7 @@ minetest.create_detached_inventory("inventory_name", {
})
```
I callback dei permessi - quelle che iniziano con `allow_` - ritornano il numero degli oggetti da trasferire, e si usa -1 per impedirne del tutto l'azione.
I callback dei permessi - quelle che iniziano con `allow_` - ritornano il numero degli oggetti da trasferire, e si usa 0 per impedirne del tutto l'azione.
I callback delle azioni - quelle che iniziano con `on_` - non ritornano invece alcun valore.