The line:
changes the color of the object that is refered to with the 'active' variable.
So if you say:
then the line will change the color of the car.
However, after you say:
The second part is a bit harder to explain. It deals with arrays, which are defined with a Dim (=dimension?) statement.
Dim allows for multiple variables to be refered to, using a number as an index.
So, if you create an array:
Then, after that, you can use x(0), x(1), x(2) .. etc x(10).
In this matter, "sel" is a number that is filled in between the brackets. So, if sel = 1, then the line
Maybe the best explanation will be a working example:
entitycolor active, red, green, blue
changes the color of the object that is refered to with the 'active' variable.
So if you say:
active = car
then the line will change the color of the car.
However, after you say:
active = bwsthe line will change the color of bws.
The second part is a bit harder to explain. It deals with arrays, which are defined with a Dim (=dimension?) statement.
Dim allows for multiple variables to be refered to, using a number as an index.
So, if you create an array:
Dim x(10)
Then, after that, you can use x(0), x(1), x(2) .. etc x(10).
In this matter, "sel" is a number that is filled in between the brackets. So, if sel = 1, then the line
entitycolor active, red(sel), green(sel), blue(sel)will become
entitycolor active, red(1), green(1), blue(1)And if sel = 2 then the line will be
entitycolor active, red(2), green(2), blue(2)
Maybe the best explanation will be a working example:
Graphics3D 800, 600, 0, 2 SetBuffer BackBuffer() ;create camera camera = CreateCamera() PositionEntity camera, 0, 0, -10 ;create array to store colors Dim red(5) Dim green(5) Dim blue(5) ;initialize 6 separate colors For i = 0 To 5 red(i) = 255 green(i) = 255 blue(i) = 255 Next ;create 6 objects object0 = CreateSphere() PositionEntity object0, -7, 0, 0 object1 = CreateSphere() PositionEntity object1, -5, 0, 0 object2 = CreateSphere() PositionEntity object2, -3, 0, 0 object3 = CreateSphere() PositionEntity object3, -1, 0, 0 object4 = CreateSphere() PositionEntity object4, 1, 0, 0 object5 = CreateSphere() PositionEntity object5, 3, 0, 0 ;select object0 activeobject = object0 ;select color 0 -> red(0), green(0), blue(0) selection = 0 Repeat ;use keys 1-6 to change object If KeyHit(2) Then activeobject = object0: selection = 0 If KeyHit(3) Then activeobject = object1: selection = 1 If KeyHit(4) Then activeobject = object2: selection = 2 If KeyHit(5) Then activeobject = object3: selection = 3 If KeyHit(6) Then activeobject = object4: selection = 4 If KeyHit(7) Then activeobject = object5: selection = 5 ;get color of current object r = red(selection) g = green(selection) b = blue(selection) ;apply color to current object EntityColor activeobject, r, g, b ;use cursor keys to change color If KeyDown(203) Then r = r - 10 If KeyDown(205) Then r = r + 10 If KeyDown(200) Then g = g - 10 If KeyDown(208) Then g = g + 10 ;put r,g,b back into array red(selection) = r green(selection) = g blue(selection) = b RenderWorld Text 0, 0, "activeobject = " + activeobject Text 0,12, "red = " + r Text 0,24, "green = " + g Text 0,36, "blue = " + b Text 400, 50, "use cursor keys to change color", 1 Text 400, 70, "use 1-6 to select object", 1 Flip Until KeyHit(1)