TheBridge/the_bridge.lua

89 lines
2.6 KiB
Lua
Raw Normal View History

2022-10-03 12:30:47 +02:00
local S = minetest.get_translator("the_bridge")
local function after_goal(arena)
local players_team_red = arena_lib.get_players_in_team(arena, team_id_red, true)
local players_team_blue = arena_lib.get_players_in_team(arena, team_id_blue, true)
for player_index in ipairs(players_team_red) do
local player = players_team_red[player_index]
player:set_hp(20)
player:set_pos(arena_lib.get_random_spawner(arena, team_id_red))
end
for player_index in ipairs(players_team_blue) do
local player = players_team_blue[player_index]
player:set_hp(20)
player:set_pos(arena_lib.get_random_spawner(arena, team_id_blue))
end
end
local goalfunc = function(pos, node, player)
if not player then return end
arena = arena_lib.get_arena_by_player(player:get_player_name())
if not arena then return end
nodename = node.name
if nodename == "the_bridge:goal_area_red" then
arena.teams[team_id_red].goals = arena.teams[team_id_red].goals +1
if arena.teams[team_id_red].goals >= 5 and arena.in_game then
arena_lib.load_celebration("the_bridge", arena, team_id_red)
return
end
after_goal(arena)
elseif nodename == "the_bridge:goal_area_blue" then
arena.teams[team_id_blue].goals = arena.teams[team_id_blue].goals +1
if arena.teams[team_id_blue].goals >= 5 and arena.in_game then
arena_lib.load_celebration("the_bridge", arena, team_id_blue)
return
end
after_goal(arena)
end
end
-- __________________
--__________________/Node Registration\____________
minetest.register_node("the_bridge:goal_area_red",{
description = S("Red Goal"),
drawtype = "glasslike",
tiles = {"^[colorize:#d9405e"},
paramtype = "light",
sunlight_propagates = true,
walkable = true,
pointable = true,
diggable = false,
buildable_to = false,
drop = "",
on_walk_over=goalfunc,
})
minetest.register_node("the_bridge:goal_area_blue",{
description = S("Blue Goal"),
drawtype = "glasslike",
tiles = {"^[colorize:#3548da"},
paramtype = "light",
sunlight_propagates = true,
walkable = true,
pointable = true,
diggable = false,
buildable_to = false,
drop = "",
on_walk_over=goalfunc,
})
minetest.register_node("the_bridge:void", {
description = S("The Bridge void"),
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = true,
pointable = true,
diggable = false,
buildable_to = false,
drop = "",
damage_per_second = 40,
})