Compare commits
5 Commits
567b95fd6c
...
22865372bf
Author | SHA1 | Date |
---|---|---|
|
22865372bf | |
|
834bd5109b | |
|
2d4e1db097 | |
|
ca70e6ae5c | |
|
4c985f126f |
73
init.lua
|
@ -26,11 +26,11 @@ else
|
|||
S = function ( s ) return s end
|
||||
end
|
||||
|
||||
local hud_default_x=0.4
|
||||
local hud_default_y=0.01
|
||||
local hud_default_x=0.5
|
||||
local hud_default_y=0.8
|
||||
local hud_default_color="FFFF00"
|
||||
local compass_default_type="c"
|
||||
local compass_valid_types={"a","b","c"}
|
||||
local compass_valid_types={"a","b","c", "d"}
|
||||
local activewidth=8 --until I can find some way to get it from minetest
|
||||
local max_shared=10 --how many shared bookmarks a user with shared_bookmarks priv can make.
|
||||
local show_shared_on_singleplayer=false --show shared and admin checkboxes on singleplayer
|
||||
|
@ -468,6 +468,22 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
elseif fields["new_admin_bookmark"] then
|
||||
type="A"
|
||||
end --shared or admin
|
||||
|
||||
--lets limmit to 5 for normal users
|
||||
if type=="P" and not minetest.check_player_privs(player, {protection_bypass=true}) then
|
||||
local c=0
|
||||
for k,v in pairs(bookmarks) do
|
||||
if v.player and v.player==playername and v.type and v.type=="P" then
|
||||
c=c+1
|
||||
end --if
|
||||
end --for
|
||||
local limit = 5
|
||||
if c >= limit then
|
||||
minetest.chat_send_player(playername,S("You have reached the limit of " .. tostring(limit) .." bookmarks. Delete some records to be able to add a new one"))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
compassgps.set_bookmark(playername, fields["bookmark"],type)
|
||||
minetest.show_formspec(playername, compassgps.get_compassgps_formspec(playername))
|
||||
elseif fields["remove_bookmark"] and textlist_clicked[playername] then
|
||||
|
@ -563,6 +579,8 @@ minetest.register_on_player_receive_fields(function(player,formname,fields)
|
|||
compass_type[playername]="b"
|
||||
elseif fields["compass_type_c"] then
|
||||
compass_type[playername]="c"
|
||||
elseif fields["compass_type_d"] then
|
||||
compass_type[playername]="d"
|
||||
end --if fields["hud_pos"]
|
||||
elseif (playername ~= "" and formname == "compassgps:confirm_remove") then
|
||||
if fields["confirm_remove_yes"] then
|
||||
|
@ -640,7 +658,26 @@ function compassgps.clean_string(str)
|
|||
return str
|
||||
end --clean_string
|
||||
|
||||
local function locate( table, value )
|
||||
for i = 1, #table do
|
||||
if table[i] == value then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function check_is_inside_forbiden_area(pos)
|
||||
local table = {"fbd"}
|
||||
if areas then
|
||||
local areasAtPos = areas:getAreasAtPos(pos)
|
||||
for id, area in pairs(areasAtPos) do
|
||||
--minetest.chat_send_all(dump(area.name))
|
||||
if locate( table, area.name ) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function compassgps.set_bookmark(playername, bkmrkname, type, predefinedpos)
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
|
@ -649,6 +686,10 @@ function compassgps.set_bookmark(playername, bkmrkname, type, predefinedpos)
|
|||
end
|
||||
|
||||
local pos = player:getpos()
|
||||
|
||||
local is_forbiden = check_is_inside_forbiden_area(pos)
|
||||
if minetest.check_player_privs(player, {protection_bypass=true}) then is_forbiden = false end
|
||||
|
||||
if predefinedpos ~= nil then
|
||||
pos = predefinedpos
|
||||
end
|
||||
|
@ -662,6 +703,7 @@ function compassgps.set_bookmark(playername, bkmrkname, type, predefinedpos)
|
|||
return
|
||||
end
|
||||
if bkmrkname == "default" or bkmrkname == "bed" or bkmrkname == "sethome"
|
||||
or is_forbiden == true
|
||||
or string.sub(bkmrkname,1,8) == "*shared*"
|
||||
or string.sub(bkmrkname,1,7)=="*admin*" then
|
||||
minetest.chat_send_player(playername, S("A bookmark with the name '%s' can't be created."):format(bkmrkname))
|
||||
|
@ -824,7 +866,7 @@ function compassgps.teleport_bookmark(playername, bkmrkidx)
|
|||
compassgps.bookmark_name_string(textlist_bkmrks[playername][bkmrkidx])))
|
||||
minetest.chat_send_player(playername, S("Teleporting to %s"):format(
|
||||
compassgps.bookmark_name_string(textlist_bkmrks[playername][bkmrkidx])))
|
||||
player:setpos(textlist_bkmrks[playername][bkmrkidx])
|
||||
player:set_pos(textlist_bkmrks[playername][bkmrkidx])
|
||||
end --teleport_bookmark
|
||||
|
||||
|
||||
|
@ -1043,11 +1085,22 @@ minetest.register_globalstep(function(dtime)
|
|||
target=point_to[playername] --just to take up less space
|
||||
pos = player:getpos()
|
||||
dir = player:get_look_horizontal()
|
||||
|
||||
local angle_north = math.deg(math.atan2(target.x - pos.x, target.z - pos.z))
|
||||
if angle_north < 0 then angle_north = angle_north + 360 end
|
||||
local angle_dir = 90 - math.deg(dir)
|
||||
local angle_dir = -math.deg(dir)
|
||||
|
||||
local divisions = 12
|
||||
local angle_interval = 30
|
||||
local ctype = compass_type[playername]
|
||||
if ctype == "d" then -- for use of more frames
|
||||
angle_interval = 11.25
|
||||
divisions = 32
|
||||
end
|
||||
|
||||
local angle_relative = (angle_north - angle_dir) % 360
|
||||
local compass_image = math.floor((angle_relative/30) + 0.5)%12
|
||||
local compass_image = math.floor((angle_relative/angle_interval) + 0.5)%divisions
|
||||
--minetest.chat_send_all(compass_image)
|
||||
|
||||
|
||||
--update compass image to point at target
|
||||
|
@ -1086,7 +1139,7 @@ minetest.register_globalstep(function(dtime)
|
|||
|
||||
local compasstype=compass_default_type
|
||||
if compass_type[playername] and
|
||||
(compass_type[playername]=="a" or compass_type[playername]=="b" or compass_type[playername]=="c") then
|
||||
(compass_type[playername]=="a" or compass_type[playername]=="b" or compass_type[playername]=="c" or compass_type[playername]=="d") then
|
||||
compasstype=compass_type[playername]
|
||||
else
|
||||
compass_type[playername]=compass_default_type
|
||||
|
@ -1175,6 +1228,7 @@ end--spairs
|
|||
|
||||
function compassgps.get_compassgps_formspec(name)
|
||||
local player = minetest.get_player_by_name(name)
|
||||
if not player then return end
|
||||
local playerpos = player:getpos()
|
||||
--print("get_compassgps_formspec spawn="..compassgps.pos_to_string(store_spawn[name]))
|
||||
--local list = "default "..compassgps.pos_to_string(compassgps.get_default_pos_and_name(name))
|
||||
|
@ -1273,7 +1327,8 @@ function compassgps.get_settings_formspec(name)
|
|||
"label[1,1.5;"..S("Compass Type:").."]"..
|
||||
"image_button[3,1.5;1,1;compass_0.png;compass_type_a;]"..
|
||||
"image_button[4,1.5;1,1;compass_b0.png;compass_type_b;]"..
|
||||
"image_button[5,1.5;1,1;compass_c0.png;compass_type_c;]"
|
||||
"image_button[5,1.5;1,1;compass_c0.png;compass_type_c;]" ..
|
||||
"image_button[6,1.5;1,1;compass_d0.png;compass_type_d;]"
|
||||
|
||||
end --get_compassgps_formspec
|
||||
|
||||
|
@ -1284,7 +1339,7 @@ end --get_compassgps_formspec
|
|||
|
||||
local i
|
||||
--for i,img in ipairs(images) do
|
||||
for i=1,12 do
|
||||
for i=1,32 do
|
||||
for c,ctype in pairs(compass_valid_types) do
|
||||
local inv = 1
|
||||
if i == 1 and ctype=="a" then
|
||||
|
|
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 225 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 229 B |
After Width: | Height: | Size: 229 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 228 B |
After Width: | Height: | Size: 227 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |
After Width: | Height: | Size: 226 B |