testing it out

Blitz3D Forums/Blitz3D Beginners Area/testing it out

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

It seems you should try to understand the diffrences between strings and integers, as well as the way arrays work.

First, when using LoadMesh you should use an integer variable to hold the handle. If you don't (as you are using a string variable) you will not be able to keep control over the mesh. Although it may work noless due to Blitzbasics automatic type conversion, it's definitively not the way it's supposed to be (note: strings are those variables and arrays that are using the dollar sign)

Second, in your example you are using "m1" as the index when loading. This will always be zero (unlike "m" that is incremented by the "For" loop).

Here's an example based on your code that proofes what's wrong with it:

Dim box$(4)
For m = 1 To 4
 box$(m)=LoadMesh("ring1.3ds")
 box$(m1)=LoadMesh("ring2.3ds")
 PositionEntity box$(m),Rand(30,30),0,Rand(-30,-30)
 PositionEntity box$(m1),Rand(50,50),0,Rand(-50,-50)
Next
For m = 1 To 4
 entitycolor box$(m),255,0,0
 entitycolor box$(m1),0,255,0 ; we have lost control over the first 3 loaded ring2 meshes
Next

you see some of them wasn't colored. These are the ones we have lost control because m1 was always zero, the handle "box$(0)" was overwritten.

Here's the same in a more proper implementation:
Dim box(4,1)
For m = 1 To 4
 box(m,0)=LoadMesh("ring1.3ds")
 box(m,1)=LoadMesh("ring2.3ds")
 PositionEntity box(m,0),Rand(30,30),0,Rand(-30,-30)
 PositionEntity box(m,1),Rand(50,50),0,Rand(-50,-50)
Next
For m = 1 To 4
 entitycolor box(m,0),255,0,0
 entitycolor box(m,1),0,255,0 
Next

BTW. you may duplicate things by using the CopyEntity command.