1
0
mirror of https://gitlab.com/rubenwardy/awards.git synced 2024-12-29 12:10:38 +01:00

Fix playern variable bug

This commit is contained in:
Rubenwardy 2013-11-12 19:33:19 +00:00
parent 3a0bc67d1b
commit 6387bd1d9e
2 changed files with 9 additions and 7 deletions

View File

@ -35,10 +35,11 @@ end
-- A table of award definitions -- A table of award definitions
awards.def = {} awards.def = {}
function awards.tbv(tb,value,default) function awards.tbv(tb,value)
if not default then awards.tbv_default(tb,value,{})
default = {} end
end
function awards.tbv_default(tb,value,default)
if not tb or type(tb) ~= "table" then if not tb or type(tb) ~= "table" then
if not value then if not value then
value = "[NULL]" value = "[NULL]"

View File

@ -140,6 +140,7 @@ minetest.register_on_dieplayer(function(player)
if not player or not player:get_player_name() or player:get_player_name()=="" then if not player or not player:get_player_name() or player:get_player_name()=="" then
return return
end end
local playern = player:get_player_name()
awards.tbv(awards.players, playern ) awards.tbv(awards.players, playern )
awards.tbv(awards.players[playern], "name", playern ) awards.tbv(awards.players[playern], "name", playern )
awards.tbv(awards.players[playern], "deaths", 0 ) awards.tbv(awards.players[playern], "deaths", 0 )
@ -148,7 +149,6 @@ minetest.register_on_dieplayer(function(player)
awards.players[player:get_player_name()].deaths = awards.players[player:get_player_name()].deaths + 1 awards.players[player:get_player_name()].deaths = awards.players[player:get_player_name()].deaths + 1
-- Run callbacks and triggers -- Run callbacks and triggers
local playern=player:get_player_name()
local data=awards.players[playern] local data=awards.players[playern]
for i=1,# awards.onDeath do for i=1,# awards.onDeath do
local res=nil local res=nil
@ -179,8 +179,9 @@ minetest.register_on_dieplayer(function(player)
end) end)
minetest.register_on_newplayer(function(player) minetest.register_on_newplayer(function(player)
awards.tbv(awards.players, player:get_player_name()) local playern = player:get_player_name()
awards.tbv(awards.players[playern], "name", player:get_player_name()) awards.tbv(awards.players, playern)
awards.tbv(awards.players[playern], "name", playern)
awards.tbv(awards.players[playern], "unlocked") awards.tbv(awards.players[playern], "unlocked")
awards.tbv(awards.players[playern], "place") awards.tbv(awards.players[playern], "place")
awards.tbv(awards.players[playern], "count") awards.tbv(awards.players[playern], "count")