diff --git a/mods/main/init.lua b/mods/main/init.lua index 4d88bcb..d292383 100644 --- a/mods/main/init.lua +++ b/mods/main/init.lua @@ -125,8 +125,7 @@ core.register_on_mods_loaded(function() end) core.register_on_joinplayer(function(player) - core.place_schematic({x = 0, y = 0, z = 0}, core.get_modpath("main") .. "/schematics/map1.mts", 0, nil, false) - player:set_pos({x = 20, y = 26.5, z = 17}) + player:set_pos({x = map_data.spawn_x, y = map_data.spawn_y, z = map_data.spawn_z}) player:get_inventory():set_list("main", {}) local player_name = player:get_player_name() @@ -157,7 +156,7 @@ core.register_on_respawnplayer(function(player) local player_name = player:get_player_name() - player:set_pos({x = 20, y = 26.5, z = 17}) + player:set_pos({x = map_data.spawn_x, y = map_data.spawn_y, z = map_data.spawn_z}) player:get_inventory():set_list("main", {}) @@ -169,15 +168,12 @@ end) core.register_privilege("match_manager", {description = "Can manage the match", give_to_singleplayer = true}) core.register_chatcommand("start", { - params = "", + params = "", privs = {match_manager = true}, description = "Start the match", func = function() - for x = 1, 39 do - for z = 1, 36 do - core.set_node({x = x, y = 25, z = z}, {name = "air"}) - end - end + local map_data = place_map(map) + remove_barrier(x=map_data.size_x, y=map_data.barrier_level, z=map_data.size_z) core.chat_send_all(core.colorize("green", "Match started!")) alive_players = {} for _, player in pairs(core.get_connected_players()) do @@ -206,12 +202,10 @@ core.register_chatcommand("reset", { privs = {match_manager = true}, description = "Reset map", func = function() - core.place_schematic({x = 0, y = 0, z = 0}, core.get_modpath("main") .. "/schematics/map1.mts", 0, nil, false) for _, player in pairs(core.get_connected_players()) do local player_name = player:get_player_name() - player:set_nametag_attributes({color = {a = 255, r = 255, g = 255, b = 255}}) - player:set_pos({x = 20, y = 26.5, z = 17}) + player:set_pos({x = map_data.spawn_x, y = map_data.spawn_y, z = map_data.spawn_z}) set_player_mode(player, "normal") player:get_inventory():set_list("main", {}) player:set_properties({ diff --git a/mods/main/schematics/map1.mts b/mods/main/schematics/map1.mts deleted file mode 100644 index 0df74d2..0000000 Binary files a/mods/main/schematics/map1.mts and /dev/null differ diff --git a/mods/maps/init.lua b/mods/maps/init.lua new file mode 100644 index 0000000..0afe471 --- /dev/null +++ b/mods/maps/init.lua @@ -0,0 +1,15 @@ +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) + dofile(map_path .. map .. "/map.lua") + return map_data +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"}) + end + end + return "" +end diff --git a/mods/maps/maps/forest/map.lua b/mods/maps/maps/forest/map.lua new file mode 100644 index 0000000..c840570 --- /dev/null +++ b/mods/maps/maps/forest/map.lua @@ -0,0 +1,11 @@ +local map_data = { + size_x = 0, + size_y = 0, -- <- currently not used for anything + size_z = 0, + + barrier_level = 0, -- <- Y level of the barrier + + spawn_x = 0, + spawn_y = 0, + spawn_z = 0 +} diff --git a/mods/maps/maps/forest/map.mts b/mods/maps/maps/forest/map.mts new file mode 100644 index 0000000..ffe3954 Binary files /dev/null and b/mods/maps/maps/forest/map.mts differ diff --git a/mods/maps/maps/pine/map.lua b/mods/maps/maps/pine/map.lua new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/mods/maps/maps/pine/map.lua @@ -0,0 +1 @@ + diff --git a/mods/maps/maps/pine/map.mts b/mods/maps/maps/pine/map.mts new file mode 100644 index 0000000..28564dc Binary files /dev/null and b/mods/maps/maps/pine/map.mts differ diff --git a/mods/maps/maps/savanna/map.lua b/mods/maps/maps/savanna/map.lua new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/mods/maps/maps/savanna/map.lua @@ -0,0 +1 @@ + diff --git a/mods/maps/maps/savanna/map.mts b/mods/maps/maps/savanna/map.mts new file mode 100644 index 0000000..f3eb463 Binary files /dev/null and b/mods/maps/maps/savanna/map.mts differ diff --git a/mods/maps/mod.conf b/mods/maps/mod.conf new file mode 100644 index 0000000..a1af990 --- /dev/null +++ b/mods/maps/mod.conf @@ -0,0 +1,3 @@ +name = maps +description = Maps mod for simple-shooter-game +depends = main