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 / loop that check if object exist

Author
Message
Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 9th Dec 2010 07:20
hi all

Can someone help me out with a loop that if i push spacebar key, will go check if object 11 exist and if it does go check object 12 and ect... until it get to an object that not exist and then create it.

if its possible it should start counting from 11 to 200 so i got the first 10 objects free, so the first object the loop will make is 11. if it not exist.


thx
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 9th Dec 2010 07:43 Edited at: 9th Dec 2010 08:22


Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 9th Dec 2010 07:58
Thx mate

You are the one. works perfekt.
C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 9th Dec 2010 08:00


TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th Dec 2010 11:24
I prefer to use a for loop, but that's just me



TheComet

Scraggle
Moderator
23
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Dec 2010 11:31
Although both of these methods work. You will find that you have created a lot more than one object. Unless you have lightning quick hands you will probably create every cube with object numbers 11-200.
To get this working as I suspect it is intended, you would need to flag the spacebar so that it only creates objects when pressed and not when held.



TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 9th Dec 2010 12:34


TheComet

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 9th Dec 2010 14:07 Edited at: 9th Dec 2010 14:08
That will also use object id 201 when you've used up all objects from 11 to 200, and then will crash when you have no more objects free in the range.



C0wbox
20
Years of Service
User Offline
Joined: 6th Jun 2006
Location: 0,50,-150
Posted: 9th Dec 2010 17:23
Aye I was just giving him the basic overview code, I didn't implement a key lock or the 200 limit so it left him some room to do his bit of programming.

Login to post a reply

Server time is: 2026-07-21 19:18:55
Your offset time is: 2026-07-21 19:18:55