Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Variables
Variables
2002-04-28, 6:55 AM #1
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!
2002-04-28, 7:00 AM #2
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.
And when the moment is right, I'm gonna fly a kite.
2002-04-28, 7:12 AM #3
Thanks, can you give me an example?
2002-04-28, 1:56 PM #4
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
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2002-04-29, 5:05 AM #5
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:
Code:
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:
Code:
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.
Visit Saber's Domain.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-04-29, 10:21 AM #6
Thanks a lot! [http://forums.massassi.net/html/smile.gif]

↑ Up to the top!