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 / What's wrong with my FOR NEXT statement?

Author
Message
DarkDISCUSSION
15
Years of Service
User Offline
Joined: 6th Jul 2011
Location: Ft Madison, IA
Posted: 10th Jan 2012 23:24

What am I not doing right? Could someone please help me with this?

I'm Never wrong, I just can't get anything right.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 10th Jan 2012 23:38
You don't need the Dim, and you have stuff back to front. You might want a Dim later for positioning, but it isn't needed in your example.


For i=1 To 100
Load object "good tree.dbo",i
Position object i,Rand(-1000,1000),55,Rand(-1000,1000)
Next

WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 10th Jan 2012 23:42
Yep, LOAD OBJECT doesn't return an objects ID, you have to assign one when using the command. (LOAD OBJECT "file", ID)

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
29 games
20
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 10th Jan 2012 23:52
Others have beaten me to it but I'll post anyway.

It's this line:



If you want the tree(i) to hold the object numbers you need to do something like:





In this example object_number = 0 at the start because no other objects have been loaded prior to loading the trees.

If you are using this method then you would have to use increment the variable object_number, assign this to another variable (so if you had rocks and mushrooms then you might have variable for holding the rock and mushroom object numbers), and then load the object using a similler FOR...TO...NEXT loop. You will also have to do this for any objects that are loaded individually.

The other way to do this is to have a function that simply finds an unused object number. I believe that there is such a function in Iam M's matrix utility plugin but it's easy enough to do your own.

Whether you do this or what has been posted above will depend if you need to keep track of the object numbers. I find it easier to write object number to variables as it makes things easier to deal with, especially if you are loading lots of different object that might have different properties / influences in the game. I.e. to differentiate between destructible, non-destructible scenery and exploding scenery for example.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 11th Jan 2012 00:15
You could program your own load object routine to make that work. The top part is your code, and I added a small function at the bottom. (You will need Matrix1 utils).



If you don't have matrix1 utils, you can replace this line:



with this



TheComet

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 11th Jan 2012 06:44
Interesting there TheComet...

Just adding shouldnt it say NEXT i ¿

bitJericho
23
Years of Service
User Offline
Joined: 9th Oct 2002
Location: United States
Posted: 12th Jan 2012 11:24 Edited at: 12th Jan 2012 11:25
the variable reference after the next command is optional.


MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 12th Jan 2012 12:17
Cheers Jerico

Login to post a reply

Server time is: 2026-07-10 04:42:21
Your offset time is: 2026-07-10 04:42:21