Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (fairtrader, AndrewAMD, ozgur, TipmyPip, Quad, alibaba), 582 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Previous variable value into another variable? #347061
11/12/10 05:13
11/12/10 05:13
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
Hi,

Is there a way to keep the value of a variable, when this one change, into another variable.

exemple:

var number =3;
var old_number;

now i add 1 to "number" i want to "old_number" keep the previous value.. so old_number = 3;

thx

Re: Previous variable value into another variable? [Re: Altarius] #347062
11/12/10 06:28
11/12/10 06:28
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
Maybe like this ?
Code:
old_number=number;
number+=1;



Re: Previous variable value into another variable? [Re: bart_the_13th] #347064
11/12/10 06:32
11/12/10 06:32
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Or if you want to be tricky about it....
Code:
old_number = ( number = number + 1 ) - 1;

But I advise against this, its a mongrel to de-bug...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Previous variable value into another variable? [Re: Altarius] #347065
11/12/10 06:33
11/12/10 06:33
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
No i cant use that for want i want to do cry

There no pre-made engine function who can keep track of last variable value when it change...?

Last edited by Altarius; 11/12/10 06:37.
Re: Previous variable value into another variable? [Re: Altarius] #347066
11/12/10 06:39
11/12/10 06:39
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Not that Ive ever heard of...

What is it you are trying to do that needs this?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Previous variable value into another variable? [Re: EvilSOB] #347067
11/12/10 06:48
11/12/10 06:48
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
I try to get 3 objects who rotate depending the current rotation value of each other...

So i tried to cut the 360 degree into 4 zone... and put the result into a variable... hard to explain lol...

Re: Previous variable value into another variable? [Re: Altarius] #347068
11/12/10 07:04
11/12/10 07:04
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Ah, so these three object are 'linked', so if ANY one of them gets
'pushed' by an outside force, all three will rotate by that same amount.

Right?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Previous variable value into another variable? [Re: Altarius] #347069
11/12/10 07:06
11/12/10 07:06
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
I think you need to make it yourself grin. What about a function like bellow? You need to make something similar for every data types you want (Lite-C support function overloadding).

Code:
#include <acknex.h>
#include <default.c>

// Variables
var newVariable = 0;
var oldVariable = 0;

// Test font
FONT *fnt_arial = "Arial#30b";

// Display panel
PANEL *pan_oldVar = 
{
	digits(0, 0, "%0.0f", fnt_arial, 1, oldVariable);
	digits(0, 30, "%0.0f", fnt_arial, 1, newVariable);
	
	flags = SHOW ;
}

function setVariable(var *new, var *old, var value)
{
	if ( new == NULL )
	{
		printf ("Variable can't be NULL");
		return;
	}
	
	if (old != NULL)
	{
		*old = *new;
	}
	*new = value ;
}

//////////////////////////////
// Entry point
//////////////////////////////
function main()
{
	video_mode = 2;
	level_load("");
	var i = 0;
	
	while(1)
	{
		setVariable(newVariable, oldVariable, i++);
		wait(-1);
	}
}



Re: Previous variable value into another variable? [Re: 3dgs_snake] #347070
11/12/10 07:35
11/12/10 07:35
Joined: Jul 2009
Posts: 85
A
Altarius Offline OP
Junior Member
Altarius  Offline OP
Junior Member
A

Joined: Jul 2009
Posts: 85
That work fine but what if i need to keep the oldvariable value until the newvariable change witout a timer?

like i press a key for change the newvariable and the oldvariable keep the old value until i change it again..



Last edited by Altarius; 11/12/10 07:46.
Re: Previous variable value into another variable? [Re: Altarius] #347071
11/12/10 07:55
11/12/10 07:55
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
Every time you need to change a value you call the function, pass in the newVariable pointer, oldVariable pointer and the new value. The timer is there for demonstration only.

I don't know if that is an answer to your question.

Code:
#include <acknex.h>
#include <default.c>

// Variables
var newVariable = 0;
var oldVariable = 0;

// Test font
FONT *fnt_arial = "Arial#30b";

// Display panel
PANEL *pan_oldVar = 
{
	digits(0, 0, "%0.0f", fnt_arial, 1, oldVariable);
	digits(0, 30, "%0.0f", fnt_arial, 1, newVariable);
	
	flags = SHOW ;
}

function setVariable(var *new, var *old, var value)
{
	if ( new == NULL )
	{
		printf ("Variable can't be NULL");
		return;
	}
	
	if (old != NULL)
	{
		*old = *new;
	}
	*new = value ;
}

//////////////////////////////
// Change variable value on key press
//////////////////////////////
function doChangeVariable()
{
	setVariable(newVariable, oldVariable, random(100));
}

//////////////////////////////
// Entry point
//////////////////////////////
function main()
{
	video_mode = 2;
	level_load("");
	
	on_v = doChangeVariable;
	
	/*while(1)
	{
		setVariable(newVariable, oldVariable, i++);
		wait(-1);
	}*/
}



Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1