PDA

View Full Version : Variables


The_Chimera_FJ
01-25-2001, 04:48 AM
If you make a cog file, and put a variable in it (EG a=0) Then how do you get other cogs to recognise that variable and realise that if the variable changes (EG to 1).

Hideki
01-25-2001, 08:20 AM
You got to pass the var onto the other cog or use a global variable, which is the

"items.dat"
"SetThingUserData"
or something else.

To pass use,
SendMessageEx(cog, message, var1, var2, var3, var4);
But this way, it's hard to retrieve the "cog" unless you specify via JED.

or add new entries in the items.dat and use
SetInv(player, 116orAbove, 1);
and
GetInv(player, 116);

or use SendTrigger
SendTrigger(-1, 123, var1, var2, var3, var4);
and in other cogs

trigger:
if(GetSourceRef() == 123)
{
sentVar1 = var1;
another = var2;
whatever = var3;
oneMore = var4;
}

The only global value is the "items.dat" method and others are passing the local var to other cogs.

And as for SetThingUserData, it can set a unique var onto a "thing" globally

SetThingUserData(player, yourValue);
and
GetThingUserData(player);
will return the value set.

------------------
http://millennium.massassi.net/ - Millennium

[This message has been edited by Hideki (edited January 25, 2001).]

The_Chimera_FJ
01-25-2001, 12:03 PM
thanx- i got it to work now! http://216.105.160.32/html/smile.gif http://216.105.160.32/html/smile.gif http://216.105.160.32/html/smile.gif