Initial Push
commit
fa9ddf042c
|
@ -0,0 +1,22 @@
|
||||||
|
# Auto detect text files and perform LF normalization
|
||||||
|
* text=auto
|
||||||
|
|
||||||
|
# Custom for Visual Studio
|
||||||
|
*.cs diff=csharp
|
||||||
|
*.sln merge=union
|
||||||
|
*.csproj merge=union
|
||||||
|
*.vbproj merge=union
|
||||||
|
*.fsproj merge=union
|
||||||
|
*.dbproj merge=union
|
||||||
|
|
||||||
|
# Standard to msysgit
|
||||||
|
*.doc diff=astextplain
|
||||||
|
*.DOC diff=astextplain
|
||||||
|
*.docx diff=astextplain
|
||||||
|
*.DOCX diff=astextplain
|
||||||
|
*.dot diff=astextplain
|
||||||
|
*.DOT diff=astextplain
|
||||||
|
*.pdf diff=astextplain
|
||||||
|
*.PDF diff=astextplain
|
||||||
|
*.rtf diff=astextplain
|
||||||
|
*.RTF diff=astextplain
|
|
@ -0,0 +1,163 @@
|
||||||
|
#################
|
||||||
|
## Eclipse
|
||||||
|
#################
|
||||||
|
|
||||||
|
*.pydevproject
|
||||||
|
.project
|
||||||
|
.metadata
|
||||||
|
bin/
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.classpath
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# CDT-specific
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# PDT-specific
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
|
||||||
|
#################
|
||||||
|
## Visual Studio
|
||||||
|
#################
|
||||||
|
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Rr]elease/
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.vspscc
|
||||||
|
.builds
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
## TODO: If you have NuGet Package Restore enabled, uncomment this
|
||||||
|
#packages/
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish
|
||||||
|
|
||||||
|
# Others
|
||||||
|
[Bb]in
|
||||||
|
[Oo]bj
|
||||||
|
sql
|
||||||
|
TestResults
|
||||||
|
*.Cache
|
||||||
|
ClientBin
|
||||||
|
stylecop.*
|
||||||
|
~$*
|
||||||
|
*.dbmdl
|
||||||
|
Generated_Code #added for RIA/Silverlight projects
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file to a newer
|
||||||
|
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
############
|
||||||
|
## Windows
|
||||||
|
############
|
||||||
|
|
||||||
|
# Windows image file caches
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
## Python
|
||||||
|
#############
|
||||||
|
|
||||||
|
*.py[co]
|
||||||
|
|
||||||
|
# Packages
|
||||||
|
*.egg
|
||||||
|
*.egg-info
|
||||||
|
dist
|
||||||
|
build
|
||||||
|
eggs
|
||||||
|
parts
|
||||||
|
bin
|
||||||
|
var
|
||||||
|
sdist
|
||||||
|
develop-eggs
|
||||||
|
.installed.cfg
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
.coverage
|
||||||
|
.tox
|
||||||
|
|
||||||
|
#Translations
|
||||||
|
*.mo
|
||||||
|
|
||||||
|
#Mr Developer
|
||||||
|
.mr.developer.cfg
|
||||||
|
|
||||||
|
# Mac crap
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,149 @@
|
||||||
|
privilegeareas = {
|
||||||
|
|
||||||
|
players = {},
|
||||||
|
|
||||||
|
areas = {
|
||||||
|
{
|
||||||
|
type="radius",
|
||||||
|
location = {x=0,y=0,z=0,radius=10},
|
||||||
|
sets = {
|
||||||
|
privs = {shout},
|
||||||
|
grant_on_enter = true;
|
||||||
|
take_on_exit = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
createPlayerTable = function(player)
|
||||||
|
if not player or not player:get_player_name() then
|
||||||
|
print("Player does not exist!")
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
local name = player:get_player_name()
|
||||||
|
|
||||||
|
print("writing player table for "..name)
|
||||||
|
|
||||||
|
if (name=="") then
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
|
||||||
|
privilegeareas.players[name] = {}
|
||||||
|
privilegeareas.players[name].player = player
|
||||||
|
|
||||||
|
if not privilegeareas.players[name].areas then
|
||||||
|
privilegeareas.players[name].areas = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
privilegeareas.calculate_current_areas(player)
|
||||||
|
end,
|
||||||
|
|
||||||
|
calculate_current_areas = function(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
print("calculating current areas for "..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
|
||||||
|
print ("is in area "..i)
|
||||||
|
if (not privilegeareas.players[name].areas or not privilegeareas.players[name].areas[i] or privilegeareas.players[name].areas[i]==false) then
|
||||||
|
print ("running function enter area")
|
||||||
|
privilegeareas.enter_area(player,i)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
print ("is not in area "..i)
|
||||||
|
if (privilegeareas.players[name].areas[i]==true) then
|
||||||
|
print ("running function leave area")
|
||||||
|
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)
|
||||||
|
for a=1,# privilegeareas.areas[i].sets do
|
||||||
|
if privilegeareas.areas[i].sets[a].grant_on_enter == true then
|
||||||
|
local privs = minetest.get_player_privs(name)
|
||||||
|
minetest.chat_send_player(name, "You have been given: ")
|
||||||
|
|
||||||
|
for b=1,# privilegeareas.areas[i].sets[a].privs do
|
||||||
|
privs[privilegeareas.areas[i].sets[a].privs[b]]=true;
|
||||||
|
minetest.chat_send_player(name, "-- "..privilegeareas.areas[i].sets[a].privs[b])
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.set_player_privs(name, privs)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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)
|
||||||
|
for a=1,# privilegeareas.areas[i].sets do
|
||||||
|
if privilegeareas.areas[i].sets[a].grant_on_enter == true then
|
||||||
|
local privs = minetest.get_player_privs(name)
|
||||||
|
minetest.chat_send_player(name, "You have been given: ")
|
||||||
|
|
||||||
|
for b=1,# privilegeareas.areas[i].sets[a].privs do
|
||||||
|
privs[privilegeareas.areas[i].sets[a].privs[b]]=true;
|
||||||
|
minetest.chat_send_player(name, "-- "..privilegeareas.areas[i].sets[a].privs[b])
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.set_player_privs(name, privs)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
function vector_is_in(hay,needle)
|
||||||
|
if (needle.x > hay.x and needle.x < hay.x+hay.w) then
|
||||||
|
if (needle.y > hay.y and needle.y < hay.y+hay.h) then
|
||||||
|
if (needle.z > hay.z and needle.z < hay.z+hay.d) 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 >= 10 then
|
||||||
|
timer=0
|
||||||
|
print("Updating")
|
||||||
|
|
||||||
|
for i=1,# privilegeareas.players do
|
||||||
|
print("player "..i)
|
||||||
|
privilegeareas.calculate_current_areas(privilegeareas.players[i].player)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_joinplayer(function(player)
|
||||||
|
privilegeareas.createPlayerTable(player)
|
||||||
|
end)
|
Loading…
Reference in New Issue