Browse Source

player inventory

main
Hendrik Langer 5 years ago
parent
commit
bb888787a4
  1. 21
      init.lua
  2. 2
      settingtypes.txt

21
init.lua

@ -11,7 +11,7 @@ toggle_areas.registered_on_leave = {}
areas_owner_privs = minetest.settings:get("toggle_areas.owner_privs") or "+creative, +fly, +fast" areas_owner_privs = minetest.settings:get("toggle_areas.owner_privs") or "+creative, +fly, +fast"
areas_guest_privs = minetest.settings:get("toggle_areas.guest_privs") or "-fly, -fast" areas_guest_privs = minetest.settings:get("toggle_areas.guest_privs") or "-fly, -fast"
default_privs = minetest.settings:get("toggle_areas.default_privs") or "+fast" default_privs = minetest.settings:get("toggle_areas.default_privs") or "+fast, -creative"
function toggle_areas:load_areas() function toggle_areas:load_areas()
local test = minetest.deserialize(mod_storage:get_string("astore")) local test = minetest.deserialize(mod_storage:get_string("astore"))
@ -102,7 +102,7 @@ end
function toggle_areas:save_player_inventory(player, listname) function toggle_areas:save_player_inventory(player, listname)
local name = player:get_player_name() local name = player:get_player_name()
local pmeta = player:get_meta() local pmeta = player:get_meta()
local inv = minetest.get_inventory({type="player", name=name}) local inv = player:get_inventory()
local player_items = inv:get_list("main") local player_items = inv:get_list("main")
inv:set_list(listname, player_items) inv:set_list(listname, player_items)
end end
@ -110,7 +110,7 @@ end
function toggle_areas:restore_player_inventory(player, listname) function toggle_areas:restore_player_inventory(player, listname)
local name = player:get_player_name() local name = player:get_player_name()
local pmeta = player:get_meta() local pmeta = player:get_meta()
local inv = minetest.get_inventory({type="player", name=name}) local inv = player:get_inventory()
local player_items = inv:get_list(listname) or {} local player_items = inv:get_list(listname) or {}
inv:set_list("main", player_items) inv:set_list("main", player_items)
end end
@ -125,7 +125,7 @@ function toggle_areas:player_enter_area(player, privstring)
minetest.chat_send_player(name, "You entered creative mode") minetest.chat_send_player(name, "You entered creative mode")
toggle_areas:save_player_inventory(player, "saved_survival") toggle_areas:save_player_inventory(player, "saved_survival")
toggle_areas:restore_player_inventory(player, "saved_creative") toggle_areas:restore_player_inventory(player, "saved_creative")
elseif has_creative and not privs_grant.creative then elseif has_creative and privs_revoke.creative then
minetest.chat_send_player(name, "You entered survival mode") minetest.chat_send_player(name, "You entered survival mode")
toggle_areas:save_player_inventory(player, "saved_creative") toggle_areas:save_player_inventory(player, "saved_creative")
toggle_areas:restore_player_inventory(player, "saved_survival") toggle_areas:restore_player_inventory(player, "saved_survival")
@ -197,17 +197,16 @@ function toggle_areas:update_player(player)
end end
local privstring = default_privs local privstring = default_privs
if smallest_area.id and toggle_areas.area_privs[smallest_area.id] then
privstring = toggle_areas.area_privs[smallest_area.id]
end
if areas_owner or areas_open then if areas_owner or areas_open then
privstring = areas_owner_privs privstring = privstring .. ", " .. areas_owner_privs
elseif areas_guest then elseif areas_guest then
if toggle_areas.area_privs[player_active_area] then if toggle_areas.area_privs[player_active_area] then
privstring = toggle_areas.area_privs[player_active_area] privstring = privstring .. ", " .. toggle_areas.area_privs[player_active_area]
else else
privstring = areas_guest_privs privstring = privstring .. ", " .. areas_guest_privs
end
elseif smallest_area.id then
if toggle_areas.area_privs[smallest_area.id] then
privstring = toggle_areas.area_privs[smallest_area.id]
end end
end end

2
settingtypes.txt

@ -5,4 +5,4 @@ toggle_areas.owner_privs (Owner privs) string "+creative, +fly, +fast"
toggle_areas.guest_privs (Guest privs) string "-fly, -fast" toggle_areas.guest_privs (Guest privs) string "-fly, -fast"
# Default privs # Default privs
toggle_areas.guest_privs (Default privs) string "+fast" toggle_areas.guest_privs (Default privs) string "+fast, -creative"

Loading…
Cancel
Save