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 → COG problems
COG problems
2003-08-03, 7:39 PM #1
I cant quite seem to get this cog to work, This is my first cog and I can figure out whats wrong with it.

Code:
# Music Switch.cog
#
# Plays sound when activated
#
# ~Dude~
#==============================================#
symbols

message activated
message deactivated
sound thesound
surface theswitch
flex volume=10


end
#==============================================#
code
#-----------------------------------
activated:
   Playsoundlocal(thesound); // Plays sound


Return;

deactivated:
   stopsound();
return;

#-----------------------------------
end


------------------
I and only I know what I'm thinking.

[This message has been edited by SaberMaster (edited August 05, 2003).]
<SalvadorChicka> i wasn't all "omg canadians have sex with each other!"
2003-08-03, 11:10 PM #2
Hm... The whole COG is a mess...

First! A switch can not send a Deactivated message. So, you'll need to add an int, like: int on=0 local
Then add another int like: int c=1 local
Now... in the activated message, do this:
Code:
activated:
    if(GetSenderRef()!=theswitch) return; // If("The thing sending the message" "Isn't equel to" theswitch) "Leave the code now"
    If(on==0) //If("the int on" "is equel to" 0)
    {
        c=PlaySoundLocal(thesound,vol,balance,flags);
        on=1;
    }
    else if(on==1)
    {
        StopSound(c);
        on=0;
    }
return;
end


If you feel that something's missing in a verb (verb is something that gives the action like PlaySoundLocal) look them up in the COGwriter. You'll find them if you click on "New file" and "Line builder".

Hope that helps...

/Edward


[This message has been edited by Edward (edited August 04, 2003).]
Edward's Cognative Hazards
2003-08-04, 3:56 AM #3
Accually you're better off using DataMaster (DM) Cogwriter isn't very good at all in its listings and checkings.....

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-08-05, 6:39 PM #4
Quote:
<font face="Verdana, Arial" size="2">
Code:
 if(GetSenderRef()!=theswitch) return; // If("The thing sending the message" "Isn't equel to" theswitch) "Leave the code now"
</font>
This line is unnecessary since "the switch" is the only thing in the symbols section capable of sending messages.
Next, the stopsound command should be like this:
Code:
StopSound(c, fade_delay);

"fade_delay" is the time it takes for the sound to completely fade away. Put 0 if you want it to stop immediately.
------------------
"The Just shall live by faith." - Galatians 3:11
To edit is human... To COG is divine!!

pegasus_1984: Stop bushing that dang suck button.
guitarofgold: NOOOOOOOOO!!!!
-------[end post]-------

[This message has been edited by DogSRoOL (edited August 05, 2003).]
Catloaf, meet mouseloaf.
My music

↑ Up to the top!