Fix deprecated calls and cursed_world variable access (#5)

This commit is contained in:
smk 2021-05-10 23:21:52 +05:30 committed by GitHub
parent 1e07844d3f
commit c50d0aa303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
spawn_command = {} spawn_command = {}
spawn_command.pos = {x=0, y=3, z=0} spawn_command.pos = {x=0, y=3, z=0}
local cursed_world_exists = minetest.get_modpath("cursed_world")
if minetest.setting_get_pos("static_spawnpoint") then if minetest.setting_get_pos("static_spawnpoint") then
spawn_command.pos = minetest.setting_get_pos("static_spawnpoint") spawn_command.pos = minetest.setting_get_pos("static_spawnpoint")
@ -12,10 +13,10 @@ function teleport_to_spawn(name)
-- just a check to prevent the server crashing -- just a check to prevent the server crashing
return false return false
end end
local pos = player:getpos() local pos = player:get_pos()
if pos.x>-20 and pos.x<20 and pos.z>-20 and pos.z<20 then if pos.x>-20 and pos.x<20 and pos.z>-20 and pos.z<20 then
minetest.chat_send_player(name, "Already close to spawn!") minetest.chat_send_player(name, "Already close to spawn!")
elseif _G['cursed_world'] ~= nil and --check global table for cursed_world mod elseif cursed_world_exists and _G['cursed_world'] ~= nil and --check global table for cursed_world mod
cursed_world.location_y and cursed_world.dimension_y and cursed_world.location_y and cursed_world.dimension_y and
pos.y < (cursed_world.location_y + cursed_world.dimension_y) and --if player is in cursed world, stay in cursed world pos.y < (cursed_world.location_y + cursed_world.dimension_y) and --if player is in cursed world, stay in cursed world
pos.y > (cursed_world.location_y - cursed_world.dimension_y) pos.y > (cursed_world.location_y - cursed_world.dimension_y)
@ -23,10 +24,10 @@ function teleport_to_spawn(name)
--minetest.chat_send_player(name, "T"..(cursed_world.location_y + cursed_world.dimension_y).." "..(cursed_world.location_y - cursed_world.dimension_y)) --minetest.chat_send_player(name, "T"..(cursed_world.location_y + cursed_world.dimension_y).." "..(cursed_world.location_y - cursed_world.dimension_y))
local spawn_pos = vector.round(spawn_command.pos); local spawn_pos = vector.round(spawn_command.pos);
spawn_pos.y = spawn_pos.y + cursed_world.location_y; spawn_pos.y = spawn_pos.y + cursed_world.location_y;
player:setpos(spawn_pos) player:set_pos(spawn_pos)
minetest.chat_send_player(name, "Teleported to spawn!") minetest.chat_send_player(name, "Teleported to spawn!")
else else
player:setpos(spawn_command.pos) player:set_pos(spawn_command.pos)
minetest.chat_send_player(name, "Teleported to spawn!") minetest.chat_send_player(name, "Teleported to spawn!")
end end
end end