Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- Store a counter that increments each time a player joins
local file = minetest.get_worldpath().."/counter"
local f = io.open(file, "r")
if f==nil then
counter = 0
else
counter = tonumber(f:read("*all"))
f:close()
end
minetest.register_on_joinplayer(function(player)
counter = counter + 1
local f = io.open(file, "w")
f:write(counter)
f:close()
minetest.chat_send_all("Player "..player:get_player_name().." is player number "..counter.."!")
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment