Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rubenwardy
Created June 23, 2022 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubenwardy/e468515b740741fd4c7fac4a86577b07 to your computer and use it in GitHub Desktop.
Save rubenwardy/e468515b740741fd4c7fac4a86577b07 to your computer and use it in GitHub Desktop.
-- 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