I wrote a small function which retrieves the game name from the world.mt file, this works with standard secure settings in place and also works on first/initial load. Function will always return a value, currently set to "unknown" if name can't be found...which should only happen if the world.mt file structure changes significantly - but that could be changed to return nil or false:
Code: Select all
local function game_name()
local world = minetest.get_worldpath()
local file = io.open(world.."/world.mt", "r")
local game_name = "unknown"
for line in file:lines() do
if string.find(line, "gameid") then
game_name = string.match(line, "= (.*)")
file:close()
break
end
end
return game_name
end
local name_of_game = game_name()
Just putting this up in case someone else needs something similar in the future.