offline and online, singleplayer or not

Post Reply
User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

offline and online, singleplayer or not

by aristotle » Post

My 2 cents (really just 1)

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
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests