From bb888787a40cd504c5f67cb606a99b883c34a5a4 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Sun, 24 May 2020 10:53:09 +0200 Subject: [PATCH] player inventory --- init.lua | 21 ++++++++++----------- settingtypes.txt | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/init.lua b/init.lua index d2cd784..e4336a1 100644 --- a/init.lua +++ b/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_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() local test = minetest.deserialize(mod_storage:get_string("astore")) @@ -102,7 +102,7 @@ end function toggle_areas:save_player_inventory(player, listname) local name = player:get_player_name() 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") inv:set_list(listname, player_items) end @@ -110,7 +110,7 @@ end function toggle_areas:restore_player_inventory(player, listname) local name = player:get_player_name() 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 {} inv:set_list("main", player_items) end @@ -125,7 +125,7 @@ function toggle_areas:player_enter_area(player, privstring) minetest.chat_send_player(name, "You entered creative mode") toggle_areas:save_player_inventory(player, "saved_survival") 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") toggle_areas:save_player_inventory(player, "saved_creative") toggle_areas:restore_player_inventory(player, "saved_survival") @@ -197,17 +197,16 @@ function toggle_areas:update_player(player) end 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 - privstring = areas_owner_privs + privstring = privstring .. ", " .. areas_owner_privs elseif areas_guest 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 - 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] + privstring = privstring .. ", " .. areas_guest_privs end end diff --git a/settingtypes.txt b/settingtypes.txt index 800a597..fb155f2 100644 --- a/settingtypes.txt +++ b/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" # Default privs -toggle_areas.guest_privs (Default privs) string "+fast" +toggle_areas.guest_privs (Default privs) string "+fast, -creative"