mirror of
https://codeberg.org/tenplus1/ambience.git
synced 2025-01-07 16:40:20 +01:00
add join/leave nil checks, use pairs for player loop
This commit is contained in:
parent
4acc464a8a
commit
f7d54237f6
10
init.lua
10
init.lua
@ -91,12 +91,16 @@ end
|
|||||||
|
|
||||||
-- setup table when player joins
|
-- setup table when player joins
|
||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
playing[player:get_player_name()] = {music = -1}
|
if player then
|
||||||
|
playing[player:get_player_name()] = {music = -1}
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- remove table when player leaves
|
-- remove table when player leaves
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
playing[player:get_player_name()] = nil
|
if player then
|
||||||
|
playing[player:get_player_name()] = nil
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
@ -197,7 +201,7 @@ minetest.register_globalstep(function(dtime)
|
|||||||
local tod = minetest.get_timeofday()
|
local tod = minetest.get_timeofday()
|
||||||
|
|
||||||
-- loop through players
|
-- loop through players
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in pairs(minetest.get_connected_players()) do
|
||||||
|
|
||||||
player_name = player:get_player_name()
|
player_name = player:get_player_name()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user