mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-29 22:03:42 +01:00
Init data when player joins
This commit is contained in:
parent
7fc2d3a96a
commit
fd375c92b3
@ -1,4 +1,3 @@
|
|||||||
sfinv?
|
sfinv?
|
||||||
sfinv_buttons?
|
sfinv_buttons?
|
||||||
intllib?
|
intllib?
|
||||||
display_api?
|
|
19
init.lua
19
init.lua
@ -795,9 +795,7 @@ if sfinv_only then
|
|||||||
local name = player:get_player_name()
|
local name = player:get_player_name()
|
||||||
local data = player_data[name]
|
local data = player_data[name]
|
||||||
|
|
||||||
if not data then
|
if progressive_mode then
|
||||||
init_data(player, name)
|
|
||||||
elseif progressive_mode then
|
|
||||||
data.p_items = get_progressive_items(player, name)
|
data.p_items = get_progressive_items(player, name)
|
||||||
filter_items(data)
|
filter_items(data)
|
||||||
end
|
end
|
||||||
@ -818,16 +816,12 @@ else
|
|||||||
local name = user:get_player_name()
|
local name = user:get_player_name()
|
||||||
local data = player_data[name]
|
local data = player_data[name]
|
||||||
|
|
||||||
if not data then
|
if progressive_mode then
|
||||||
init_data(user, name)
|
|
||||||
data = player_data[name]
|
|
||||||
data.formspec = make_formspec(name)
|
|
||||||
elseif progressive_mode then
|
|
||||||
data.p_items = get_progressive_items(user, name)
|
data.p_items = get_progressive_items(user, name)
|
||||||
filter_items(data)
|
filter_items(data)
|
||||||
data.formspec = make_formspec(name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
data.formspec = make_formspec(name)
|
||||||
show_formspec(name, "craftguide", data.formspec)
|
show_formspec(name, "craftguide", data.formspec)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -928,8 +922,6 @@ if not progressive_mode then
|
|||||||
if not node_name then
|
if not node_name then
|
||||||
return false, mt.colorize("red", "[craftguide] ") ..
|
return false, mt.colorize("red", "[craftguide] ") ..
|
||||||
S("No node pointed")
|
S("No node pointed")
|
||||||
elseif not player_data[name] then
|
|
||||||
init_data(player, name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = player_data[name]
|
local data = player_data[name]
|
||||||
@ -963,6 +955,11 @@ end
|
|||||||
|
|
||||||
mt.register_on_mods_loaded(get_init_items)
|
mt.register_on_mods_loaded(get_init_items)
|
||||||
|
|
||||||
|
mt.register_on_joinplayer(function(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
init_data(player, name)
|
||||||
|
end)
|
||||||
|
|
||||||
local function save_meta(player, data)
|
local function save_meta(player, data)
|
||||||
local meta = player:get_meta()
|
local meta = player:get_meta()
|
||||||
meta:set_string("p_items", serialize(data.p_items))
|
meta:set_string("p_items", serialize(data.p_items))
|
||||||
|
Loading…
Reference in New Issue
Block a user