3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: How about those 'variables'?  (Read 779 times)

« on: July 28, 2011, 04:49:05 AM »
Here is a list of all the variables of the 3DRad scripts and how to change and create them.

- float: normal number variable. Like: 5.61342.
  You create and set this variable like this:
Code: [Select]
float FloatVariable = 0;
void Main()
{
   FloatVariable = 12.3642;
}

- int: this is a number variable, but only with whole numbers. Like: 6.0000.
  You create and set this variable like this:
Code: [Select]
int IntVariable = 0;
void Main()
{
   IntVariable = 254;
}

- string: this one can contains anything. It is meant for text. Like: Hello World!
  You create and set this variable like this:
Code: [Select]
string StringVariable = "HelloWorld!";
void Main()
{
   StringVariable = "Hello Again!";
}

Mind the ' or the ".

- bool: this variable is true or false. Nothing else.
  You create and set this variable like this:
Code: [Select]
bool BoolVariable = true;
void Main()
{
   BoolVariable = false;
}
Note that a bool variable is false as default.

- Quaternion: this variable contains a 3D rotation. There isn't really an easy way to view one.
  You create and set this variable like this:
Code: [Select]
Quaternion QuaternionVariable;
void Main()
{
   iQuaternionFromEulerAngles(QuaternionVariable,90,180,-90,"xyz");
}
Note that there isn't a simple way to set a Quaternion like with a float variable. You will need a function like this one.

- Vector3: 3d location variable. Like: 10,5,23.
  You create and set this variable like this:
Code: [Select]
Vector3 VectorVariable;
void Main()
{
   VectorVariable = Vector3(2,1,3);

   VectorVariable.x = 2;
   VectorVariable.y = 1;
   VectorVariable.z = 3;
}
Note that there are different ways to set a Vector.


There are different ways of creating multiple of the same variables. See this script:
Code: [Select]
float FloatVariable1;                        //This one doesn't have a value set. The default is 0.
float FloatVariable2 = 1;                    //This one is set to 1.
float FloatVariable3, FloatVariable4;        //Here multiple variables are created. Both are not set, so they are 0.
float FloatVariable5 = 10, FloatVariable6;   //Here multiple variables are created. One is set to 10, the other one is default.
float FloatVariable7, FloatVariable8 = 20;   //Here multiple variables are created. One is set to default, the other one is 20.

void Main()
{
   
}



That are the ones I could come up with. If I have missed one or you have a question, post it beneath this.
Hope it helps.  ;)
« Last Edit: October 12, 2013, 01:04:21 PM by RobertooMolvadoo »
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #1 on: July 28, 2011, 08:59:55 PM »
Thanks, I'm sure some newbies will appreciate this.
Also, you forgot bool (true/false statement)
Code: [Select]
bool On = false;
void Main()
{
     if(YouTurnedItOn){
bool On = true;
}
Also "void", which returns nothing
« Last Edit: July 28, 2011, 09:02:28 PM by noaaisaiah »
« Reply #2 on: July 29, 2011, 01:40:26 AM »
Added to the list.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0

psikoT

« Reply #3 on: July 29, 2011, 08:03:01 AM »
bool variables are false by default... no need to declare them globally as false
« Reply #4 on: July 29, 2011, 09:01:48 AM »
Added.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #5 on: January 11, 2014, 12:57:24 AM »
Also most or all can be defined as arrays like -

string[] MyStuff(43), YourStuff(200), ThereStuff(1500);

int[] Mx(5), ut(21);

etc..

To access the array elements you would use -
int AB=20;  NOTE:of 21 elements, zero is the first ( 0 to 20 = 21 total ).
ut[AB]=128;
or
Mx[4] = 128;
« Last Edit: January 27, 2014, 03:30:45 AM by TinSoldier »
Pages: [1]