Browse Source

make arena mode more intuitive

main
Hendrik Langer 5 years ago
parent
commit
5c599a0b03
  1. 12
      arena.lua
  2. 1
      init.lua
  3. 21
      items.lua
  4. 4
      region.lua

12
arena.lua

@ -32,6 +32,18 @@ function creative_regions.drop_everything(player, drop_bones)
end
minetest.register_on_dieplayer(function(player)
-- minetest.chat_send_all(player:get_player_name().." lost.")
local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {arena=true}) then
creative_regions.drop_everything(player, true)
local privs = minetest.get_player_privs(player_name)
privs["arena"] = nil
minetest.set_player_privs(player_name, privs)
end
end)
minetest.register_on_leaveplayer(function(player)
-- minetest.chat_send_all(player:get_player_name().." has left this awesome game.")
local player_name = player:get_player_name()
if minetest.check_player_privs(player_name, {arena=true}) then
creative_regions.drop_everything(player, true)

1
init.lua

@ -91,6 +91,7 @@ function creative_regions:update_player(player)
-- overwrite
if areas_owner or areas_open then
creative_regions:add_privs_from_string(new_privs_table, areas_owner_privs)
creative_regions:add_privs_from_string(new_privs_table, "-arena")
end
-- did the regions change? update

21
items.lua

@ -17,12 +17,19 @@ if minetest.get_modpath("areas") then
end
if player_owns_id then
if creative_regions.region_privs[player_owns_id] then
minetest.chat_send_player(name, "[creative_regions] Failed. Privileges for area already set.")
minetest.after(0.2, function(pos)
minetest.remove_node(pos)
end, pos)
return
end
meta:set_string("infotext", string.format(description.." for area %s owned by %s", player_owns_id, name))
meta:set_string("area_id", player_owns_id)
meta:set_string("privstring", privstring)
meta:set_string("owner", name)
creative_regions.add_region_privs(tostring(player_owns_id), privstring)
creative_regions.set_region_privs(tostring(player_owns_id), privstring)
minetest.chat_send_player(name, "[creative_regions] "..description.." set for region " .. player_owns_id)
creative_regions.save_regions()
else
@ -30,6 +37,7 @@ if minetest.get_modpath("areas") then
minetest.after(0.2, function(pos)
minetest.remove_node(pos)
end, pos)
return
end
end
@ -60,6 +68,8 @@ if minetest.get_modpath("areas") then
if player_owns_id then
return true
elseif owner == name then
return true
else
minetest.chat_send_player(name, "[creative_regions] Cannot remove protector block for area "..id.." owned by "..owner)
return false
@ -79,13 +89,12 @@ if minetest.get_modpath("areas") then
local current_areas = areas:getAreasAtPos(pos)
for areas_id, areas_area in pairs( current_areas ) do
local id = "a"..tostring(areas_id)
if stored_id == id then
local success = creative_regions.strip_region_privs(tostring(id), privstring)
if stored_id == id and privstring == creative_regions.region_privs[tostring(id)] then
creative_regions.set_region_privs(id, nil)
minetest.chat_send_player(name, "[creative_regions] "..description.." removed for area " .. id)
if not success then
minetest.chat_send_player(name, "[creative_regions] Failed to remove privileges!")
end
creative_regions.save_regions()
else
minetest.chat_send_player(name, "[creative_regions] Failed to remove privileges!")
end
end

4
region.lua

@ -36,7 +36,7 @@ function creative_regions.set_region_privs(id, privs_string)
creative_regions.region_privs[tostring(id)] = privs_string
end
function creative_regions.add_region_privs(id, privs_string)
--[[function creative_regions.add_region_privs(id, privs_string)
local region_privs = creative_regions.region_privs[tostring(id)]
if not region_privs or region_privs == '' then
creative_regions.region_privs[tostring(id)] = privs_string
@ -69,7 +69,7 @@ function creative_regions.strip_region_privs(id, privs_string)
creative_regions.region_privs[tostring(id)] = new_region_privs
return true
end
end
end--]]
function creative_regions:decode_privs_table(privs_table)
local privs_grant = {}

Loading…
Cancel
Save