Add even more new stuff

This commit is contained in:
IonicCheese 2026-02-19 11:53:10 -08:00
commit 42663612a2
4 changed files with 36 additions and 21 deletions

View file

@ -44,11 +44,10 @@ core.register_chatcommand("list_maps", {
privs = {match_manager = true}, privs = {match_manager = true},
description = "List all maps", description = "List all maps",
func = function() func = function()
local maps = core.get_dir_list(core.get_modpath("maps") .. "/maps", true) local list_string = "Available maps:\n"
local map_list = "Available maps:\n" for _, map in pairs(map_list) do
for _, map in pairs(maps) do list_string = list_string .. map .. "\n"
map_list = map_list .. map .. "\n"
end end
return true, map_list .. "\nUse /start <map> to start a match." return true, list_string .. "\nUse /start <map> to start a match."
end end
}) })

View file

@ -130,10 +130,10 @@ function start_match(map) -- Start the match
return return
end end
map_data = place_map(map or "forest") -- default to forest if no map is specified place_map(map or "forest") -- default to forest if no map is specified
if map_data == "nope :(" then if map_data == nil then
return map_data return "nope :("
end end
set_match_state("pre_match") set_match_state("pre_match")

View file

@ -1,7 +1,12 @@
-- Maps mod for SSG -- Maps mod for SSG
local map_path = core.get_modpath("maps") .. "/maps/"
map_data = {}
map_list = core.get_dir_list(map_path, true)
table.sort(map_list)
function place_map(map) function place_map(map)
local map_path = core.get_modpath("maps") .. "/maps/"
local map_list = core.get_dir_list(map_path, true)
local map_pos = vector.new(0, 0, 0) local map_pos = vector.new(0, 0, 0)
for i = 1, #map_list do for i = 1, #map_list do
@ -9,16 +14,18 @@ function place_map(map)
map_pos = vector.new(1000 * (i - 1), 0, 0) map_pos = vector.new(1000 * (i - 1), 0, 0)
break break
elseif i == #map_list then elseif i == #map_list then
return "nope :(" return nil
end end
end end
local map_data = dofile(map_path .. map .. "/map.lua") map_data = dofile(map_path .. map .. "/map.lua")
map_data.pos = map_pos map_data.pos = map_pos
core.place_schematic(map_pos, map_path .. map .. "/map.mts", 0, nil, true) core.place_schematic(map_pos, map_path .. map .. "/map.mts", 0, nil, true)
if not map_data.spawn then -- set a default spawnpoint if not set if not map_data.spawn then -- set a default spawnpoint if not set
map_data.spawn = vector.new(map_data.size.x / 2, map_data.barrier_level + 1, map_data.size.z / 2) + map_pos map_data.spawn = vector.new(map_data.size.x / 2, map_data.barrier_level + 1, map_data.size.z / 2) + map_pos
else
map_data.spawn = map_data.spawn + map_pos
end end
if map_data.start_time == nil or map_data.start_time <= 0 then if map_data.start_time == nil or map_data.start_time <= 0 then
@ -46,16 +53,15 @@ function place_map(map)
map_data.classes.class_3.initial_items = {"ctf_ranged:benelli_loaded", "ctf_ranged:glock17_loaded", "ctf_ranged:ammo 99"} map_data.classes.class_3.initial_items = {"ctf_ranged:benelli_loaded", "ctf_ranged:glock17_loaded", "ctf_ranged:ammo 99"}
map_data.classes.class_3.name = "Short-range" map_data.classes.class_3.name = "Short-range"
end end
return map_data
end end
function remove_barrier(x, y, z) -- name and arguments kept for backwards compat function remove_barrier()
for _, player in pairs(core.get_connected_players()) do for _, player in pairs(core.get_connected_players()) do
local pos = player:get_pos() local pos = player:get_pos()
player:set_pos({x=pos.x, y=map_data.barrier_level - 3.5, z=pos.z}) player:set_pos({x=pos.x, y=map_data.barrier_level - 3.5, z=pos.z})
end end
assert(loadstring(map_data.scripts.on_barrier_remove or ""))()
return "" if map_data.on_barrier_remove then
map_data.on_barrier_remove()
end
end end

View file

@ -2,13 +2,23 @@ return {
name = "mini-map", name = "mini-map",
size = vector.new(8, 19, 8), size = vector.new(8, 19, 8),
barrier_level = 15, -- This is a ridiculous hack to prevent players from teleporting into the ground..
barrier_level = 19,
spawn = nil, spawn = vector.new(4, 15, 4),
start_time = 15, start_time = 15,
on_start = nil, on_start = nil,
on_end = nil, on_end = nil,
on_barrier_remove = nil, on_barrier_remove = function()
local pos = map_data.pos
local size = map_data.size + pos
for x = pos.x + 1, size.x - 2 do
for z = pos.z + 1, size.z - 2 do
core.set_node(vector.new(x, 14, z), {name = "air"})
end
end
end,
} }