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 → Printing one-off messages
Printing one-off messages
2010-03-03, 11:23 AM #1
Hi coggers! I'm looking for a way to modify a cog, which plays a one-off sound upon entering a sector, so that it also prints a message on-screen too. (Subtitles for a monologue)

Here's the cog in question:

Code:
-----------------------------------------------------------------------
 
symbols 
   message   entered 
   sector   triggerSector   linkid=1 
   sound   theSound 
   flex   soundVolume=1 
   int      soundId=-1      local 
   int      done=0         local 
end 



code 
   entered: 
      if (GetSenderID() == 1) {   // match linkid 
         if (!done) { 
            soundId = PlaySoundGlobal (theSound, soundVolume, 0, 0); 
            done = 1; 
         } 
      } 
   return; 
end 
 
-----------------------------------------------------------------------


Thanks for your advice in advance. :)
2010-03-06, 9:12 AM #2
Try this on. Don't forget to change the message.

A few points to consider:
1) Only the listed sector ("triggerSector") will send the Entered event, so there is no need to check who sent it
2) There is no need to store the sound ID if you're not going to use it later
3) Please use code tags when posting cogs so that whitespace and alignment are shown
4) One print line won't cut it if the sound is too long

Code:
symbols 
   message   entered 
   sector   triggerSector
   sound   theSound 
   flex   soundVolume=1 
   int     done=0         local 
end 

code 
   entered: 
      if (done) return;
      done = 1; 
      PlaySoundGlobal (theSound, soundVolume, 0, 0); 
      print("Your message here"); // <-- Change the bit in the quotes
   return; 
end 
And when the moment is right, I'm gonna fly a kite.

↑ Up to the top!