Cog Quiz

Week 4 - Answer

Prev - Exit - Next

Show Quiz

Level 1

SendMessageEx(CogToSendTo, MessageToSendTo, Parameter0, Param1, Param2, Param3);

SendMessage(); can send a message to another cog to a specified message. This is useful when you need to deal with a variable across cogs.

For instance when you want to stop a key played by a cog, but needs to be stopped when a door closes, the door cog need to send a message to the cog playing the key to stop the specified key.

When you want to send extra information(integers, models, things etc), place them in the parameters and retrieve them using GetParam(X); in the sent cog. If you don't need any parameters just use SendMessage(cogRef, message);.


Level 2

SendMessageEx(dest_cog, user0, GetLocalPlayerThing(), jerecModel, 0, 0);

This does not accomplish the task, as the cog is defined in the symbols section directly and this method does not work so it is a pain to define a user made cog.

Try to place a cog in the items.dat like other force powers do, and call it using GetInvCog(player, bin);. That is the only problem that this is not working.


Level 3

SetThingModel(GetParam(0), GetParam(1));

As this shows, the SetThingModel(); is carried out using parameters from the sender cog, which can be found in the above answer line.

The parameter 0 is GetLocalPlayerThing() and parameter 1 is "jerecModel" which is je.3do found in the symbols section.

Parameters usually hold integers no matter what type of value is placed in the parameter parenthesis, so models are also retrieved as integers, but don't worry, it can set the model sent properly to the player. So the answer is it works fine.