Factorio userdata class name api
Posted: Wed Feb 28, 2018 8:26 pm
Although the new is_player api is a nice start, it would be much appreciated if we could just ask an arbitrary userdata object what its factorio API "class" name is, i.e.,:
Perhaps, somehow, modders can already create a big matrix of clever hacks to achieve the equivalent but why not make it easy?
This would be especially helpful for people tackling the initial learning curve of mod design like myself, as we are the ones who are most prone to get mixed up and lose the What The Heck Have I Got a Handle For Here? game.
Code: Select all
function pretty(thing)
if type(thing) == 'table' and thing.factorio_class then
return '[Factorio: ' .. thing.factorio_class .. ']'
else
...
end
end
print(pretty(game))
(output: [Factorio: LuaGameScript])
This would be especially helpful for people tackling the initial learning curve of mod design like myself, as we are the ones who are most prone to get mixed up and lose the What The Heck Have I Got a Handle For Here? game.