tranfering variables

Posted By: onslaught147

tranfering variables - 11/09/07 04:02

how do you transfer different variables between function and function, action and action, and function and action (i imagine it will be the same way for all three) i know how to transfer flags but that is very limiting so transfering even skills will be extremely helpful. ty
Posted By: bonecracker

Re: tranfering variables - 11/09/07 11:15

So what variables do you mean?

If you wanna transfer Informaition like "Player-Energy or Money or something else" you should use "DEFINE"
for example:



*****************************************
DEFINE Money,Skill51;

Action Player
{

MY.Money = 100;

while(....){
blalalalalala
.....
....
wait(1);
}
}

Function Bad_guy_take_my_money()
{

IF( ....EVENT_TYPE....is TRUE) { YOUR.Money = 0; }

}

****************************************************
The Pointer of the "Bad_guy_take_my_money" have to point the "Player".

So you can handel the energy of every Action , function... !!

I hope that help you to fix your little problem.

Ciao Bonecracker
Posted By: MichaelGale

Re: tranfering variables - 11/09/07 20:46

What you talk about are global variables. They work like this:

Code:

var x;

function alpha()
{
x += 5;
// x is now 10
}

function main()
{
x = 5;

alpha();
}


Posted By: Dark_samurai

Re: tranfering variables - 11/09/07 21:18

I think his talking about function parameters.
Do it just like that:

Code:

function main()
{
test_sub(30);
temp = 20;
test_sub(temp);
}

function test_sub(a)
{
//after thrist call a == 30
//after second call a == 20
...
}



This is NOT possible with actions!!! For actions you have to use global Variables.
For more informations about parameters look into the manual.

Dark_Samurai
Posted By: onslaught147

Re: tranfering variables - 11/10/07 00:41

i cant use global varables bc i will have multiple objects of the same type using the same variables so global variables will be impossible to use
Posted By: Dark_samurai

Re: tranfering variables - 11/10/07 09:13

So why not using parameters?
If you want to use actions there is no other solution then using global variables, but you can also use functions in WED! If you write the name of the function in the behaviour panel, this function is handled like an action, but you can use parameters.

Dark_Samurai
Posted By: MichaelGale

Re: tranfering variables - 11/10/07 09:22

If you have multiple objects of the same type you should go for skills in C-Script. In Lite-C, however, you could have structures and arrays to work with. Or as Dark_samurai suggested you pass the variables through the function parameters, which is very limited though.
Posted By: onslaught147

Re: tranfering variables - 11/10/07 19:36

i would use skills but u cant pass the skill through two different objects and i dont have WED so the function parameters (as far as i know) will be impossible for me but thnx for the replies
© 2024 lite-C Forums