Use _naming_convention for ball custom variables
This commit is contained in:
parent
e61263c648
commit
2f71829390
@ -16,8 +16,8 @@ local ball = {
|
||||
static_save = false,
|
||||
},
|
||||
|
||||
p_name = nil,
|
||||
timer = 0, -- solo per farla beccare da block_league.get_ball
|
||||
_p_name = nil,
|
||||
_timer = 0, -- solo per farla beccare da block_league.get_ball
|
||||
|
||||
on_activate = function(self, staticdata, dtime)
|
||||
local ball_obj = self.object
|
||||
@ -61,7 +61,7 @@ function ball:attach(player)
|
||||
local p_name = player:get_player_name()
|
||||
local arena = arena_lib.get_arena_by_player(p_name)
|
||||
|
||||
self.p_name = p_name
|
||||
self._p_name = p_name
|
||||
|
||||
arena_lib.sound_play(p_name, "bl_crowd_cheer")
|
||||
block_league.HUD_ball_update(p_name, extS("You've got the ball!"), "0xabf877")
|
||||
@ -78,7 +78,7 @@ end
|
||||
|
||||
|
||||
function ball:reset()
|
||||
local p_name = self.p_name
|
||||
local p_name = self._p_name
|
||||
|
||||
-- annuncio
|
||||
arena_lib.sound_play(p_name, "bl_voice_ball_reset")
|
||||
@ -87,7 +87,7 @@ function ball:reset()
|
||||
local wielder = minetest.get_player_by_name(p_name)
|
||||
local ball_obj = self.object
|
||||
|
||||
self.p_name = nil
|
||||
self._p_name = nil
|
||||
wielder:set_physics_override({speed = block_league.SPEED})
|
||||
wielder:get_meta():set_int("bl_has_ball", 0)
|
||||
ball_obj:set_detach()
|
||||
|
@ -59,7 +59,6 @@ end
|
||||
----------------------------------------------
|
||||
|
||||
function remove_message(panel, field)
|
||||
|
||||
local old_msg = panel[field].text
|
||||
|
||||
minetest.after(3, function()
|
||||
|
@ -21,14 +21,13 @@ local ball = {
|
||||
use_texture_alpha = true,
|
||||
|
||||
textures = {"bl_ball_unclaimed.png"},
|
||||
timer_limit = 10,
|
||||
},
|
||||
|
||||
p_name = nil,
|
||||
team_id = nil,
|
||||
timer_bool = false,
|
||||
timer = 0,
|
||||
has_scored = false
|
||||
_p_name = nil,
|
||||
_team_id = nil,
|
||||
_timer_limit = 10,
|
||||
_timer_bool = false,
|
||||
_timer = 0
|
||||
}
|
||||
|
||||
|
||||
@ -36,14 +35,13 @@ local ball = {
|
||||
-- eseguito quando l'entità viene distrutta
|
||||
function ball:_destroy()
|
||||
self.object:remove()
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
|
||||
function ball:get_staticdata()
|
||||
if self == nil or self.arena == nil then return end
|
||||
return self.p_name
|
||||
return self._p_name
|
||||
end
|
||||
|
||||
|
||||
@ -51,7 +49,7 @@ end
|
||||
function ball:on_activate(staticdata, d_time)
|
||||
if staticdata ~= nil then
|
||||
|
||||
local id, arena = arena_lib.get_arena_by_name("block_league", staticdata)
|
||||
local _, arena = arena_lib.get_arena_by_name("block_league", staticdata)
|
||||
|
||||
if arena == nil or not arena.in_game then
|
||||
self:_destroy()
|
||||
@ -62,10 +60,10 @@ function ball:on_activate(staticdata, d_time)
|
||||
|
||||
local ball_obj = self.object
|
||||
|
||||
self.p_name = nil
|
||||
self.timer_bool = false
|
||||
self.team_id = nil
|
||||
self.timer = 0
|
||||
self._p_name = nil
|
||||
self._timer_bool = false
|
||||
self._team_id = nil
|
||||
self._timer = 0
|
||||
self.arena = arena
|
||||
|
||||
ball_obj:set_hp(65535)
|
||||
@ -91,11 +89,11 @@ function ball:on_step(d_time, moveresult)
|
||||
end
|
||||
|
||||
--se nessuno la sta portando a spasso...
|
||||
if self.p_name == nil then
|
||||
if self._p_name == nil then
|
||||
-- se il timer per il reset è attivo, controllo a che punto sta
|
||||
if self.timer_bool then
|
||||
self.timer = self.timer + d_time
|
||||
if self.timer > self.initial_properties.timer_limit then
|
||||
if self._timer_bool then
|
||||
self._timer = self._timer + d_time
|
||||
if self._timer > self._timer_limit then
|
||||
self:reset()
|
||||
return end
|
||||
end
|
||||
@ -114,7 +112,7 @@ function ball:on_step(d_time, moveresult)
|
||||
-- se ce l'ha qualcuno
|
||||
-- NB: se quel qualcuno è appena morto, al posto di controllarlo qui su ogni step, viene controllato sul callback della morte in player_manager.lua
|
||||
else
|
||||
local p_name = self.p_name
|
||||
local p_name = self._p_name
|
||||
local wielder = minetest.get_player_by_name(p_name)
|
||||
|
||||
-- se si è disconnesso
|
||||
@ -124,7 +122,7 @@ function ball:on_step(d_time, moveresult)
|
||||
end
|
||||
|
||||
local p_pos = wielder:get_pos()
|
||||
local goal = arena.teams[self.team_id].name == S("orange") and arena.goal_orange or arena.goal_blue
|
||||
local goal = arena.teams[self._team_id].name == S("orange") and arena.goal_orange or arena.goal_blue
|
||||
|
||||
check_for_touchdown(arena, self, p_name, p_pos, goal)
|
||||
end
|
||||
@ -136,8 +134,8 @@ function ball:attach(player)
|
||||
local arena = self.arena
|
||||
local p_name = player:get_player_name()
|
||||
|
||||
self.p_name = p_name
|
||||
self.team_id = arena.players[p_name].teamID
|
||||
self._p_name = p_name
|
||||
self._team_id = arena.players[p_name].teamID
|
||||
|
||||
self:announce_ball_possession_change()
|
||||
|
||||
@ -145,16 +143,16 @@ function ball:attach(player)
|
||||
block_league.stamina_drain(arena, p_name)
|
||||
|
||||
arena.players[p_name].points = arena.players[p_name].points + 2
|
||||
block_league.info_panel_update(arena, self.team_id)
|
||||
block_league.info_panel_update(arena, self._team_id)
|
||||
block_league.HUD_spectate_update(arena, p_name, "ball")
|
||||
|
||||
local ball_obj = self.object
|
||||
local team_texture = self.team_id == 1 and "bl_ball_orange.png" or "bl_ball_blue.png"
|
||||
local team_texture = self._team_id == 1 and "bl_ball_orange.png" or "bl_ball_blue.png"
|
||||
|
||||
ball_obj:set_attach(player, "Body", {x=0, y=18, z=0}, {x=0, y=0, z=0})
|
||||
|
||||
self.timer_bool = false
|
||||
self.timer = 0
|
||||
self._timer_bool = false
|
||||
self._timer = 0
|
||||
|
||||
ball_obj:set_properties({textures={team_texture}})
|
||||
ball_obj:set_animation({x=120,y=160}, 20, 0, true) -- smette di oscillare quando presa
|
||||
@ -169,7 +167,7 @@ end
|
||||
|
||||
|
||||
function ball:detach(skip_announcement)
|
||||
local p_name = self.p_name
|
||||
local p_name = self._p_name
|
||||
local player = minetest.get_player_by_name(p_name)
|
||||
local arena = self.arena
|
||||
|
||||
@ -186,9 +184,9 @@ function ball:detach(skip_announcement)
|
||||
|
||||
ball_obj:set_detach()
|
||||
|
||||
self.p_name = nil
|
||||
self.timer_bool = true
|
||||
self.timer = 0
|
||||
self._p_name = nil
|
||||
self._timer_bool = true
|
||||
self._timer = 0
|
||||
|
||||
ball_obj:set_properties({textures={"bl_ball_unclaimed.png"}})
|
||||
ball_obj:set_animation({x=0,y=40}, 20, 0, true)
|
||||
@ -204,8 +202,8 @@ function ball:reset()
|
||||
block_league.HUD_ball_update_all(arena, S("Ball reset"))
|
||||
|
||||
-- se è agganciata a qualcunə...
|
||||
if self.p_name then
|
||||
local wielder = minetest.get_player_by_name(self.p_name)
|
||||
if self._p_name then
|
||||
local wielder = minetest.get_player_by_name(self._p_name)
|
||||
|
||||
if wielder:get_hp() > 0 and wielder:get_meta():get_int("bl_is_speed_locked") == 0 then
|
||||
wielder:set_physics_override({speed = block_league.SPEED})
|
||||
@ -214,10 +212,10 @@ function ball:reset()
|
||||
self:detach(true)
|
||||
end
|
||||
|
||||
self.p_name = nil
|
||||
self.team_id = nil
|
||||
self.timer_bool = false
|
||||
self.timer = 0
|
||||
self._p_name = nil
|
||||
self._team_id = nil
|
||||
self._timer_bool = false
|
||||
self._timer = 0
|
||||
|
||||
self.object:set_pos(arena.ball_spawn)
|
||||
end
|
||||
@ -226,7 +224,7 @@ end
|
||||
|
||||
function ball:announce_ball_possession_change(is_ball_lost)
|
||||
local arena = self.arena
|
||||
local teamID = self.team_id
|
||||
local teamID = self._team_id
|
||||
local enemy_teamID = teamID == 1 and 2 or 1
|
||||
|
||||
if is_ball_lost then
|
||||
@ -241,7 +239,7 @@ function ball:announce_ball_possession_change(is_ball_lost)
|
||||
block_league.HUD_ball_update_team(arena, enemy_teamID, S("Enemy team has lost the ball!"), "0xabf877")
|
||||
|
||||
else
|
||||
local p_name = self.p_name
|
||||
local p_name = self._p_name
|
||||
block_league.HUD_log_update(arena, "bl_log_ball.png", p_name, "")
|
||||
|
||||
arena_lib.sound_play_team(arena, teamID, "bl_crowd_cheer")
|
||||
@ -369,7 +367,7 @@ minetest.register_entity("block_league:ball", ball)
|
||||
|
||||
function block_league.get_ball(player)
|
||||
for _, child in pairs (player:get_children()) do
|
||||
if child:get_luaentity() and child:get_luaentity().timer then
|
||||
if child:get_luaentity() and child:get_luaentity()._timer then
|
||||
return child:get_luaentity()
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user