mirror of
https://github.com/a-bad-dev/simple-shooter-game.git
synced 2026-06-08 20:12:11 +00:00
65 lines
2.1 KiB
Lua
65 lines
2.1 KiB
Lua
-- Maps mod for SSG
|
|
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)
|
|
|
|
for i = 1, #map_list do
|
|
if map_list[i] == map then
|
|
map_pos = vector.new(1000 * (i - 1), 0, 0)
|
|
break
|
|
elseif i == #map_list then
|
|
return "nope :("
|
|
end
|
|
end
|
|
|
|
local map_data = dofile(map_path .. map .. "/map.lua")
|
|
map_data.pos = map_pos
|
|
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
|
|
map_data.spawn = vector.new(map_data.size.x / 2, map_data.barrier_level + 1, map_data.size.z / 2) + map_pos
|
|
end
|
|
|
|
if map_data.start_time == nil or map_data.start_time <= 0 then
|
|
map_data.start_time = 30
|
|
end
|
|
|
|
if map_data.classes == nil then
|
|
map_data.classes = {}
|
|
map_data.classes.class_1 = {}
|
|
map_data.classes.class_2 = {}
|
|
map_data.classes.class_3 = {}
|
|
end
|
|
|
|
if map_data.classes.class_1.initial_items == nil or map_data.classes.class_1.name == nil then
|
|
map_data.classes.class_1.initial_items = {"ctf_ranged:m200_loaded", "default:sword_stone", "ctf_ranged:ammo 99"}
|
|
map_data.classes.class_1.name = "Long-range"
|
|
end
|
|
|
|
if map_data.classes.class_2.initial_items == nil or map_data.classes.class_2.name == nil then
|
|
map_data.classes.class_2.initial_items = {"ctf_ranged:ak47_loaded", "ctf_ranged:glock17_loaded", "ctf_ranged:ammo 99"}
|
|
map_data.classes.class_2.name = "Mid-range"
|
|
end
|
|
|
|
if map_data.classes.class_3.initial_items == nil or map_data.classes.class_3.name == nil then
|
|
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"
|
|
end
|
|
|
|
|
|
return map_data
|
|
end
|
|
|
|
function remove_barrier()
|
|
for node_x = 1, x - 2 do
|
|
for node_z = 1, z - 2 do
|
|
core.set_node({x = node_x, y = y - 1, z = node_z}, {name = "air"}) -- account for the fact that lua counts starting at 1... i think.... whatever, it works \_('_')_/
|
|
end
|
|
end
|
|
if map_data.on_barrier_remove then
|
|
map_data.on_barrier_remove()
|
|
end
|
|
|
|
return ""
|
|
end
|