set_filter implementation

Place to get help with not working mods / modding interface.
User avatar
FlyHigh
Long Handed Inserter
Long Handed Inserter
Posts: 55
Joined: Sun Jul 27, 2014 12:14 am
Contact:

set_filter implementation

Post 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 :)
>>> Maxwell R. Black <<<

Image


* * *
User avatar
prg
Filter Inserter
Filter Inserter
Posts: 947
Joined: Mon Jan 19, 2015 12:39 am
Contact:

Re: set_filter implementation

Post 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.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
Post Reply

Return to “Modding help”