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: problem with incriment...please help.  (Read 256 times)

« on: December 22, 2013, 01:32:54 AM »
When I post-incriment a variable and reset the script...Next time when i start the script,the variable increments from the previous value before the reset.
How can i reinitialise it to zero, when i start script after reset..??

soulfly

« Reply #1 on: December 22, 2013, 02:12:18 AM »
just declare it as global (out of Main) and assign it a value, (0 in this case).
« Reply #2 on: December 22, 2013, 02:14:36 AM »
got it....sorry...
« Reply #3 on: December 22, 2013, 11:00:00 AM »
or use it in the void main() loop

Code: [Select]
float testing;

void main()
{
    if (iInitializing()){
      testing = 0.123456789;
     }
     /// your code here
}

Each time the script runs, your variable should be reset.

If you assign the variable to a global variable, the value can be retained between projects in a multi-player project.

Expanding on that -
You could even write what ever values you want to a text file, then read the file back in to any other project, or the same project.

Thats just a few ways to deal with variables and saving / loading / sharing.. :)
« Reply #4 on: December 22, 2013, 06:44:12 PM »
yes it incriments when taken global and when i reset the script, i redefine it to 0 and this solves the problem..
int a=1;
void main()
{
a++;
if(ikeyDown(iKeyCode("DIK_return")))
a=0;
}
Pages: [1]