Elements/prototypes should be enumerable

Things that already exist in the current mod API
Post Reply
robhol
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Sun May 11, 2014 9:57 pm
Contact:

Elements/prototypes should be enumerable

Post by robhol »

Either an iterator (not sure if this is possible?) or a method on Entity that exposes the "keys" would be a good idea in the absence of documentation. If it's a method, it'd also be nice to be able to filter the keys so that you only get the ones that are specific to that element.
窮屈そうに身を屈めても今じゃ誰もがそうしてる 天井の無いECHO ROOMに誰かが僕を放り込む
君のSPEEDでもって 同じPHRASEを弾いて 冷たい時に寄り添って

JLBShecky
Long Handed Inserter
Long Handed Inserter
Posts: 60
Joined: Mon Jul 21, 2014 5:27 pm
Contact:

Re: Elements/prototypes should be enumerable

Post by JLBShecky »

This would be one of the most useful things out there for working with the API as it stands.

At the moment most if you try using pairs to find out about an entity or object in the game, all you get back is __self with a data type of userdata which tells you nothing about the structure of the object or any game things it may expose. It seems that train.schedule works this way at the moment, but nothing else that I have found so far acts similarly.

slpwnd
Factorio Staff
Factorio Staff
Posts: 1835
Joined: Sun Feb 03, 2013 2:51 pm
Contact:

Re: Elements/prototypes should be enumerable

Post by slpwnd »

Not exactly the same thing, but try

Code: Select all

game.player.print(game.player.help())
The help() method should work for any rich lua object.

JLBShecky
Long Handed Inserter
Long Handed Inserter
Posts: 60
Joined: Mon Jul 21, 2014 5:27 pm
Contact:

Re: Elements/prototypes should be enumerable

Post by JLBShecky »

slpwnd wrote:Not exactly the same thing, but try

Code: Select all

game.player.print(game.player.help())
The help() method should work for any rich lua object.
I'll have to give that a try as soon as I get home. With it not being mentioned on the wiki, any I doubt that searching for "help" on the forums would ever give good results so I never even thought to try it.

If it tells me what I want to know I might be able to really make some headway without having to try and brute force everything by guessing possible method and property names that are not mentioned on the wiki. :D

Post Reply

Return to “Already exists”