Remove unused mod priviligeareas
parent
af54a8c58c
commit
358e6b2744
|
@ -17,7 +17,6 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
* [invisible][] ([LGPL][lic.lgpl2.1] / [CC BY-SA][lic.ccbysa4.0]) -- version: [4 (a2a6504 Git)][ver.invisible]
|
||||
* [no_fall_damage][] ([MIT][lic.no_fall_damage]) -- version [1.0.0][ver.no_fall_damage] *2020-12-19*
|
||||
* [override][] ([MIT][lic.override]) -- version: [0.2 (e6dda7a Git)][ver.override] *2017-08-30*
|
||||
* [privilegeareas][] ([WTFPL][lic.privilegeareas] / [CC0][lic.cc0]) -- version: [15eae20 Git][ver.privilegeareas] *2018-11-16*
|
||||
* [privs][] ([CC0][lic.cc0])
|
||||
* [spectator_mode][] ([WTFPL][lic.spectator_mode]) -- version: [3648371 Git][ver.spectator_mode] *2020-07-15*
|
||||
* [whitelist][] ([CC0][lic.cc0]) -- version: [0.1 (b813b19 Git)][ver.whitelist] *2017-08-18*
|
||||
|
@ -352,7 +351,6 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
[painting]: https://github.com/minetest-mods/painting
|
||||
[pipeworks]: https://forum.minetest.net/viewtopic.php?t=2155
|
||||
[player_monoids]: https://github.com/minetest-mods/player_monoids
|
||||
[privilegeareas]: https://forum.minetest.net/viewtopic.php?t=5545
|
||||
[privs]: mods/admin/privs
|
||||
[pvp_areas]: https://forum.minetest.net/viewtopic.php?t=15480
|
||||
[quartz]: https://forum.minetest.net/viewtopic.php?t=5682
|
||||
|
@ -446,7 +444,6 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
[lic.no_fall_damage]: mods/admin/no_fall_damage/README.md
|
||||
[lic.override]: mods/admin/override/LICENSE.txt
|
||||
[lic.player_monoids]: mods/player/action/player_monoids/COPYING
|
||||
[lic.privilegeareas]: mods/admin/privilegeareas/README.md
|
||||
[lic.quartz]: mods/materials/quartz/LICENSE.txt
|
||||
[lic.rainbow_ore]: mods/materials/rainbow_ore/README.md
|
||||
[lic.sand_monster]: mods/mobiles/sand_monster/license.txt
|
||||
|
@ -602,7 +599,6 @@ The game includes the mods from the default [minetest_game](https://github.com/m
|
|||
[ver.painting]: https://github.com/minetest-mods/painting/tree/8961849
|
||||
[ver.pipeworks]: https://gitlab.com/VanessaE/pipeworks/tree/2670fd8
|
||||
[ver.player_monoids]: https://github.com/minetest-mods/player_monoids/tree/ed11a73
|
||||
[ver.privilegeareas]: https://github.com/minetest-mods/privilegeareas/tree/15eae20
|
||||
[ver.pvp_areas]: https://github.com/everamzah/pvp_areas/tree/6e4d66d
|
||||
[ver.quartz]: https://github.com/minetest-mods/quartz/tree/72ec06f
|
||||
[ver.rainbow_ore]: https://github.com/FsxShader2012/rainbow_ore/tree/6e77693
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
# Privilege Areas [privilegeareas]
|
||||
|
||||
This mod grants or revokes privileges to players depending on their position.
|
||||
|
||||
Made by rubenwardy (a long time ago)
|
||||
|
||||
License: CC0 or WTFPL
|
|
@ -1 +0,0 @@
|
|||
Granting and revoking privileges based on position on the map.
|
|
@ -1,209 +0,0 @@
|
|||
gui = {}
|
||||
|
||||
-- Chat command for opening gui
|
||||
minetest.register_chatcommand("privareas", {
|
||||
params = "",
|
||||
description = "PrivAreas: access a formspec from the privilegeareas mod",
|
||||
privs = {
|
||||
privs = true,
|
||||
},
|
||||
func = function(name, param)
|
||||
add_gui(name)
|
||||
end,
|
||||
})
|
||||
|
||||
-- The add gui
|
||||
function add_gui(name)
|
||||
print("Showing add area form to "..name)
|
||||
|
||||
gui[name]={
|
||||
type="box"
|
||||
}
|
||||
|
||||
minetest.show_formspec(name, "privilegeareas:gui_add", "size[6,5]"..
|
||||
"button[2,0;2,1;type;box]"..
|
||||
"field[2,2;1,1;x;X;0]"..
|
||||
"field[3,2;1,1;y;Y;0]"..
|
||||
"field[4,2;1,1;z;Z;0]"..
|
||||
"field[2,3;1,1;x2;X;0]"..
|
||||
"field[3,3;1,1;y2;Y;0]"..
|
||||
"field[4,3;1,1;z2;Z;0]"..
|
||||
"button_exit[2,4;2,1;submit;Add]")
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
local name = player:get_player_name()
|
||||
if (formname~="privilegeareas:gui_add") then
|
||||
return false
|
||||
end
|
||||
|
||||
if not minetest.check_player_privs(player, "privs") then
|
||||
return false
|
||||
end
|
||||
|
||||
if fields.submit then
|
||||
-- Do addition stuff
|
||||
print("submitting")
|
||||
|
||||
if gui[name].type == "box" then
|
||||
table.insert(privilegeareas.areas,{
|
||||
type = gui[name].type,
|
||||
location = {
|
||||
x=math.floor(fields.x),
|
||||
y=math.floor(fields.y),
|
||||
z=math.floor(fields.z),
|
||||
},
|
||||
location2 = {
|
||||
x=math.floor(fields.x2),
|
||||
y=math.floor(fields.y2),
|
||||
z=math.floor(fields.z2),
|
||||
},
|
||||
actions = {
|
||||
on_enter = {
|
||||
},
|
||||
on_leave = {
|
||||
}
|
||||
}
|
||||
})
|
||||
else
|
||||
table.insert(privilegeareas.areas,{
|
||||
type = gui[name].type,
|
||||
location = {
|
||||
x=math.floor(fields.x),
|
||||
y=math.floor(fields.y),
|
||||
z=math.floor(fields.z),
|
||||
radius=math.floor(fields.rad)
|
||||
},
|
||||
actions = {
|
||||
on_enter = {
|
||||
grant = {},
|
||||
take = {}
|
||||
|
||||
},
|
||||
on_leave = {
|
||||
grant = {},
|
||||
take = {}
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
gui[name]=nil
|
||||
|
||||
act_gui(name,#privilegeareas.areas)
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
if fields.type then
|
||||
-- Do toggle stuff
|
||||
print("toggling")
|
||||
if gui[name].type == "box" then
|
||||
gui[name].type = "radius"
|
||||
minetest.show_formspec(name, "privilegeareas:gui_add", "size[6,5]"..
|
||||
"button[2,0;2,1;type;"..gui[name].type.."]"..
|
||||
"field[2,2;1,1;x;X;"..fields.x.."]"..
|
||||
"field[3,2;1,1;y;Y;"..fields.y.."]"..
|
||||
"field[4,2;1,1;z;Z;"..fields.z.."]"..
|
||||
"field[2,3;1,1;rad;R;0]"..
|
||||
"button_exit[2,4;2,1;submit;Add]")
|
||||
else
|
||||
gui[name].type = "box"
|
||||
minetest.show_formspec(name, "privilegeareas:gui_add", "size[6,5]"..
|
||||
"button[2,0;2,1;type;"..gui[name].type.."]"..
|
||||
"field[2,2;1,1;x;X;"..fields.x.."]"..
|
||||
"field[3,2;1,1;y;Y;"..fields.y.."]"..
|
||||
"field[4,2;1,1;z;Z;"..fields.z.."]"..
|
||||
"field[2,3;1,1;x2;X;0]"..
|
||||
"field[3,3;1,1;y2;Y;0]"..
|
||||
"field[4,3;1,1;z2;Z;0]"..
|
||||
"button_exit[2,4;2,1;submit;Add]")
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function act_gui(name,id)
|
||||
print("Showing add action form for area "..id)
|
||||
|
||||
print(dump(privilegeareas.areas[id]))
|
||||
|
||||
if not gui[name] or not gui[name].trigger or not gui[name].type or not gui[name].value then
|
||||
gui[name]={
|
||||
trigger = "on_enter",
|
||||
type = "grant",
|
||||
value = "",
|
||||
}
|
||||
end
|
||||
|
||||
gui[name].id = id
|
||||
|
||||
minetest.show_formspec(name, "privilegeareas:gui_act", "size[7,4]"..
|
||||
"field[2,1;4,1;name;Data;"..gui[name].value.."]"..
|
||||
"button[1,2;2,1;trigger;"..gui[name].trigger.."]"..
|
||||
"button[4,2;2,1;type;"..gui[name].type.."]"..
|
||||
"button[1,3;2,1;submit;Add]"..
|
||||
"button_exit[4,3;2,1;close;Close]")
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player, formname, fields)
|
||||
if (formname~="privilegeareas:gui_act") then
|
||||
return false
|
||||
end
|
||||
|
||||
local name = player:get_player_name()
|
||||
gui[name].value = fields.name
|
||||
|
||||
if fields.close then
|
||||
return
|
||||
end
|
||||
|
||||
if fields.submit then
|
||||
-- Do addition stuff
|
||||
print("submitting")
|
||||
|
||||
if (gui[name].id and gui[name].trigger and fields.name) then
|
||||
-- this will doubtlessly be buggy
|
||||
local id = gui[name].id
|
||||
local trigger = gui[name].trigger
|
||||
local action_type = gui[name].type
|
||||
local trigger_action_types = privilegeareas.areas[id].actions[trigger]
|
||||
if not trigger_action_types[action_type] then
|
||||
trigger_action_types[action_type] = {}
|
||||
end
|
||||
table.insert(trigger_action_types[action_type],fields.name)
|
||||
|
||||
-- Alert user of success
|
||||
minetest.chat_send_player(name, "Added data '"..fields.name.."' to '"..gui[name].type.."' in trigger "..gui[name].trigger.." in area "..gui[name].id)
|
||||
|
||||
-- Delete field
|
||||
gui[name] = nil
|
||||
|
||||
-- Update
|
||||
act_gui(name,id)
|
||||
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if fields.type then
|
||||
-- Do toggle stuff
|
||||
print("toggling type")
|
||||
if gui[player:get_player_name()].type == "grant" then
|
||||
gui[player:get_player_name()].type = "take"
|
||||
else
|
||||
gui[player:get_player_name()].type = "grant"
|
||||
end
|
||||
end
|
||||
|
||||
if fields.trigger then
|
||||
-- Do toggle stuff
|
||||
print("toggling trigger")
|
||||
if gui[player:get_player_name()].trigger == "on_enter" then
|
||||
gui[player:get_player_name()].trigger = "on_leave"
|
||||
else
|
||||
gui[player:get_player_name()].trigger = "on_enter"
|
||||
end
|
||||
end
|
||||
|
||||
act_gui(name,gui[name].id)
|
||||
end)
|
|
@ -1,273 +0,0 @@
|
|||
privilegeareas = {
|
||||
|
||||
players = nil,
|
||||
userdata = {},
|
||||
|
||||
areas = {
|
||||
},
|
||||
|
||||
createPlayerTable = function(player)
|
||||
if not privilegeareas.players then
|
||||
load_data()
|
||||
end
|
||||
|
||||
if not player or not player:get_player_name() then
|
||||
print("[PrivilegeAreas] Player does not exist!")
|
||||
return;
|
||||
end
|
||||
|
||||
local name = player:get_player_name()
|
||||
|
||||
print("[PrivilegeAreas] writing player table for "..name)
|
||||
|
||||
if (name=="") then
|
||||
return;
|
||||
end
|
||||
|
||||
privilegeareas.players[name] = {}
|
||||
privilegeareas.userdata[name] = player
|
||||
|
||||
if not privilegeareas.players[name].areas then
|
||||
privilegeareas.players[name].areas = {}
|
||||
end
|
||||
end,
|
||||
|
||||
calculate_current_areas = function(player)
|
||||
local name = player:get_player_name()
|
||||
|
||||
if (name=="") then
|
||||
return;
|
||||
end
|
||||
|
||||
if (not privilegeareas.players[name]) then
|
||||
createPlayerTable(player)
|
||||
end
|
||||
|
||||
for i=1,# privilegeareas.areas do
|
||||
if privilegeareas.areas[i].type == "radius" then
|
||||
if distance(player:getpos(),privilegeareas.areas[i].location) < privilegeareas.areas[i].location.radius then
|
||||
if (not privilegeareas.players[name].areas or not privilegeareas.players[name].areas[i] or privilegeareas.players[name].areas[i]==false) then
|
||||
privilegeareas.enter_area(player,i)
|
||||
end
|
||||
else
|
||||
if (privilegeareas.players[name].areas[i]==true) then
|
||||
privilegeareas.leave_area(player,i)
|
||||
end
|
||||
end
|
||||
elseif privilegeareas.areas[i].type == "box" then
|
||||
if (vector_is_in(privilegeareas.areas[i].location,privilegeareas.areas[i].location2,player:getpos())) then
|
||||
if (not privilegeareas.players[name].areas or not privilegeareas.players[name].areas[i] or privilegeareas.players[name].areas[i]==false) then
|
||||
privilegeareas.enter_area(player,i)
|
||||
end
|
||||
else
|
||||
if (privilegeareas.players[name].areas[i]==true) then
|
||||
privilegeareas.leave_area(player,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
||||
enter_area = function(player,i)
|
||||
local name = player:get_player_name()
|
||||
privilegeareas.players[name].areas[i]=true
|
||||
minetest.chat_send_player(name, "You have entered area "..i)
|
||||
print ("[PrivilegeAreas] "..name.." has entered area "..i)
|
||||
|
||||
-- Get privs
|
||||
local privs = minetest.get_player_privs(name)
|
||||
|
||||
if not privs then
|
||||
print("[PrivilegeAreas] player does not exist error!")
|
||||
end
|
||||
|
||||
-- loop grants
|
||||
local tmpv = false
|
||||
if privilegeareas.areas[i].actions.on_enter.grant then
|
||||
for a=1,# privilegeareas.areas[i].actions.on_enter.grant do
|
||||
if tmpv == false then
|
||||
tmpv = true
|
||||
minetest.chat_send_player(name, "You have been given the following privs:")
|
||||
print("[PrivilegeAreas] "..name.." has been given the following privs:")
|
||||
end
|
||||
|
||||
privs[privilegeareas.areas[i].actions.on_enter.grant[a]]=true;
|
||||
minetest.chat_send_player(name, "-- "..privilegeareas.areas[i].actions.on_enter.grant[a])
|
||||
print("[PrivilegeAreas] -- "..privilegeareas.areas[i].actions.on_enter.grant[a])
|
||||
end
|
||||
end
|
||||
|
||||
-- Loop though takes
|
||||
tmpv = false
|
||||
if privilegeareas.areas[i].actions.on_enter.take then
|
||||
|
||||
for a=1,# privilegeareas.areas[i].actions.on_enter.take do
|
||||
if tmpv == false then
|
||||
tmpv = true
|
||||
minetest.chat_send_player(name, "You have lost the following privs:")
|
||||
print("[PrivilegeAreas] "..name.." has lost the following privs:")
|
||||
end
|
||||
|
||||
privs[privilegeareas.areas[i].actions.on_enter.take[a]]=nil;
|
||||
minetest.chat_send_player(name, "-- "..privilegeareas.areas[i].actions.on_enter.take[a])
|
||||
print("[PrivilegeAreas] -- "..privilegeareas.areas[i].actions.on_enter.take[a])
|
||||
end
|
||||
end
|
||||
|
||||
-- Set privs
|
||||
minetest.set_player_privs(name, privs)
|
||||
|
||||
-- save data
|
||||
save_data()
|
||||
end,
|
||||
|
||||
leave_area = function(player,i)
|
||||
local name = player:get_player_name()
|
||||
privilegeareas.players[name].areas[i]=false
|
||||
minetest.chat_send_player(name, "You have left area "..i)
|
||||
print ("[PrivilegeAreas] "..name.." has left area "..i)
|
||||
|
||||
-- Get privs
|
||||
local privs = minetest.get_player_privs(name)
|
||||
|
||||
if not privs then
|
||||
print("[PrivilegeAreas] player does not exist error!")
|
||||
end
|
||||
|
||||
-- loop grants
|
||||
local tmp = false
|
||||
if privilegeareas.areas[i].actions.on_leave.grant then
|
||||
for a=1,# privilegeareas.areas[i].actions.on_leave.grant do
|
||||
if tmp == false then
|
||||
tmp = true
|
||||
minetest.chat_send_player(name, "You have been given the following privs:")
|
||||
print("[PrivilegeAreas] "..name.." has been given the following privs:")
|
||||
end
|
||||
|
||||
privs[privilegeareas.areas[i].actions.on_leave.grant[a]]=true;
|
||||
minetest.chat_send_player(name, "-- "..privilegeareas.areas[i].actions.on_leave.grant[a])
|
||||
print("[PrivilegeAreas] -- "..privilegeareas.areas[i].actions.on_leave.grant[a])
|
||||
end
|
||||
end
|
||||
|
||||
-- Loop though takes
|
||||
tmp = false
|
||||
if privilegeareas.areas[i].actions.on_leave.take then
|
||||
|
||||
for a=1,# privilegeareas.areas[i].actions.on_leave.take do
|
||||
if tmp == false then
|
||||
tmp = true
|
||||
minetest.chat_send_player(name, "You have lost the following privs:")
|
||||
print("[PrivilegeAreas] "..name.." has lost the following privs:")
|
||||
end
|
||||
|
||||
privs[privilegeareas.areas[i].actions.on_leave.take[a]]=nil;
|
||||
minetest.chat_send_player(name, "-- "..privilegeareas.areas[i].actions.on_leave.take[a])
|
||||
print("[PrivilegeAreas] -- "..privilegeareas.areas[i].actions.on_leave.take[a])
|
||||
end
|
||||
end
|
||||
|
||||
-- Set privs
|
||||
minetest.set_player_privs(name, privs)
|
||||
|
||||
-- save data
|
||||
save_data()
|
||||
end,
|
||||
}
|
||||
|
||||
-- Table Save Load Functions
|
||||
function save_data()
|
||||
if privilegeareas.players == nil then
|
||||
return
|
||||
end
|
||||
|
||||
print("[PrivilegeAreas] Saving data")
|
||||
|
||||
local file = io.open(minetest.get_worldpath().."/privareas.txt", "w")
|
||||
if file then
|
||||
file:write(minetest.serialize(privilegeareas.players))
|
||||
file:close()
|
||||
end
|
||||
|
||||
local file = io.open(minetest.get_worldpath().."/privareas_areas.txt", "w")
|
||||
if file then
|
||||
file:write(minetest.serialize(privilegeareas.areas))
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
|
||||
function _load_data()
|
||||
local file = io.open(minetest.get_worldpath().."/privareas_areas.txt", "r")
|
||||
if file then
|
||||
local table = minetest.deserialize(file:read("*all"))
|
||||
if type(table) == "table" then
|
||||
privilegeareas.areas = table
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function load_data()
|
||||
print("[PrivilegeAreas] Loading data")
|
||||
_load_data()
|
||||
if privilegeareas.players == nil then
|
||||
local file = io.open(minetest.get_worldpath().."/privareas.txt", "r")
|
||||
if file then
|
||||
local table = minetest.deserialize(file:read("*all"))
|
||||
if type(table) == "table" then
|
||||
privilegeareas.players = table
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
privilegeareas.players = {}
|
||||
end
|
||||
|
||||
load_data()
|
||||
|
||||
minetest.register_on_shutdown(function()
|
||||
-- save data
|
||||
save_data()
|
||||
end)
|
||||
|
||||
function vector_is_in(hay,box,needle)
|
||||
if (needle.x > hay.x and needle.x < box.x) then
|
||||
if (needle.y > hay.y and needle.y < box.y) then
|
||||
if (needle.z > hay.z and needle.z <box.z) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function distance(v, w)
|
||||
return math.sqrt(
|
||||
math.pow(v.x - w.x, 2) +
|
||||
math.pow(v.y - w.y, 2) +
|
||||
math.pow(v.z - w.z, 2)
|
||||
)
|
||||
end
|
||||
|
||||
local timer = 0
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime;
|
||||
if timer >= 1 then
|
||||
timer=0
|
||||
for _, plr in pairs(privilegeareas.userdata) do
|
||||
privilegeareas.calculate_current_areas(plr)
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
privilegeareas.createPlayerTable(player)
|
||||
end)
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
privilegeareas.userdata[player:get_player_name()]=nil
|
||||
end)
|
||||
|
||||
dofile(minetest.get_modpath("privilegeareas").."/gui.lua")
|
|
@ -1,7 +0,0 @@
|
|||
name = privilegeareas
|
||||
title = Privilege Areas
|
||||
author = rubenwardy
|
||||
description = Grant and revoke privileges based on position of a player on the map.
|
||||
license = WTFPL
|
||||
forum = https://forum.minetest.net/viewtopic.php?t=7553
|
||||
version = 1.1.0
|
Loading…
Reference in New Issue