Page 1 of 1

[Solved] Need help with surface.find_entities_filtered

Posted: Sat Apr 09, 2016 6:04 pm
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.*

Re: Need help with surface.find_entities_filtered

Posted: Sat Apr 09, 2016 6:08 pm
by prg
It seems to return an empty table.

Re: Need help with surface.find_entities_filtered

Posted: Sat Apr 09, 2016 6:33 pm
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?)