mirror of
https://github.com/a-bad-dev/simple-shooter-game.git
synced 2026-06-09 12:26:29 +00:00
Fix lots of bugs
It mostly works now
This commit is contained in:
parent
dd5657c9ea
commit
34732c1f3a
2 changed files with 31 additions and 12 deletions
|
|
@ -167,30 +167,40 @@ end)
|
|||
|
||||
core.register_privilege("match_manager", {description = "Can manage the match", give_to_singleplayer = true})
|
||||
|
||||
core.register_chatcommand("start", {
|
||||
core.register_chatcommand("load", {
|
||||
params = "<map>",
|
||||
privs = {match_manager = true},
|
||||
description = "Start the match",
|
||||
description = "Load a map",
|
||||
func = function(_, param)
|
||||
map_data = place_map(param)
|
||||
for _, player in pairs(core.get_connected_players()) do
|
||||
local player_name = player:get_player_name()
|
||||
set_player_mode(player, "normal")
|
||||
player:set_nametag_attributes({color = {a = 0}})
|
||||
player:set_hp(20)
|
||||
|
||||
player:set_pos({x=map_data.spawn_x, y=map_data.spawn_y, z=map_data.spawn_z})
|
||||
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
core.register_chatcommand("start", {
|
||||
params = "",
|
||||
privs = {match_manager = true},
|
||||
description = "Start the match",
|
||||
func = function()
|
||||
remove_barrier(map_data.size_x, map_data.barrier_level, map_data.size_z)
|
||||
core.chat_send_all(core.colorize("green", "Match started!"))
|
||||
alive_players = {}
|
||||
for _, player in pairs(core.get_connected_players()) do
|
||||
local player_name = player:get_player_name()
|
||||
|
||||
set_player_mode(player, "normal")
|
||||
|
||||
player:set_nametag_attributes({color = {a = 0}})
|
||||
player:set_hp(20)
|
||||
player:set_pos({x=map_data.spawn_x, y=map_data.spawn_y, z=map_data.spawn_z})
|
||||
player:set_properties({
|
||||
pointable = true, -- allow players to be killable after the match starts
|
||||
})
|
||||
|
||||
inv = player:get_inventory()
|
||||
inv:add_item("main", "ctf_ranged:ak47_loaded")
|
||||
inv:add_item("main", "ctf_ranged:ammo 3")
|
||||
player:set_properties({
|
||||
pointable = true, -- allow players to be killable after the match starts
|
||||
})
|
||||
alive_players[player_name] = "alive"
|
||||
end
|
||||
return ""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,17 @@
|
|||
function place_map(map)
|
||||
local map_path = core.get_modpath("maps") .. "/maps/"
|
||||
core.place_schematic({x=0, y=0, z=0}, map_path .. map .. "/map.mts", 0, nil, false)
|
||||
local map_data = dofile(map_path .. map .. "/map.lua")
|
||||
|
||||
for x = 1, map_data.size_x do -- preset the area to air to avoid any problems with preexisting maps
|
||||
for y = 1, map_data.size_y do
|
||||
for z = 1, map_data.size_z do
|
||||
core.set_node({x=x, y=y, z=z}, {name = "air"}) -- maybe switch to core.bulk_set_node()?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
core.place_schematic({x=0, y=0, z=0}, map_path .. map .. "/map.mts", 0, nil, false)
|
||||
|
||||
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
|
||||
map_data.spawn_y = map_data.barrier_level + 1
|
||||
|
|
@ -15,7 +24,7 @@ end
|
|||
function remove_barrier(x, y, z)
|
||||
for node_x = 1, x do
|
||||
for node_z = 1, z do
|
||||
core.set_node({x=x, y=y, z=z}, {name = "air"})
|
||||
core.set_node({x = node_x - 1, y = y - 1, z = node_z - 1}, {name = "air"}) -- account for the fact that lua counts starting at 1... i think.... whatever, it works \_('_')_/
|
||||
end
|
||||
end
|
||||
return ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue