-- =================================================================== local function is_empty (s) if (s == nil) or (s == '') then return true end return false end -- =================================================================== local server_name = minetest.setting_get ("server_name") or "Unknown" local disable_multispawn = minetest.setting_getbool ("disable_multispawn" ) local disable_spawn = minetest.setting_getbool ("disable_spawn" ) local enable_bucket_city = minetest.setting_getbool ("enable_bucket_city" ) local edgylos = minetest.setting_getbool ("edgylos" ) local enable_moontest = minetest.setting_getbool ("enable_moon" ) or minetest.setting_getbool ("enable_moontest" ) -- =================================================================== minetest.register_privilege ("spawn", { description = "Enables shortcut teleport commands" }) local have_codersky = false if (rawget (_G, "codersky") ~= nil) and codersky ~= nil and codersky.update_skybox ~= nil then have_codersky = true end -- =================================================================== local function CloneTable (original) local copy = {} for k, v in pairs (original) do if type (v) == 'table' then v = CloneTable (v) end copy [k] = v end return copy end -- =================================================================== local warpnames = {} local function setwarp (warpname, fullname) if warpnames [warpname] ~= nil then return end warpnames [warpname] = true local s_point = "coderwarp_" .. warpname local s_pos = minetest.setting_get_pos (s_point) if s_pos == nil or s_pos == "" then s_point = "static_" .. warpname .. "_point" s_pos = minetest.setting_get_pos (s_point) if s_pos == nil or s_pos == "" then return end end minetest.register_chatcommand (warpname, { description = "Teleport to " .. warpname , params = "" , privs = { interact=true } , func = function (name, params) local key = warpname local player = minetest.env:get_player_by_name (name) local point = "coderwarp_" .. key local pos = minetest.setting_get_pos (point) if not pos then point = "static_" .. key .. "_point" pos = minetest.setting_get_pos (point) end if type (_G ['skyblock']) == "table" then if skyblock.feats and skyblock.feats.get_level and (warpname == "asteroid" or warpname == "asteroids" or warpname == "planetoid" or warpname == "planetoids" or warpname == "bron" or warpname == "tron") then local level = skyblock.feats.get_level (name) if level < 4 then minetest.chat_send_player (name, "You must be level 4 or above to use /" .. warpname) return false end end end if pos then minetest.chat_send_player (name, "Teleporting to " .. fullname) player:setpos (pos) if have_codersky then codersky.update_skybox (player) end return true else minetest.chat_send_player (name, "ERROR: " .. key .. " point isn't set on this server") return false end end }) end -- =================================================================== minetest.register_globalstep (function (dtime) if collectgarbage ("count") > 307200 then collectgarbage() end end) -- =================================================================== -- Misc. multi-world attractions. -- Note: These teleport points aren't necessarily present in all (or -- even most) worlds and they don't need to be. They're installed if -- and only if the world host adds appropriate "static_..._point" set- -- tings to "world.conf". setwarp ("bron" , "BRON Realm" ) setwarp ("tron" , "TRON Realm" ) setwarp ("airport" , "Airport" ) setwarp ("asteroid" , "Asteroids" ) setwarp ("asteroids" , "Asteroids" ) setwarp ("astro" , "Asteroids" ) setwarp ("bremen" , "Bremen" ) setwarp ("center" , "City Center" ) setwarp ("doll" , "Doll" ) setwarp ("earth" , "Earth" ) setwarp ("earth2" , "Earth 2" ) setwarp ("electric" , "Electric Mall" ) setwarp ("icecastle" , "Ice Castle" ) setwarp ("ironclad" , "The Ironclad" ) setwarp ("jose" , "Jose Town" ) setwarp ("krishna" , "Krishna Builds" ) setwarp ("loud" , "Loud Walking" ) setwarp ("market" , "Market" ) setwarp ("mothership" , "Mothership" ) setwarp ("oldspawn" , "Old Spawn" ) setwarp ("pcity" , "Planetoids" ) setwarp ("planetoid" , "Planetoids" ) setwarp ("planetoids" , "Planetoids" ) setwarp ("pixel" , "Pixel Art" ) setwarp ("pixels" , "Pixel Art" ) setwarp ("revival" , "Revival City" ) setwarp ("satellite" , "LOTT Satellite" ) setwarp ("silent" , "Silent Running" ) setwarp ("skyspawn" , "Sky Spawn" ) -- =================================================================== -- Mostly specific to AMHI. if server_name == "AMHI" then setwarp ("arena" , "Sky Arena" ) setwarp ("bouncy" , "Sky Bounce" ) setwarp ("hameer" , "Hameer Spawn" ) setwarp ("mesegarden" , "MeseGarden" ) setwarp ("oldspawn" , "Old Spawn" ) setwarp ("skygrid" , "SkyGrid platform" ) setwarp ("skyspot" , "SkySpot" ) setwarp ("square" , "Town Square" ) setwarp ("statue" , "Statue" ) setwarp ("survivalx" , "SurvivalX" ) end -- =================================================================== -- Mostly specific to BlockCity. setwarp ("apple" , "AppleTown" ) setwarp ("chloe" , "Chloe Town" ) setwarp ("hana" , "Hana Village" ) setwarp ("nightcity" , "NightCity" ) setwarp ("pharos" , "The Pharos" ) setwarp ("spider" , "Spider's Web" ) setwarp ("sunset" , "Sunset City" ) setwarp ("tie" , "Tie Fighter" ) -- =================================================================== -- Mostly specific to Legends of Dragons. if server_name == "Legends of Dragons" then setwarp ("chill" , "Chill Club" ) setwarp ("cliff" , "Cliff House" ) setwarp ("dark" , "Dark Castle" ) setwarp ("kastle" , "Kiwi's Castle" ) setwarp ("kiwifarm" , "Kiwi's Farm" ) setwarp ("megamall" , "Kiwi's MegaMall" ) setwarp ("pizzaria" , "Pizzaria" ) setwarp ("schichi" , "Bhoomika" ) setwarp ("vedic" , "Vedic City" ) end -- =================================================================== -- Mostly specific to Legends of Revival. setwarp ("iceland" , "Iceland" ) setwarp ("pvp" , "PVP Arena" ) setwarp ("rosierant" , "Rosie's Restaurant" ) -- =================================================================== -- Mostly specific to Legends of Survival. if edgylos then setwarp ("adam" , "Adam's Place" ) setwarp ("armenia" , "Armenia" ) setwarp ("bogdan" , "Bogdan 0575" ) setwarp ("bogdan0575" , "Bogdan 0575" ) setwarp ("newspawn" , "New Spawn" ) setwarp ("robocop" , "Robo LEO" ) setwarp ("ruslan1" , "Ruslan1's House" ) setwarp ("tinytrain" , "Tiny Train" ) setwarp ("village" , "Village" ) setwarp ("zetg" , "zetg place" ) setwarp ("zulfikar" , "Zulfikar's Place" ) end -- =================================================================== -- Mostly specific to MeseLite. if server_name == "MeseLite" then setwarp ("blocks" , "Blocks Museum" ) setwarp ("coderlab" , "CoderLab" ) setwarp ("dna" , "DNA Building" ) setwarp ("emperor" , "Emperor Point" ) setwarp ("lexi" , "Lexi Point" ) setwarp ("mesecity" , "MeseCity" ) setwarp ("rc" , "RC Point" ) setwarp ("rocket" , "Wan Rocket" ) setwarp ("yama" , "Yama Point" ) setwarp ("yaybay" , "Yay Bay" ) setwarp ("zip84" , "Zip84 Point" ) end -- =================================================================== -- Mostly specific to Minetest India. setwarp ("smkcity" , "SMK City" ) -- =================================================================== -- Mostly specific to MoneysWorld. if server_name == "MoneysWorld" or server_name == "Moneys World" then setwarp ("coolie" , "coolie base" ) setwarp ("hannah" , "Hannah Museum" ) setwarp ("k1tty" , "k1tty and light" ) setwarp ("mark123" , "Mark123 City" ) setwarp ("misuri" , "misuri City" ) setwarp ("rnr" , "RnR Deep Mine" ) setwarp ("seojun" , "seo_jun City" ) setwarp ("seo_jun" , "seo_jun City" ) setwarp ("tbhotel" , "T0MB0Y Hotel" ) end -- =================================================================== -- Mostly specific to Moontest. if server_name == "Moontest" then setwarp ("moon" , "Moon" ) setwarp ("nerdstation" , "CompuNerd Station" ) setwarp ("pumpkin" , "The Great Pumpkin" ) end -- =================================================================== -- Mostly specific to MustTest. if server_name == "MustTest" then setwarp ("bigcat" , "Giant Cat Plushie" ) setwarp ("mistyhotel" , "MistyStar Hotel" ) setwarp ("mistystar" , "MistyStar Place" ) end -- =================================================================== -- Mostly specific to Nyan RedIce. setwarp ("atlantis" , "Atlantis" ) setwarp ("corner" , "Corner of World" ) setwarp ("lulu" , "lulululu offices" ) setwarp ("oddsymbol" , "Odd Symbol" ) setwarp ("palmcove" , "Palm Cove" ) setwarp ("pierre" , "Pierre's Mines" ) setwarp ("ramor" , "Ramor's Room" ) setwarp ("skybase" , "Sky Base" ) setwarp ("walle" , "Big Robot" ) setwarp ("wallee" , "Big Robot" ) -- =================================================================== setwarp ("mauvebic" , "Mauvebic City" ) setwarp ("russharbor" , "Russian Harbor" ) setwarp ("russian" , "Russian Harbor" ) setwarp ("bremen" , "Bremen" ) setwarp ("bucket" , "Bucket City" ) setwarp ("bucketcity" , "Bucket City" ) setwarp ("hometown" , "HomeTown" ) setwarp ("karsthafen" , "Karsthafen" ) setwarp ("leyadel" , "Leyadel" ) setwarp ("liberty" , "Statue of Liberty" ) setwarp ("shadow" , "Shadow City" ) setwarp ("shadowcity" , "Shadow City" ) setwarp ("shadownet" , "ShadowNet Central" ) setwarp ("sonos" , "SONOS Capitol" ) setwarp ("stadium" , "Veritas Stadium" ) setwarp ("nyc" , "NYC Times Square" ) setwarp ("timesquare" , "NYC Times Square" ) setwarp ("timessquare" , "NYC Times Square" ) setwarp ("ussent" , "NYC USS Enterprise" ) -- =================================================================== -- Mostly specific to SkyDoom. setwarp ("juju" , "juju base" ) setwarp ("lexi" , "Lexi Land" ) setwarp ("majora" , "Majestic Majora" ) setwarp ("nubshop" , "NubRekkor shop" ) setwarp ("panda" , "Panda Point" ) setwarp ("pandawars" , "Panda Wars" ) setwarp ("reddevil" , "RedDevil island" ) setwarp ("savage" , "Savage Center" ) setwarp ("yayyer" , "Yayyer Center" ) setwarp ("wan" , "Wan T1" ) -- =================================================================== -- Mostly specific to Linuxworks Original. setwarp ("apartments" , "Apartments" ) setwarp ("bernhard" , "Bernhard" ) setwarp ("bernhardd" , "Bernhard" ) setwarp ("bluespawn" , "Blue Spawn" ) setwarp ("bremerhaus" , "Bremerhaus" ) setwarp ("cremek" , "Cremek" ) setwarp ("cricket" , "Cricket" ) setwarp ("elpo" , "Elpo" ) setwarp ("fanny" , "Fanny" ) setwarp ("newspawn" , "New Spawn" ) setwarp ("scottish" , "Scottish" ) setwarp ("shanielle" , "Shanielle" ) setwarp ("steve" , "Steve" ) setwarp ("trump" , "Trumpleton" ) setwarp ("trumpcity" , "Trumpleton" ) setwarp ("trumpleton" , "Trumpleton" ) -- =================================================================== -- Bucket City points of interest. setwarp ("angkor" , "Angkor Wat" ) setwarp ("angkorwat" , "Angkor Wat" ) setwarp ("angkorcross" , "Angkor Wat at Cross" ) setwarp ("angkorhigh" , "Angkor Wat High Plaza" ) setwarp ("apartment" , "Apartment Block" ) setwarp ("babylon" , "Hanging Gardens of Babylon" ) setwarp ("bighouse" , "Big Manor House" ) setwarp ("building" , "Strange Unfinished Building" ) setwarp ("challenge" , "Community Challenge" ) setwarp ("citadel" , "The Citadel" ) setwarp ("bigtemple" , "Huge Temple" ) setwarp ("hugetemple" , "Huge Temple" ) setwarp ("templecat" , "Temple of the Cat" ) setwarp ("templelight" , "Temple of Light and Dark" ) setwarp ("templewell" , "Temple of the Sacred Well" ) setwarp ("empty" , "Empty Town Garden" ) setwarp ("emptygarden" , "Empty Town Garden" ) setwarp ("farm" , "Farm of No Harm" ) setwarp ("forum" , "The Minetest Forum" ) setwarp ("gardencastle" , "Garden Castle" ) setwarp ("house1" , "House of Mysteries" ) setwarp ("house2" , "House of Secrets" ) setwarp ("house3" , "House of Lazy Sunday" ) setwarp ("house01" , "House of Mysteries" ) setwarp ("house02" , "House of Secrets" ) setwarp ("house03" , "House of Lazy Sunday" ) setwarp ("kiosk" , "The Kiosk" ) setwarp ("nother" , "Nother Castle" ) setwarp ("palace" , "Buckinghuge Castle" ) setwarp ("picnic" , "Public Picnic Grounds" ) setwarp ("ranger" , "Ranger's Outpost" ) setwarp ("tavern" , "Terry's Tavern" ) setwarp ("tinyfort" , "Tiny Fort" ) setwarp ("townhall" , "Town Hall" ) setwarp ("village" , "The Village" ) setwarp ("beata" , "Villa Beata" ) setwarp ("villa" , "Villa Beata" ) setwarp ("bluecottage" , "Blue Cottage" ) setwarp ("clubhouse" , "Clubhouse" ) setwarp ("decotower" , "Deco Tower" ) setwarp ("desertmotel" , "Desert Motel" ) setwarp ("diagonal" , "Diagonal Development" ) setwarp ("dyersguild" , "Dyer's Guild" ) setwarp ("grandhall" , "Grand Hall" ) setwarp ("poshdining" , "Posh Restaurant" ) setwarp ("romanfort" , "Roman Fort" ) setwarp ("stardome" , "The Stardome" ) setwarp ("wizardskeep" , "Wizard's Keep" ) -- Possibly temporary aliases: -- setwarp ("cottage" , "Blue Cottage" ) setwarp ("dyers" , "Dyer's Guild" ) setwarp ("fort" , "Roman Fort" ) setwarp ("motel" , "Desert Motel" ) -- =================================================================== -- Other worlds. setwarp ("stampy" , "Stampy City" ) -- =================================================================== local static_spawn_point = minetest.settings:get ("coderwarp_spawn" ) or minetest.settings:get ("static_spawn_point" ) or minetest.settings:get ("static_spawnpoint" ) if is_empty (static_spawn_point) then ocutil.log ("static_spawn_point is empty") else ocutil.log ("static_spawn_point is " .. static_spawn_point) disable_multispawn = true end -- =================================================================== local teleport_to_spawn = nil if disable_multispawn and not disable_spawn then teleport_to_spawn = function (name) if is_empty (static_spawn_point) then return false end local pos = minetest.string_to_pos (static_spawn_point) if pos ~= nil then local player = minetest.env:get_player_by_name (name) player:setpos (pos) if have_codersky then codersky.update_skybox (player) end return true end return false end minetest.register_chatcommand ("spawn", { description = "Teleport to spawnpoint" , privs = {} , func = function (name) teleport_to_spawn (name) end }) end -- =================================================================== if not disable_multispawn then spawnpoints = {} spawnpoints.list = { cid = 1 , } -- =================================================================== local function load_spawns() local f = io.open (minetest.get_worldpath() .. "/spawnpoints", "r") if not f then minetest.log ("action", "[coderwarp] Missing spawn data [1]") return end spawnpoints.list = minetest.deserialize (f:read ("*a")) f:close() end -- =================================================================== local function save_spawns() local f = io.open (minetest.get_worldpath() .. "/spawnpoints", "w") if not f then return end f:write (minetest.serialize (spawnpoints.list)) f:close() end -- =================================================================== teleport_to_spawn = function (pname, id) if #spawnpoints.list == 0 then minetest.chat_send_player (pname, "Sorry, there are no spawns set") minetest.log ("action", "[coderwarp] Missing spawn data [2]") return end local spawn = nil if id ~= nil then for _, spwn in ipairs (spawnpoints.list) do if spwn.id == id then spawn = spwn break end end else id = math.floor (math.random() * #spawnpoints.list) + 1 minetest.chat_send_player (pname, "Teleporting to spawn #" .. id) spawn = spawnpoints.list [id] end if not spawn then minetest.chat_send_player (pname, "Sorry, spawn #" .. id .. " doesn't exist") minetest.log ("action", "[coderwarp] Missing spawn data [3]") return end local player = minetest.get_player_by_name(pname) player:setpos (spawn) if have_codersky then codersky.update_skybox (player) end end -- =================================================================== minetest.register_chatcommand ("spawn", { params = "[id]", description = "Teleport to spawnpoint", privs = {}, func = function(name, param) local id = tonumber(param) if id == nil then teleport_to_spawn (name) else teleport_to_spawn (name, id) end end, }) -- =================================================================== local tb_addspawn = { params = " ", description = "Add a spawnpoint", privs = {basic_privs=true}, func = function(name, param) local x, y, z = param:match ('(.-) (.-) (.*)') x = tonumber (x) y = tonumber (y) z = tonumber (z) if not x or not y or not z then x, y, z = param:match ('(.-) *, *(.-) *, *(.*)') x = tonumber (x) y = tonumber (y) z = tonumber (z) if not x or not y or not z then minetest.chat_send_player (name, "Invalid coordinates") return end end spawnpoints.list [#spawnpoints.list + 1] = { x=x, y=y, z=z, id=spawnpoints.list.cid } local id = spawnpoints.list.cid spawnpoints.list.cid = spawnpoints.list.cid + 1 minetest.chat_send_player (name, "Created new spawnpoint. ID: " .. id) save_spawns() end , } minetest.register_chatcommand ("add_spawn" , tb_addspawn) minetest.register_chatcommand ("addspawn" , tb_addspawn) -- =================================================================== local tb_delspawn = { params = "", description = "Delete a spawnpoint", privs = { basic_privs=true } , func = function (name, param) local id = tonumber (param) if not id then minetest.chat_send_player (name, "Invalid ID") return end local del = false local newlist = {} for i, sp in ipairs (spawnpoints.list) do if sp.id == id then del = true else newlist [#newlist + 1] = CloneTable (spawnpoints.list [i]) end end newlist.cid = spawnpoints.list.cid spawnpoints.list = newlist if del then minetest.chat_send_player (name, "Deleted spawnpoint #" .. id) save_spawns() else minetest.chat_send_player(name, "There was no spawnpoint #" .. id) end end , } minetest.register_chatcommand ("del_spawn" , tb_delspawn) minetest.register_chatcommand ("delspawn" , tb_delspawn) minetest.register_chatcommand ("delete_spawn" , tb_delspawn) minetest.register_chatcommand ("deletespawn" , tb_delspawn) minetest.register_chatcommand ("rm_spawn" , tb_delspawn) minetest.register_chatcommand ("rmspawn" , tb_delspawn) -- =================================================================== local tb_listspawns = { params = "", description = "List spawnpoints" , privs = {}, func = function (name, param) for _, sp in ipairs (spawnpoints.list) do local str = minetest.pos_to_string (sp) .. " #" .. sp.id minetest.chat_send_player (name, str) end end , } minetest.register_chatcommand ("list_spawn" , tb_listspawns) minetest.register_chatcommand ("listspawn" , tb_listspawns) minetest.register_chatcommand ("list_spawns" , tb_listspawns) minetest.register_chatcommand ("listspawns" , tb_listspawns) -- =================================================================== load_spawns() end -- =================================================================== if teleport_to_spawn ~= nil then minetest.register_on_newplayer (function (player) teleport_to_spawn (player:get_player_name()) return true end) minetest.register_on_respawnplayer (function (player) teleport_to_spawn (player:get_player_name()) return true end) end -- =================================================================== ocutil.log ("[coderwarp] Mod loaded. server_name is: " .. server_name) -- =================================================================== -- End of file.