mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 15:23:48 +01:00
Improve on_wielditem_change
This commit is contained in:
parent
47a927005b
commit
61b48e09da
25
minetest.lua
25
minetest.lua
@ -410,18 +410,21 @@ end}
|
|||||||
--+ Will be called once with player, nil, index, item on join
|
--+ Will be called once with player, nil, index, item on join
|
||||||
register_on_wielditem_change = modlib.func.curry(table.insert, registered_on_wielditem_changes)
|
register_on_wielditem_change = modlib.func.curry(table.insert, registered_on_wielditem_changes)
|
||||||
|
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_mods_loaded(function()
|
||||||
local item, index = player:get_wielded_item(), player:get_wield_index()
|
-- Other on_joinplayer / on_leaveplayer callbacks should execute first
|
||||||
players[player:get_player_name()] = {
|
minetest.register_on_joinplayer(function(player)
|
||||||
wield = {
|
local item, index = player:get_wielded_item(), player:get_wield_index()
|
||||||
item = item,
|
players[player:get_player_name()] = {
|
||||||
index = index
|
wield = {
|
||||||
|
item = item,
|
||||||
|
index = index
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
modlib.table.icall(registered_on_wielditem_changes, player, nil, index, item)
|
||||||
modlib.table.icall(registered_on_wielditem_changes, player, nil, index, item)
|
end)
|
||||||
end)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
minetest.register_on_leaveplayer(function(player)
|
players[player:get_player_name()] = nil
|
||||||
player = players[player:get_player_name()]
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_globalstep(function()
|
minetest.register_globalstep(function()
|
||||||
|
Loading…
Reference in New Issue
Block a user