lastplayer in stats

This commit is contained in:
BuckarooBanzay 2019-10-29 08:25:51 +01:00
parent 85cfb4b2e3
commit a7077c8aff

View File

@ -1,6 +1,8 @@
local update_formspec = function(meta)
local counter = meta:get_int("counter")
meta:set_string("infotext", "Visits: " .. counter)
local lastplayer = meta:get_string("lastplayer")
meta:set_string("infotext", "Visits: " .. counter ..
" Last player: ''" .. lastplayer .. "'")
meta:set_string("formspec", "size[8,2;]" ..
"label[0,0.5;Visits: " .. counter .. "]" ..
@ -25,6 +27,7 @@ minetest.register_node("epic:stats", {
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_int("counter", 0)
meta:set_string("lastplayer", "")
update_formspec(meta)
end,
@ -44,8 +47,9 @@ minetest.register_node("epic:stats", {
end,
epic = {
on_enter = function(_, meta, _, ctx)
on_enter = function(_, meta, player, ctx)
meta:set_int("counter", meta:get_int("counter") + 1)
meta:set_string("lastplayer", player:get_player_name())
update_formspec(meta)
ctx.next()
end