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 → Easy Peasy Cog Needed
Easy Peasy Cog Needed
2001-11-14, 7:33 AM #1
Easy for those who know how of course. [http://forums.massassi.net/html/smile.gif]
I need a simple cog that makes a surface act as a switch that can be switched. When switched i need a sound played and a line of text printed.

Ta [http://forums.massassi.net/html/biggrin.gif]
2001-11-14, 7:45 AM #2
Code:
symbols

surface switch
sound   sound_to_play

message activated

end

code

activated:
   if (GetSenderRef() != switch) Return;

   PlaySoundPos(sound_to_play, SurfaceCenter(switch), 0.6, -1, -1, 0);

   jkStringClear();
   jkStringConcatAsciiString("PUT YOUR TEXT HERE");
   jkStringOutput(-3, -1);

   Return;

end


You didn't specify anything about how/where you wanted the sound to be played, so this just plays the sound at the switch. The text is also displayed to everyone. If this is to be used in SP, you can change the "-3" to "-1". If you want it to only be displayed to the person who activated it (for MP purposes), change the "-3" to "GetSourceRef()".

It *should* work. I *didn't* test it. [http://forums.massassi.net/html/biggrin.gif]
2001-11-14, 12:19 PM #3
Thanks. Its fine. [http://forums.massassi.net/html/biggrin.gif]
2001-11-15, 11:29 AM #4
Soz actually, i shoulda said, is it possible to make the surface (switch) change to the switched form of itself (if you know what i mean) when switched?

Hmm..confusing :P
2001-11-15, 11:58 AM #5
Modified Rishka's code:

symbols
surface switch
sound sound_to_play
message activated
Message Timer
end
code
activated:
if (GetSenderRef() != switch) Return; PlaySoundPos(sound_to_play, SurfaceCenter(switch), 0.6, -1, -1, 0);
Setwallcel(Switch, 1);
Settimer(Getsoundlen(Sound_to_play));
jkStringClear();
jkStringConcatAsciiString("PUT YOUR TEXT HERE");
jkStringOutput(-3, -1);
Return;
Timer: Setwallcel(Switch, 0); Stop;
end

That should do it.... [http://forums.massassi.net/html/biggrin.gif]



------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-11-15, 12:37 PM #6
Bah, GBK needs to learn the code tag. :P
2001-11-15, 7:25 PM #7
Using the CODE tag causes problems when you try to copy the text - it doesnt preserve the line breaks.

Thats why all the text gets jumbled onto one line.... [http://forums.massassi.net/html/tongue.gif]


------------------
Success is the inverse relationship between effort, gain, and loss.
And when the moment is right, I'm gonna fly a kite.
2001-11-15, 11:59 PM #8
There are some ways around that... If there's not a whole lot of text/code, you can use reply-with-quote and then copy what's between the CODE tags and all your formatting is there. [http://forums.massassi.net/html/wink.gif] guess it all depends on personal preference.

[This message has been edited by ~Rishka~ (edited November 16, 2001).]

↑ Up to the top!