I'm making a selector engine for TPT lua (aka select every particle of type BCOL) and would like to know why a part of it isn't working. It should purely in theory work, however the code returns a different table to the one I am expecting.
See outtakes of the script, as well as faulty output, here: http://hastebin.com/winebupiza.lua (specifically lines 30-34 which produce a wrong table as seen in lines 41-43 and 45)
I don't know why you are getting any output at all. The first problem is that you are using {type="BCOL"} when really tpt.parts uses IDs, not names. Fixing that I do get the same problem as you. This is probably because tpt.parts[i] is a metatable, nothing inside of it is real so you can't use a reference to it or something idk. Change "found[#found+1] = tpt.parts[idx]" to something else, maybe just set it equal to idx. tpt.parts is a bit slow I think anyway.
@jacob1(View Post) The part before the (...) runs a filter which silently converts type="BCOL" into type=73 :D
Also, idx is a number while I would really like to fiddle about with the particle tables themselves... However, this *does* seem like a better approach overall.