[Solved] Need help with surface.find_entities_filtered

Place to get help with not working mods / modding interface.
Mengmoshu
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Tue May 26, 2015 11:24 pm
Contact:

[Solved] Need help with surface.find_entities_filtered

Post by Mengmoshu »

What does surface.find_entities_filtered return if it didn't find anything? I'm trying to check if a search area contains any entities of type="resource", and checking if the returned table ~= nil didn't work.

Please let me know if there's more info I can add. I've attached the mod, sorry if it seems messy. The place I'm having trouble with is around line 74 of the control.lua.

*Edit: Added [Solved] to subject.*
Attachments
Resource_Relocation_Machine_0.0.1.zip
(32.74 KiB) Downloaded 56 times
Last edited by Mengmoshu on Sun Apr 10, 2016 3:36 am, edited 1 time in total.

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

Re: Need help with surface.find_entities_filtered

Post by prg »

It seems to return an empty table.
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!

Mengmoshu
Long Handed Inserter
Long Handed Inserter
Posts: 53
Joined: Tue May 26, 2015 11:24 pm
Contact:

Re: Need help with surface.find_entities_filtered

Post by Mengmoshu »

Thanks. Your info and a quick google search solved my problem I'm now doing something like:

Code: Select all

if next(myTable) == nil then
   -- myTable is empty
end
I got the advice here: http://stackoverflow.com/questions/1252 ... no-entries

That was the last piece of code that needed to work to make the one feature of my mod. I might post in the WIP forum with what I've got, even though it's ugly in so many ways.

Edit: (This is solved, can I change the thread title to add [solved] to it?)

Post Reply

Return to “Modding help”