Page 1 of 1

set_filter implementation

Posted: Fri Aug 12, 2016 11:20 am
by FlyHigh
I'm trying to implement a rail wagon that is restricted to a certain type of ore but I'm a noob at lua.

I'm messing with the stainless steal wagon mod just as a base, and tried to insert the line close to the example on the Wiki.

Code: Select all

wagon.set_filter(2, 'iron-ore')
in the entities.lua script which, as far as I understand, is where this line should go.
However i'm getting a 12: attempt to call field 'set_filter' (a nill value).

Anyone care to shed some light on it for me? Thank you :)

Re: set_filter implementation

Posted: Fri Aug 12, 2016 12:25 pm
by prg
entities.lua sounds like something that would be required from data.lua, which is not the place to call this function. Not sure what "wagon" would be in this context here.

set_filter() needs to be called on an entity reference, like in an on_built_entity event handler in control.lua.