Created
June 23, 2022 11:03
-
-
Save rubenwardy/e468515b740741fd4c7fac4a86577b07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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