Posted by Stealth on February 23, 1998 at 03:54:43:
In Reply to: Re: Grrr. Stupid bloody CoGs-Help(again)!! :P posted by Stealth on February 23, 1998 at 03:47:52:
> > I bloody well give up.
> > I have spent the last 14 hours building, editing and rebuilding a .Cog to allow me to move a thing (i.e. a tie bomber) around through more than 2 frames.
> > The tiepatrol.cog is nothing more than a static 2 frame standard elevator script set to process on startup rather than on activation.
> > The frame positions are taken from the two variables (FRAME)that you attach to the thing (tie bomber, thing 27 in my level) and the cog moves the thing from FRAME 1 to FRAME 2 then back again and repeats the whole cycle forever.
> >
> > I looked EVERYWHERE in the .url formatted Cog Specification lists that I got off of here and I find absolutely NOTHING about a setting for NUMFRAMES.
> > Furthermore, the cockeyed way the .cog language looks at setting and comparing variables is preventing me from knowing how or even WHERE in the cog to set up the variables I need, compare them, increment them and use them.
> > Here (again, sigh) is my basic need:
> > 1) In JED (or FB) place a thing (elevator, tie bomber, whatever).
> > 2)Add a value field named NUMFRAMES to the thing editor and put the number of desired coordinate sets for the thing to be moved to (ex: NUMFRAMES 3)
> > 3) Add value fields named FRAME to the thing editor for each FRAME you want (ex. if NUMFRAMES is 3, then you must add and fill in 3 FRAME fields in the item editor as well)
> > fine so far...now into the .COG itself
> >
> > 1) set flex variables for speed, sleeptime and thing #
> Easy
> flex speed=2.0 local
> flex sleep=1.0 local
> thing mover # you Have to set this..
> > 2) set up variables that the cog will work with but the user does NOT have to enter any values for. this is for startframe (always 0) endframe (ENDFRAME=NUMFRAMES), curframe (GetCurFrame) and nextframe (NEXTFRAME=CURFRAME +1)
> You Will have to tell it how many frames you have,you can figure everything else from that.
> int numframes
>
> > 3) get the data stored in NUMFRAMES from the thing
> why ? much simpler to tell it how many you have.
> > 4) find out where the thing is. (CURFRAME)
>
> int curframe=0 local
>
> CurFrame= GetCurFrame(mover);
> If (GetCurFrame(mover)!= numframes)
> {
> MoveToFrame(mover,Curframe+1,speed);
> Return;
> }
> > 5) if the thing is in ENDFRAME, let the thing move all the way back to frame 0
> If (GetCurFrame(mover)== numframes)
> {
> MoveToFrame(mover,0,speed);
> Return;
> }
> > 6) if the thing is NOT in ENDFRAME, then NEXTFRAME=CURFRAME +1
> see # 4
> > 7) move the thing to CURFRAME
> > 7a) pause for the amount of time specified in the flex variable sleeptime
> just stick the timer in one of the loops above.
> > 8) if the thing is in ENDFRAME, let the thing move all the way back to frame 0
> Going to look funny flying backwards, you should make new frames to turn it around to fly forward all the way back to frame 0
> If you want the thing to continously loop it`s even easier.
> add a startup:
> Move it to next frame
> when it arrives move it to next frame
> if it`s at numframes move it to frame 0
> > 8a) pause for the amount of time specified in the flex variable sleeptime
> > 9) Repeat the entire thing again, causing the thing to 'patrol' through its frames forever.
> > thats it..thats all I need. It seems so bloody simple, but I cant figure it out.
> > IDEALLY, I'd like to see the thing move through all the frames specified, then move through the frames in reverse order 1 frame at a time rather than making one long trip back to the start frame.
> > so if CogKing or someone else is willing, would you put together a cog that does this?
> > If someone can put together this cog idea and get it working, the information I get from it should fill in the gaps in my coging knowledge, not to mention getting your name credited in any level I use the cog in.
> >
> > I call this the thingmover.cog :D
> > I really really need this. Im stuck at a crucial development point in my first level of the level pack Im building
> > Thanks, and sorry to be posting so much..but if my blood pressure gets any higher, my heads gonna explode.
>
> If you use say three frames to get to where you want it then turn it around with three more frames.
> it`s quite simple to make it loop .
>
> symbols> message startup
> message arrived
> message timer> thing mover linkid=1 # thing number
> int CurFrame=0 local
> int numFrames # enter number of frames> flex sleep=1.0 local
> flex speed=3.0 local> end
> code
> startup:
> If (GetCurFrame(mover)==0)
> {
> MoveToFrame(mover,1,speed);
> Return;
> }
> Return;
> arrived:
If (GetSenderId() !=1) return;
> If (IsThingMoving(mover)==1) Return;
> CurFrame = GetCurFrame(mover);
>
> If (CurFrame == numframes)
> {
> MoveToFrame(mover,0,speed);
> Return;
> }
>
> If (CurFrame !=NumFrames)
> {
> Timer(sleep);
> Return;
> }
> Return;> timer:
> MoveToFrame(mover,CurFrame+1,speed);
> Return;
>