I think that this snippet might help other newbies like me who would like to develop a mod that has different behaviors when it knows you are offline and not on a [public] server.
In fact, minetest.get_server_info().ip would return a valid ip address - 127.0.0.1- even though you are in singleplayer because of its inner details and would not help.
The trick is to verify the username.
Code: Select all
local is_singleplayer = function()
return minetest.localplayer:get_name() == 'singleplayer'
end
local is_offline = is_singleplayer