Page 1 of 1

Can you give .help() to all LuaObjects?

Posted: Thu Sep 03, 2020 9:39 am
by x2605
I'm making a global variable viewer.
And it now have tree structure gui and can dig inside infinitely through tables and luaobjects having table-like properties.
And added a function to open directory of default global luaobjects too.

I'm using .help() method to get available property names for objects.

But not all objects are providing that. https://lua-api.factorio.com/latest/Common.html Yes, this link says, "not all".
I think there is no way to get property or function name programmatically.
Such as :

LuaBootstrap, LuaRemote, LuaCommandProcessor, LuaSettings, LuaRCON, LuaRendering
and
objects listed https://lua-api.factorio.com/latest/Concepts.html here

I can parse html contents by hand and put in my code, but it's not cool.
Can you give .help() method to all objects?

Re: Can you give .help() to all LuaObjects?

Posted: Thu Sep 03, 2020 3:58 pm
by Rseding91
.help() already works on all of LuaBootstrap, LuaRemote, LuaCommandProcessor, LuaSettings, LuaRCON, LuaRendering. Everything listed in https://lua-api.factorio.com/latest/Concepts.html is just basic tables; just iterate them to see what properties they have.

Re: Can you give .help() to all LuaObjects?

Posted: Fri Sep 04, 2020 2:33 am
by x2605
Rseding91 wrote:
Thu Sep 03, 2020 3:58 pm
.help() already works on all of LuaBootstrap, LuaRemote, LuaCommandProcessor, LuaSettings, LuaRCON, LuaRendering.
Are you sure?

Try this on base 1.0

Code: Select all

/c local a={game,script,remote,commands,settings,rcon,rendering} local fail={} for _,v in pairs(a) do local b,c=pcall(function() local d=v.help() end) if not b then table.insert(fail,', '..v.object_name) end end game.print(" following objects don't have help() !!! "..table.concat(fail))

Re: Can you give .help() to all LuaObjects?

Posted: Fri Sep 04, 2020 2:37 am
by x2605
Rseding91 wrote:
Thu Sep 03, 2020 3:58 pm
Everything listed in https://lua-api.factorio.com/latest/Concepts.html is just basic tables; just iterate them to see what properties they have.
And iterating the object in concepts such as

Code: Select all

/c for k,v in pairs(game.map_settings) do game.print(k) end
giving me only a __self key.

Re: Can you give .help() to all LuaObjects?

Posted: Fri Sep 04, 2020 5:47 am
by Rseding91
My mistake, they have the functions internally but don't expose them.

Also the one example you listed out of all the things in concepts not working is a LuaObject and has .help().

Re: Can you give .help() to all LuaObjects?

Posted: Fri Sep 04, 2020 5:49 am
by Rseding91
Also also, I don't get the point of wanting a .help() function when https://lua-api.factorio.com/latest/ exists and is far more detailed. You can't just arbitrarily access properties on objects without them being valid to call on that object so seeing a big list of things on something is kind of pointless.

Re: Can you give .help() to all LuaObjects?

Posted: Fri Sep 04, 2020 12:53 pm
by x2605
Rseding91 wrote:
Fri Sep 04, 2020 5:47 am
Also the one example you listed out of all the things in concepts not working is a LuaObject and has .help().

Nope. I can't access help function. May be in your source code, help is alive but something is overrided it.

Code: Select all

LuaMapSettings: unknown path help
stack traceback:
	(command):1: in function <(command):1>
	[C]: in function 'pcall'
	(command):1: in main chunk
As you said, most of contents in concepts page are just simple tables. But I can't access help function of remaining few objects.