PDA

View Full Version : Variables


BrutalVenom
04-28-2002, 09:55 AM
How would I make a global variable on startup that other COGs could get/set?
I'd be using it for money.
Thanks.

------------------
Or else Pizza is gonna send out for YOU!

gbk
04-28-2002, 10:00 AM
Its simple; you cant. Youll have to fake it with triggers.

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

JK editing resources (http://www.tbns.net/GBK/ol/index.htm).

BrutalVenom
04-28-2002, 10:12 AM
Thanks, can you give me an example?

Descent_pilot
04-28-2002, 04:56 PM
You could always use a new item bin. Ex 116, in the Items.dat. http://forums.massassi.net/html/wink.gif

------------------
The Sniper Missions. Current project, The X Project

SaberMaster
04-29-2002, 08:05 AM
Right, Cog does not use global variables. They're not really needed.

To give another cog a value, you can use the items.dat, SendMessage(), or SendTrigger(). SendTrigger() is better if you want to send the value to just one or two cogs because it's not worth creating a new bin.

So to send the trigger, use:

SendTrigger(dest, ID, param0, param1, param2, param3);


The destination is the thing number of the player who receives the trigger message. If the dest is negative, all players receive the message. The ID is the ID number of the trigger - no two triggers should use the same ID. Use the variable that you want to send for param0.

In the trigger message, use:

trigger:
IF(GetSourceRef() != IDnum) Return;
yourVar = GetParam(0);

Return;


Then, yourVar will contain the value of the variable in the cog that sent the trigger.

The DataMaster has a more complete description of SendTrigger() and trigger: so you should read what it has for them.

Glad to help. http://forums.massassi.net/html/wink.gif

------------------
Author of the Jedi Knight DataMaster (http://www.geocities.com/sabersdomain/fileframe.html).
Visit Saber's Domain (http://www.geocities.com/sabersdomain).

BrutalVenom
04-29-2002, 01:21 PM
Thanks a lot! http://forums.massassi.net/html/smile.gif