From caaf2481d25dcdb03cb8c4d7c957c546f8d5ce0b Mon Sep 17 00:00:00 2001 From: a-bad-dev <244852891+a-bad-dev@users.noreply.github.com> Date: Wed, 18 Feb 2026 01:32:27 -0400 Subject: [PATCH] Backport some features to not require 5.15.0+ Also decrease map load time --- mods/game/functions/init.lua | 6 +++--- mods/game/maps/init.lua | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mods/game/functions/init.lua b/mods/game/functions/init.lua index cc6db00..6f3d96a 100644 --- a/mods/game/functions/init.lua +++ b/mods/game/functions/init.lua @@ -115,13 +115,13 @@ function start_match(map) -- Start the match return end - set_match_state("pre_match") - map_data = place_map(map or "forest") -- default to forest if no map is specified if map_data == "nope :(" then return map_data end + + set_match_state("pre_match") local map_loading_images = {} for _, player in pairs(core.get_connected_players()) do @@ -143,7 +143,7 @@ function start_match(map) -- Start the match player:set_hp(20) end - core.after(5, function() + core.after(3, function() for _, player in pairs(core.get_connected_players()) do player:set_pos({x = map_data.spawn_x, y = map_data.spawn_y, z = map_data.spawn_z}) player:hud_remove(map_loading_images[player:get_player_name()]) diff --git a/mods/game/maps/init.lua b/mods/game/maps/init.lua index 1b31321..e79a033 100644 --- a/mods/game/maps/init.lua +++ b/mods/game/maps/init.lua @@ -1,13 +1,18 @@ -- Maps mod for SSG function place_map(map) - local map_path = core.get_modpath("maps") .. "/maps/" .. map .. "/" + local map_path = core.get_modpath("maps") .. "/maps/" + local map_list = core.get_dir_list(map_path, true) - if not core.path_exists(map_path) then - return "nope :(" + for i = 1, #map_list do + if map_list[i] == map then + break + elseif i == #map_list then + return "nope :(" + end end - local map_data = dofile(map_path .. "map.lua") - core.place_schematic({x=0, y=0, z=0}, map_path .. "map.mts", 0, nil, true) + local map_data = dofile(map_path .. map .. "/map.lua") + core.place_schematic({x=0, y=0, z=0}, map_path .. map .. "/map.mts", 0, nil, true) if map_data.spawn_x == nil or map_data.spawn_y == nil or map_data.spawn_z == nil then -- set a default spawnpoint if not set map_data.spawn_x = map_data.size_x / 2