Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / For Next object creation

Author
Message
Straxus
16
Years of Service
User Offline
Joined: 6th Oct 2009
Location: Beaverton, Oregon
Posted: 8th Apr 2011 05:46
So for last few days I have been trying to figure this one out on my own and with help of forum posts. Though sadly I just feel like my brain has been tied in a knot.

Trying to make each enemy loaded in a for next loop be asigned it's own object number.

Now I have been using handles for a little while (thanks to Zotoaster's tutorial) which has helped with so much, so I tried handles for some of my experiments.

the code (below) makes endless objects and I know why. It's because the npc = freeobject() just changes the variable every time.
Just thrown in because it's the only example code I have left that I didn't delete.
So how do I make object number unique for each "npc" in the loop?

I appologize in advance. This probably has a very obvious answer but I am probably way over thinking it.

Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Apr 2011 07:52
Quote: "So how do I make object number unique for each "npc" in the loop?"


Isn't it already unique? Each object number is different.

A clever person solves a problem, a wise person avoids it - Albert Einstein
Straxus
16
Years of Service
User Offline
Joined: 6th Oct 2009
Location: Beaverton, Oregon
Posted: 8th Apr 2011 08:10
OK good point...
I should have worded that differently.
Should have been how do I make each "npc" in the loop have a number that is not already taken by another "npc"...heheh
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Apr 2011 10:40
Ok, now I understand Maybe you should change to a different loop or even remove the for - next loop. Like this



Or if you know how many cubes you want, lets say 200, you could use an array



Hope this answers your question

A clever person solves a problem, a wise person avoids it - Albert Einstein
Straxus
16
Years of Service
User Offline
Joined: 6th Oct 2009
Location: Beaverton, Oregon
Posted: 8th Apr 2011 11:01
YES!
Thank you very much!
Now I can stop smacking my forehead into the table.
Hodgey
16
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 8th Apr 2011 11:25
Haha, I know how you feel, your welcome

A clever person solves a problem, a wise person avoids it - Albert Einstein

Login to post a reply

Server time is: 2026-07-17 14:00:17
Your offset time is: 2026-07-17 14:00:17