fix *some* issues
parent
54c2c84a3b
commit
afae933c64
|
@ -25,22 +25,6 @@ minetest.register_node("detached_chest:detached_chest", {
|
|||
meta:set_string("infotext", "Detached Chest (unconfigured)")
|
||||
end,
|
||||
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("formspec",
|
||||
"size[8,9]"..
|
||||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
"list[current_player;more_chests:wifi;0,0.3;8,4;]"..
|
||||
"list[current_player;main;0,4.85;8,1;]" ..
|
||||
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||
"listring[current_player;more_chests:wifi]" ..
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(0,4.85))
|
||||
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, _, player)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("channel") == "" then
|
||||
|
|
|
@ -4,7 +4,7 @@ local FORMNAME = "detached_chest_configure"
|
|||
function detached_chest.show_form_configure(pos, player)
|
||||
|
||||
local playername = player:get_player_name()
|
||||
local formspec = "field[channel;Channel;${channel}"
|
||||
local formspec = "field[channel;Channel;channel_name]"
|
||||
|
||||
minetest.show_formspec(playername,
|
||||
FORMNAME .. ";" .. minetest.pos_to_string(pos),
|
||||
|
@ -28,7 +28,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
|
|||
return
|
||||
end
|
||||
|
||||
if fields.save and fields.channel then
|
||||
if fields.channel then
|
||||
meta:set_string("channel", fields.channel)
|
||||
meta:set_string("infotext", "Detached Chest (channel: " .. fields.channel .. ")")
|
||||
end
|
||||
|
|
|
@ -14,10 +14,10 @@ function detached_chest.show_form_inventory(pos, player)
|
|||
default.gui_bg ..
|
||||
default.gui_bg_img ..
|
||||
default.gui_slots ..
|
||||
"list[current_player;detached:" .. inv_name .. ";main;0,0.3;8,4;]"..
|
||||
"list[detached:" .. inv_name .. ";main;0,0.3;8,4;]"..
|
||||
"list[current_player;main;0,4.85;8,1;]" ..
|
||||
"list[current_player;main;0,6.08;8,3;8]" ..
|
||||
"listring[current_player;detached:" .. inv_name .. ";main]" ..
|
||||
"listring[detached:" .. inv_name .. ";main]" ..
|
||||
"listring[current_player;main]" ..
|
||||
default.get_hotbar_bg(0,4.85)
|
||||
|
||||
|
|
2
init.lua
2
init.lua
|
@ -3,7 +3,7 @@ detached_chest = {}
|
|||
|
||||
local MP = minetest.get_modpath("detached_chest")
|
||||
|
||||
dofile(MP.."/form_cofigure.lua")
|
||||
dofile(MP.."/form_configure.lua")
|
||||
dofile(MP.."/form_inventory.lua")
|
||||
dofile(MP.."/inventory.lua")
|
||||
dofile(MP.."/chest_node.lua")
|
||||
|
|
|
@ -14,7 +14,7 @@ end
|
|||
local player_inventories = {}
|
||||
|
||||
function detached_chest.get_inventory_name(player, channel)
|
||||
return player:get_player_name() .. ":" .. channel
|
||||
return player:get_player_name() .. "_" .. channel
|
||||
end
|
||||
|
||||
-- create / get
|
||||
|
@ -36,11 +36,13 @@ function detached_chest.setup_inventory(player, channel)
|
|||
-- restore
|
||||
local save_file = get_save_file(playername, inv_name)
|
||||
local file = io.open(save_file,"r")
|
||||
local data = file:read("*a")
|
||||
if data then
|
||||
inv:set_list("main", minetest.deserialize(data))
|
||||
end
|
||||
file:close()
|
||||
if file then
|
||||
local data = file:read("*a")
|
||||
if data then
|
||||
inv:set_list("main", minetest.deserialize(data))
|
||||
end
|
||||
file:close()
|
||||
end
|
||||
|
||||
inv_map[inv_name] = inv
|
||||
end
|
||||
|
@ -56,14 +58,15 @@ minetest.register_on_leaveplayer(function(player)
|
|||
return
|
||||
end
|
||||
|
||||
for inv_name, inv in pairs(player_inventories[playername]) do
|
||||
for inv_name, _ in pairs(player_inventories[playername]) do
|
||||
-- persist
|
||||
--[[
|
||||
local save_file = get_save_file(playername, inv_name)
|
||||
local file = io.open(save_file,"w")
|
||||
local data = minetest.serialize(inv:get_list("main"))
|
||||
file:write(data)
|
||||
file:close()
|
||||
|
||||
--]]
|
||||
minetest.remove_detached_inventory(inv_name)
|
||||
end
|
||||
end)
|
||||
|
|
Loading…
Reference in New Issue