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 → First cogging attempt
First cogging attempt
2004-08-01, 1:46 PM #1
I wrote a cog and it works somewhat. Its supposed to move a thing to frame one, sleep, then move back to frame 0 and sleep and so on and so forth, but, it only moves to frame one and then Stays there. Here's the Cog
Code:
# Written By Dude
#
#Custom Shuttle Script
#
#
#=======================================================

symbols

        message startup
        message timer

        thing shuttle0

        float movespeed=5.0
        float sleeptime=6.0
        float lightvalue=0.5

end
#=======================================================

code

startup:
       
       SetTimer(sleeptime);

                          MoveToFrame(shuttle0, 1, movespeed);
          
                                                             SetTimer(sleeptime);
                                                                              
                                                                                MoveToFrame(shuttle0, 1, movespeed);
                                                                                     
                                                                                                                   SetTimer(sleeptime);

return;

end


Please let me know what you do to it and why if you can. Im tryin to learn to cog. [http://forums.massassi.net/html/smile.gif]

------------------
Total Toothpickings; 7
<SalvadorChicka> i wasn't all "omg canadians have sex with each other!"
2004-08-01, 6:22 PM #2
Code:
# Written By Dude
#
#Modified by a_person. Reason, Wasnt moving back through the frames.
#
#Custom Shuttle Script
#
#
#=======================================================
symbols

message startup

thing shuttle0
flex movespeed=5.0
flex sleeptime=6.0

end
#=======================================================
code
startup:
       
       while(1)   {
       MoveToFrame(shuttle0, 1, movespeed);
       waitforstop(shuttle0);
       sleep(sleeptime);
       MoveToFrame(shuttle0, 0, movespeed);
       waitforstop(shuttle0);
       sleep(sleeptime);
     }
                                                                                     
                                                                                                                   SetTimer(sleeptime);
return;
end


This should work for you. Firstly I got rid of all that timer stuff and made the sleep times sleep(). Then I added while(1) to make the cog continuously loop. Then the next movetoframe() frame value has to be 0.

I hope this helps.

[edit] Also I should add unless you add more frames the ship will fly backwards[/edit]

/a_person

------------------
~Nightfire Mod~

[This message has been edited by a_person (edited August 01, 2004).]
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2004-08-02, 12:04 AM #3
That's not a bad effort for a first time COTF_Dude [http://forums.massassi.net/html/smile.gif] - just a couple tidbits of advice that I hope are helpful in your endeavours:

1) When you write "SetTimer(sleeptime)", what you are saying is to call the "timer" message - something that whilst you have acknowledged you are going to use in your cog symbols section, you haven't ended up implementing in your code section. Parsec would pick up this for you (see point 4).

2) Whilst timers are extremely useful (especially once you start dealing with multiple timers...), I think "Sleep()" would be better, as a_person suggests [http://forums.massassi.net/html/smile.gif]. Although not a huge fan of "Sleep()" myself, I readily confess that it has it's uses, certainly with regard to SP cutscenes, but anything to do with MP, then timers would be advisable but not obligatory (thought I'd throw in a disclaimer before some people pick me up on this...)

3) On an aesthetic note, don't overdo your code indentation [http://forums.massassi.net/html/wink.gif] take it from someone who knows, indenting your code for readability is one thing, but indenting every line could be construed as maybe a tad bit excessive... [http://forums.massassi.net/html/tongue.gif]

4) My other main counsel would be to download the DataMaster (a.k.a the COG BIBLE - always good for a bit of bedtime reading [http://forums.massassi.net/html/wink.gif]) and Parsec (for debugging your cog scripts - a totally invaluable resource [http://forums.massassi.net/html/biggrin.gif]). Both of these can be found at SaberMaster's site: http://geocities.com/sabersdomain/ - download these and you will be sorted for life (as far as JK cogging is concerned) [http://forums.massassi.net/html/biggrin.gif]

Well I hope these "sage words" are of some help - keep up the good work [http://forums.massassi.net/html/biggrin.gif]

-Jackpot

------------------
"lucky_jackpot is the smily god..." - gothicX
"jackpot is an evil evil man... so evil, in fact, that he's awesome." - Seb

"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
("Ye Wearie Wayfarer" - by Adam Lindsay Gordon)
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2004-08-02, 9:39 AM #4
Thanks for all the help. I'll be sure to d/l that stuff. I was using the 00_Door.cog for a reference on how to do it. [http://forums.massassi.net/html/smile.gif]

------------------
Total Toothpickings; 7
<SalvadorChicka> i wasn't all "omg canadians have sex with each other!"
2004-08-02, 6:28 PM #5
Haha I remember my attempt to use 00_door.cog when i was starting out.

------------------
~Nightfire Mod~
Spoting an error in post will result in a $100 reward.
Offer expires on 6/6/06. Valid one per customer, per day.

Rangi
2004-08-03, 4:24 PM #6
Also, don't use "float". Use "flex" instead, even though it is essentially equal. float is older and I guess has issues with certain things (not sure what/why just do it [http://forums.massassi.net/html/wink.gif] )

------------------
nil nip nada zip zero naught lip zil
This is retarded, and I mean drooling at the mouth
2004-08-03, 8:32 PM #7
As far as I'm aware there's no special problems with floats. The only problem I know of applies to both floats and flexs, and that is floating point precision error, which simply has to do with the way information is stored. (Binary sucks for storing decimals, so after a certain point there is error. Other than that, I believe flex is just something common in cogs, though flex and float work the same as far as I'm aware.)

------------------
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come

↑ Up to the top!