cleanup & doc
This commit is contained in:
parent
1b509437ea
commit
5c9f05dfe6
47
init.lua
47
init.lua
@ -3,29 +3,65 @@ pandorabox = {}
|
||||
|
||||
local MP = minetest.get_modpath("pandorabox_custom")
|
||||
|
||||
-- unknown item aliasing
|
||||
dofile(MP.."/alias.lua")
|
||||
|
||||
-- bucket and xp limitation
|
||||
if minetest.get_modpath("bucket") and minetest.get_modpath("xp_redo") then
|
||||
dofile(MP.."/onplace_restriction.lua")
|
||||
end
|
||||
|
||||
-- loot customization
|
||||
if minetest.get_modpath("loot") then
|
||||
dofile(MP.."/loot.lua")
|
||||
end
|
||||
|
||||
-- custom privs
|
||||
dofile(MP.."/privs.lua")
|
||||
|
||||
-- death message
|
||||
dofile(MP.."/death.lua")
|
||||
dofile(MP.."/travel.lua")
|
||||
|
||||
-- travel stuff
|
||||
dofile(MP.."/travel/travel.lua")
|
||||
|
||||
if minetest.get_modpath("jumpdrive") then
|
||||
-- limit jumpdrive travel
|
||||
dofile(MP.."/travel/jumpdrive.lua")
|
||||
|
||||
-- jumppoints (different energy requirements)
|
||||
dofile(MP.."/jumppoints.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("telemosaic") then
|
||||
-- limit telemosaic travel
|
||||
dofile(MP.."/travel/telemosaic.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("travelnet") then
|
||||
-- limit travelnet
|
||||
dofile(MP.."/travel/travelnet.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("skybox") then
|
||||
-- planetary skyboxes
|
||||
dofile(MP.."/skybox.lua")
|
||||
|
||||
-- fly check
|
||||
dofile(MP.."/fly.lua")
|
||||
end
|
||||
|
||||
-- item/nodes stats
|
||||
dofile(MP.."/stats.lua")
|
||||
|
||||
-- join priv set/revoke
|
||||
dofile(MP.."/join.lua")
|
||||
|
||||
-- no_announce priv
|
||||
dofile(MP.."/join_announce.lua")
|
||||
|
||||
-- craft overrides
|
||||
dofile(MP.."/crafts.lua")
|
||||
dofile(MP.."/ylimit.lua")
|
||||
|
||||
if minetest.get_modpath("technic") then
|
||||
dofile(MP.."/grinder.lua")
|
||||
@ -39,15 +75,16 @@ if minetest.get_modpath("mesecons_mvps") then
|
||||
dofile(MP.."/mvps_stopper.lua")
|
||||
end
|
||||
|
||||
-- join-limit bypass
|
||||
dofile(MP.."/userlimit.lua")
|
||||
|
||||
-- protected sethome
|
||||
dofile(MP.."/sethome.lua")
|
||||
|
||||
-- letters mod
|
||||
if minetest.get_modpath("letters") then
|
||||
dofile(MP.."/letters.lua")
|
||||
end
|
||||
|
||||
if minetest.get_modpath("jumpdrive") then
|
||||
dofile(MP.."/jumppoints.lua")
|
||||
end
|
||||
|
||||
--dofile(MP.."/drawers.lua")
|
||||
|
17
join.lua
17
join.lua
@ -18,20 +18,3 @@ minetest.register_on_joinplayer(function(player)
|
||||
|
||||
end)
|
||||
|
||||
old_send_join_message = minetest.send_join_message
|
||||
|
||||
minetest.send_join_message = function(player_name)
|
||||
if minetest.check_player_privs(player_name, { no_announce=true }) then
|
||||
return
|
||||
end
|
||||
old_send_join_message(player_name)
|
||||
end
|
||||
|
||||
old_send_leave_message = minetest.send_leave_message
|
||||
|
||||
minetest.send_leave_message = function(player_name, timed_out)
|
||||
if minetest.check_player_privs(player_name, { no_announce=true }) then
|
||||
return
|
||||
end
|
||||
old_send_leave_message(player_name, timed_out)
|
||||
end
|
||||
|
17
join_announce.lua
Normal file
17
join_announce.lua
Normal file
@ -0,0 +1,17 @@
|
||||
old_send_join_message = minetest.send_join_message
|
||||
|
||||
minetest.send_join_message = function(player_name)
|
||||
if minetest.check_player_privs(player_name, { no_announce=true }) then
|
||||
return
|
||||
end
|
||||
old_send_join_message(player_name)
|
||||
end
|
||||
|
||||
old_send_leave_message = minetest.send_leave_message
|
||||
|
||||
minetest.send_leave_message = function(player_name, timed_out)
|
||||
if minetest.check_player_privs(player_name, { no_announce=true }) then
|
||||
return
|
||||
end
|
||||
old_send_leave_message(player_name, timed_out)
|
||||
end
|
@ -33,19 +33,6 @@ jumpdrive.calculate_power = function(radius, distance, sourcePos, targetPos)
|
||||
return old_calculate_power(radius, distance, sourcePos, targetPos)
|
||||
end
|
||||
|
||||
local save_data = function()
|
||||
|
||||
local data = minetest.write_json(jumppoints, true);
|
||||
local path = minetest.get_worldpath().."/jumppoints.json";
|
||||
|
||||
local file = io.open( path, "w" );
|
||||
if( file ) then
|
||||
file:write(data);
|
||||
file:close();
|
||||
else
|
||||
print("[pandorabox_custom] Error: Savefile '" .. path .. "' could not be written.")
|
||||
end
|
||||
end
|
||||
|
||||
local load_data = function()
|
||||
local path = minetest.get_worldpath().."/jumppoints.json";
|
||||
@ -61,8 +48,8 @@ local load_data = function()
|
||||
|
||||
local count = 0
|
||||
for _, jumppoint in ipairs(jumppoints) do
|
||||
print("[pandorabox_custom] jumppoints '" .. jumppoint.name .. "', pos: " .. minetest.pos_to_string(jumppoint.pos) ..
|
||||
", radius: " .. jumppoint.radius)
|
||||
print("[pandorabox_custom] jumppoints '" .. jumppoint.name .. "', pos: " ..
|
||||
minetest.pos_to_string(jumppoint.pos) .. ", radius: " .. jumppoint.radius)
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
|
31
teleport_back.lua
Normal file
31
teleport_back.lua
Normal file
@ -0,0 +1,31 @@
|
||||
-- static spawn point
|
||||
local spawn_pos = minetest.setting_get_pos("static_spawnpoint")
|
||||
|
||||
-- check every few seconds if the player belongs to the current position
|
||||
-- if not, teleport them back to spawn
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
|
||||
if not spawn_pos then
|
||||
return
|
||||
end
|
||||
|
||||
-- every 2 seconds
|
||||
if timer < 2 then return end
|
||||
timer = 0
|
||||
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
|
||||
local pos = player:getpos()
|
||||
|
||||
-- check if player can travel there
|
||||
local can_travel, err_msg = pandorabox.can_travel(player, pos)
|
||||
if not can_travel then
|
||||
player:set_pos(spawn_pos)
|
||||
if err_msg then
|
||||
minetest.chat_send_player(player:get_player_name(), err_msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
138
travel.lua
138
travel.lua
@ -1,138 +0,0 @@
|
||||
local has_xp_redo_mod = minetest.get_modpath("xp_redo")
|
||||
|
||||
pandorabox.can_travel = function(player, pos)
|
||||
|
||||
if not has_xp_redo_mod then
|
||||
-- no xp system
|
||||
return true
|
||||
end
|
||||
|
||||
local req_xp = 0
|
||||
|
||||
if pos.y > 5000 then
|
||||
-- moon
|
||||
req_xp = 10000
|
||||
end
|
||||
|
||||
if pos.y > 6000 then
|
||||
-- asteroids
|
||||
req_xp = 20000
|
||||
end
|
||||
|
||||
if pos.y > 10000 then
|
||||
-- mars
|
||||
req_xp = 50000
|
||||
end
|
||||
|
||||
if pos.y > 17000 then
|
||||
-- warzone
|
||||
req_xp = 100000
|
||||
end
|
||||
|
||||
local playername = player:get_player_name()
|
||||
local xp = xp_redo.get_xp(playername)
|
||||
|
||||
if xp >= req_xp then
|
||||
return true
|
||||
else
|
||||
minetest.chat_send_player(playername, "You need " .. req_xp .. " xp to travel to world-height of " .. math.floor(pos.y))
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if minetest.get_modpath("jumpdrive") then
|
||||
jumpdrive.preflight_check = function(source, destination, radius, player)
|
||||
local has_landing_priv = minetest.check_player_privs(player, {jumpdrive_land=true})
|
||||
|
||||
-- check for height limit, only space travel allowed
|
||||
if destination.y > -20 and destination.y < 100 and not has_landing_priv then
|
||||
return { success=false, message="Atmospheric travel not allowed!" }
|
||||
end
|
||||
|
||||
-- check for upper limit
|
||||
if destination.y > 18000 then
|
||||
return { success=false, message="Region above 18k is reserved for now.." }
|
||||
end
|
||||
|
||||
if not pandorabox.can_travel(player, destination) then
|
||||
return { success=false, message="Jump failed" }
|
||||
end
|
||||
|
||||
-- everything ok
|
||||
return { success=true }
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("telemosaic") then
|
||||
local old_travel_allowed = telemosaic.travel_allowed
|
||||
|
||||
telemosaic.travel_allowed = function(player, src, dest)
|
||||
if not pandorabox.can_travel(player, dest) then
|
||||
return false
|
||||
else
|
||||
return old_travel_allowed(player, src, dest)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("travelnet") then
|
||||
travelnet.allow_travel = function( player_name, owner_name, network_name, station_name_start, station_name_target )
|
||||
|
||||
local has_override_priv = minetest.check_player_privs(player_name, { protection_bypass=true })
|
||||
if has_override_priv then
|
||||
return true
|
||||
end
|
||||
|
||||
local target_pos
|
||||
|
||||
if travelnet.targets[owner_name] and travelnet.targets[owner_name][network_name] and
|
||||
travelnet.targets[owner_name][network_name][station_name_target] then
|
||||
target_pos = travelnet.targets[owner_name][network_name][station_name_target].pos
|
||||
else
|
||||
-- error!
|
||||
return false
|
||||
end
|
||||
|
||||
if station_name_target and string.sub(station_name_target, 1, 3) == "(P)" then
|
||||
-- protected target
|
||||
if travelnet.targets[owner_name] and travelnet.targets[owner_name][network_name] and
|
||||
travelnet.targets[owner_name][network_name][station_name_target] then
|
||||
minetest.load_area(target_pos)
|
||||
if minetest.is_protected(target_pos, player_name) then
|
||||
minetest.chat_send_player(player_name, "This station is protected!")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- check xp
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
return pandorabox.can_travel(player, target_pos)
|
||||
end
|
||||
end
|
||||
|
||||
local spawn_pos = minetest.setting_get_pos("static_spawnpoint")
|
||||
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
|
||||
if not spawn_pos then
|
||||
return
|
||||
end
|
||||
|
||||
-- every 2 seconds
|
||||
if timer < 2 then return end
|
||||
timer = 0
|
||||
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
|
||||
local pos = player:getpos()
|
||||
-- check if y-height allowed with xp
|
||||
if not pandorabox.can_travel(player, pos) then
|
||||
player:set_pos(spawn_pos)
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
20
travel/jumpdrive.lua
Normal file
20
travel/jumpdrive.lua
Normal file
@ -0,0 +1,20 @@
|
||||
jumpdrive.preflight_check = function(source, destination, radius, playername)
|
||||
local has_landing_priv = minetest.check_player_privs(playername, {jumpdrive_land=true})
|
||||
|
||||
-- check for height limit, only space travel allowed
|
||||
if destination.y > -20 and destination.y < 100 and not has_landing_priv then
|
||||
return { success=false, message="Atmospheric travel not allowed!" }
|
||||
end
|
||||
|
||||
local player = minetest.get_player_by_name(playername)
|
||||
if player then
|
||||
-- player is online, check limits (non-automatic jump)
|
||||
local can_teleport, err_msg = pandorabox.can_teleport(player, destination)
|
||||
if not can_teleport then
|
||||
return { success=false, message="Jump failed: " .. (err_msg or "") }
|
||||
end
|
||||
end
|
||||
|
||||
-- everything ok
|
||||
return { success=true }
|
||||
end
|
13
travel/telemosaic.lua
Normal file
13
travel/telemosaic.lua
Normal file
@ -0,0 +1,13 @@
|
||||
local old_travel_allowed = telemosaic.travel_allowed
|
||||
|
||||
telemosaic.travel_allowed = function(player, src, dest)
|
||||
|
||||
local can_teleport, err_msg = pandorabox.can_teleport(player, dest)
|
||||
if not can_teleport then
|
||||
-- not allowed
|
||||
minetest.chat_send_player(player:get_player_name(), err_msg or "")
|
||||
return false
|
||||
else
|
||||
return old_travel_allowed(player, src, dest)
|
||||
end
|
||||
end
|
90
travel/travel.lua
Normal file
90
travel/travel.lua
Normal file
@ -0,0 +1,90 @@
|
||||
local has_xp_redo_mod = minetest.get_modpath("xp_redo")
|
||||
|
||||
-- current world height limit
|
||||
local max_height = 18000
|
||||
|
||||
|
||||
|
||||
-- generic travel check
|
||||
-- returns (success, error_message)
|
||||
pandorabox.can_travel = function(player, pos)
|
||||
|
||||
if pos.y > max_height then
|
||||
-- world height limit
|
||||
return false, "The area above " .. max_height .. " is reserved for future use, sorry..."
|
||||
end
|
||||
|
||||
if not has_xp_redo_mod then
|
||||
-- no xp system
|
||||
return true
|
||||
end
|
||||
|
||||
local req_xp = 0
|
||||
|
||||
if pos.y > 5000 then
|
||||
-- moon
|
||||
req_xp = 10000
|
||||
end
|
||||
|
||||
if pos.y > 6000 then
|
||||
-- asteroids
|
||||
req_xp = 20000
|
||||
end
|
||||
|
||||
if pos.y > 10000 then
|
||||
-- mars
|
||||
req_xp = 50000
|
||||
end
|
||||
|
||||
if pos.y > 17000 then
|
||||
-- warzone
|
||||
req_xp = 100000
|
||||
end
|
||||
|
||||
local playername = player:get_player_name()
|
||||
local xp = xp_redo.get_xp(playername)
|
||||
|
||||
if xp >= req_xp then
|
||||
return true
|
||||
else
|
||||
return false, "You need " .. req_xp .. " xp to travel to world-height of " .. math.floor(pos.y)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- teleport only check (for "walk-only" areas)
|
||||
-- returns (success, error_message)
|
||||
pandorabox.can_teleport = function(player, pos)
|
||||
|
||||
-- check if the player can travel there "by foot"
|
||||
local can_travel, err_msg = pandorabox.can_travel(player, pos)
|
||||
if not can_travel then
|
||||
return false, err_msg
|
||||
end
|
||||
|
||||
-- walk-only areas here
|
||||
|
||||
-- amun system
|
||||
-- x=10000, z=15000, y=9700
|
||||
-- system-radius=500
|
||||
-- sun-radius=250, planet-radius=100
|
||||
|
||||
local amun_sun_pos = { x=10000, z=15000, y=9700 }
|
||||
local distance = vector.distance(amun_sun_pos, pos)
|
||||
|
||||
if distance > 50 and distance < 800 then
|
||||
-- only allow teleporting in the center of the system
|
||||
return false, "Can't travel into Amun subspace-bubble!"
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
43
travel/travelnet.lua
Normal file
43
travel/travelnet.lua
Normal file
@ -0,0 +1,43 @@
|
||||
travelnet.allow_travel = function( player_name, owner_name, network_name, station_name_start, station_name_target )
|
||||
|
||||
local has_override_priv = minetest.check_player_privs(player_name, { protection_bypass=true })
|
||||
if has_override_priv then
|
||||
-- admin can go everywhere...
|
||||
return true
|
||||
end
|
||||
|
||||
-- extracted target pos
|
||||
local target_pos
|
||||
|
||||
-- sanity check
|
||||
if travelnet.targets[owner_name] and travelnet.targets[owner_name][network_name] and
|
||||
travelnet.targets[owner_name][network_name][station_name_target] then
|
||||
target_pos = travelnet.targets[owner_name][network_name][station_name_target].pos
|
||||
else
|
||||
-- error!
|
||||
return false
|
||||
end
|
||||
|
||||
-- protected target with "(P) name"
|
||||
if station_name_target and string.sub(station_name_target, 1, 3) == "(P)" then
|
||||
if travelnet.targets[owner_name] and travelnet.targets[owner_name][network_name] and
|
||||
travelnet.targets[owner_name][network_name][station_name_target] then
|
||||
|
||||
minetest.load_area(target_pos)
|
||||
if minetest.is_protected(target_pos, player_name) then
|
||||
minetest.chat_send_player(player_name, "This station is protected!")
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- check if player can teleport there
|
||||
local player = minetest.get_player_by_name(player_name)
|
||||
local can_teleport, err_msg = pandorabox.can_teleport(player, target_pos)
|
||||
|
||||
if err_msg then
|
||||
minetest.chat_send_player(player_name, err_msg)
|
||||
end
|
||||
|
||||
return can_teleport
|
||||
end
|
21
ylimit.lua
21
ylimit.lua
@ -1,21 +0,0 @@
|
||||
|
||||
-- 2018-08-23 y limit (reserved space)
|
||||
local timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
timer = timer + dtime
|
||||
|
||||
-- every 2 seconds
|
||||
if timer < 2 then return end
|
||||
timer = 0
|
||||
|
||||
for _,player in ipairs(minetest.get_connected_players()) do
|
||||
|
||||
local pos = player:getpos()
|
||||
|
||||
if pos.y > 18000 then
|
||||
player:setpos({x=pos.x, y=17950, z=pos.z})
|
||||
minetest.chat_send_player(player:get_player_name(), "The area above 18k is reserved for future use, sorry...")
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
Loading…
x
Reference in New Issue
Block a user