|
2 registered members (3run, AndrewAMD),
667
guests, and 1
spider. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
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
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Or if you want to be tricky about it....
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
Altarius
OP
Junior Member
|
OP
Junior Member
Joined: Jul 2009
Posts: 85
|
No i cant use that for want i want to do  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
Expert
|
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: Altarius]
#347068
11/12/10 07:04
11/12/10 07:04
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
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
Senior Member
|
Senior Member
Joined: Feb 2010
Posts: 320
TANA/Madagascar
|
I think you need to make it yourself  . What about a function like bellow? You need to make something similar for every data types you want (Lite-C support function overloadding).
#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
Altarius
OP
Junior Member
|
OP
Junior Member
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
Senior Member
|
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.
#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);
}*/
}
|
|
|
|