Search found 13 matches

by Strutyk
Sun May 08, 2016 12:23 pm
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

Thank you all very much for help with tips and code, you helped me alot! Hoping the practice will come to understand where best to use what code :)
by Strutyk
Sun May 08, 2016 11:43 am
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

Maybe I need to use debug (memory usage, graphics, etc.), and then it will be clear which code is more appropriate for my situation?
by Strutyk
Sun May 08, 2016 11:37 am
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

Yep, mansPool is manual control - the number of objects on the screen - less than the size of the pool.
Second pool for dynamically added objects :)
by Strutyk
Sun May 08, 2016 10:57 am
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

Yes this function is not remove man from pool. In my project I have two pool. In the first pool objects are added and removed. In the second poll objects are active, inactive. function checkActive() used for the second pool. But I have my doubts, when using this function. Is there a better option fo...
by Strutyk
Sun May 08, 2016 10:00 am
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

Today, I feel better and understood :awesome: But I have a question. Is this good practice use this function to check? function checkActive() rand = mansPool[math.random(#mansPool)] if rand.active == true then return checkActive() end randName = rand.name rand.active = true table.insert(mansArray, r...
by Strutyk
Sat May 07, 2016 10:51 pm
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

I'll try to explain. I have four characters. Every 3 seconds a random character is taken from mansPool Then the chosen random character gets to mansArray and removed from mansPool Then a random character moves. When it reaches a certain point - is removed from the mansArray and is added back into th...
by Strutyk
Sat May 07, 2016 9:50 pm
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

my update function: timer = timer + (1 * dt) if timer >= 3 then timer = 0 rand = mansPool[math.random(#mansPool)] table.insert(mansArray, rand) end for i = 1, #mansPool do if mansPool[i] == rand then table.remove(mansPool, i) break end end for i, man in ipairs(mansArray) do man.X = man.X - 128 * dt ...
by Strutyk
Sat May 07, 2016 8:54 pm
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

pgimeno - Thank you! The 'picture' has cleared up a bit, but now I can't correctly add a remote object in mansPool a table :o:
by Strutyk
Sat May 07, 2016 6:00 pm
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Re: Objects table(active/inactive) - removing and adding

Now is: in load table.insert(mansPool, manOne) table.insert(mansPool, manTwo) table.insert(mansPool, manThree) table.insert(mansPool, manFour) in update timer = timer + (1 * dt) if timer >= 3 then timer = 0 rand = mansPool[math.random(#mansPool)] randName = rand.name rand.active = true end in draw l...
by Strutyk
Sat May 07, 2016 2:53 pm
Forum: Support and Development
Topic: Objects table(active/inactive) - removing and adding
Replies: 20
Views: 9259

Objects table(active/inactive) - removing and adding

Hi all. We have a table with objects: objectsArray = {objectOne, objectTwo, objectThree ...} Each object has a properties: objectOne.active = false objectOne.x = 333, ... We need to choose a random object and set randomObject.active = true then remove selected object from objectsArray Upon reaching ...