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 → Message Sending
Message Sending
2005-07-14, 11:00 AM #1
I've never understood how to send messages from a cog to another cog. So I have a few questions:

1a) What do I do to have a cog send a message to a certain section of another cog, and what do I put in the cog I'm sending the message to?

1b) If I have a cog define a player(victim), how do I make it so another cog uses that victim. Does that make sense?

2) How do I send triggers to a cog on another computer? What do I put in the local cog, and what I do put in the cog that goes on the other computer?

Thanks!

ReT
2005-07-14, 11:37 AM #2
1a)
Code:
    SendMessageEx(GetInvCog(player, BIN), MESSAGE, PARAMETER0, PARAMETER1, PARAMETER2, PARAMETER3); 


it basically calls a message section in another cog. I usually only use this to send messages to cogs in the items.dat. There are probably other cogs you can send messages to, but I never tried it because I never needed to. Use the "user#:" messages for custom messages, but you can still call stuff like selected, activated, fire and things.

1b) put the player in as one of the parameters and use GetParam(0); or GetParam(1); or whatever you set it to to find it in the recieving cog's message. I'd use a user message for this because I've never seen or used GetParam(); in any of the other messages except trigger, timer, and the user ones, but I don't know for sure.

1b)
Code:
   SendTrigger(WHICHCOGithink, IDNUMBER, PARAMETER0, PARAMETER1, PARAMETER2, PARAMETER3);


set the first value to -1 and it will send the trigger everywhere (including other players).

In the recieving cog, have a "trigger:" message and use GetSourceRef(); to identify the ID number. The parameters are again certain things you can carry over.


vectors can't be sent as one parameter and need to be broken into the X, Y, and Z.
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-07-14, 11:43 AM #3
(1. a and b) Say, for example, you wanted to send a victim you defined in some cog to an inventory cog... then the inventory cog does stuff with it...
cog 1 (the one that found the victim)
Code:
   victim = <something>;
   SendMessageEx(GetInvCog(GetLocalPlayerThing(), bin_num), user0, victim, 0, 0, 0);

Cog 2 (inventory cog)
Code:
user0:
   victim = GetParam(0);
   <do stuff>


(2) Say, using the code on your other thread, you select the player, and in primary fire you want to send a trigger to that player's computer to give him 20 more health points...
Cog 1 (your weapon cog)
Code:
activated:
   mode = GetSenderRef();
   if(mode == 0)
   {
      // send a trigger to that player we selected -- index is the index number of the player (not thing number), 1337 is the trigger id
      SendTrigger(index, 1337, 0, 0, 0, 0);
   }
   else
   {
      <player selection code>
   }
   Return;

Cog 2 (on the other player's computer)
Code:
trigger:
   if(GetSourceRef() == 1337) //trigger id is 1337
   {
      HealThing(GetLocalPlayerThing(), 20);
   }
May the mass times acceleration be with you.
2005-07-14, 12:37 PM #4
Something's been bugging me, is it jkGetLocalPlayer(); or GetLocalPlayerThing();. In weap_fists.cog its jkGetLocalPlayer();..

Do both work or something?
visit my project

"I wonder to myself. Why? Simply why? Why why? Why do I ask why? Why do I need to find out why? Why do I have to ask why as a question? Why is why always used to find out why? Why is the answer to why always why? Why is there no final answer to why? Simply why not? Holy cow, this is pretty deep, meaningful **** I wrote. Glad I wrote it down. Oh man."
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [slog], Echoman
2005-07-14, 1:54 PM #5
LEC made 2 verbs for a lot of things. I honestly don't know why, but they did. Yes, jkGetLocalPlayer(); and GetLocalPlayerThing(); are the same thing as far as I know.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-07-14, 5:56 PM #6
Wow, thanks a lot everyone. I'm gonna try this out hopefully sometime soon.

I really appreciate you guys taking the time to help me out.

It's gonna be for the JKDS, one local cog will be used to define player and another(the tools cog) will have certain functions that do things to a victim, but the victim will of course have to be defined(through the define player cog).

The weapon cog is for something else entirely. ;)

Thanks again!

ReT

↑ Up to the top!