Can you give .help() to all LuaObjects?

Post Reply
x2605
Inserter
Inserter
Posts: 41
Joined: Fri Jul 31, 2020 4:08 pm
Contact:

Can you give .help() to all LuaObjects?

Post 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?
English is not my native language. Sorry for bad English.
My mods :
Lua API global Variable Viewer (mod portal)
Lua API Event Trace (mod portal)
My tools :
Locale String Editor (github.io webapp)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.

x2605
Inserter
Inserter
Posts: 41
Joined: Fri Jul 31, 2020 4:08 pm
Contact:

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

Post 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))
English is not my native language. Sorry for bad English.
My mods :
Lua API global Variable Viewer (mod portal)
Lua API Event Trace (mod portal)
My tools :
Locale String Editor (github.io webapp)

x2605
Inserter
Inserter
Posts: 41
Joined: Fri Jul 31, 2020 4:08 pm
Contact:

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

Post 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.
English is not my native language. Sorry for bad English.
My mods :
Lua API global Variable Viewer (mod portal)
Lua API Event Trace (mod portal)
My tools :
Locale String Editor (github.io webapp)

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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().
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13171
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.

x2605
Inserter
Inserter
Posts: 41
Joined: Fri Jul 31, 2020 4:08 pm
Contact:

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

Post 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.
English is not my native language. Sorry for bad English.
My mods :
Lua API global Variable Viewer (mod portal)
Lua API Event Trace (mod portal)
My tools :
Locale String Editor (github.io webapp)

Post Reply

Return to “Implemented mod requests”