Cog is running forward then backward..help!


[ Follow Ups ] [ Post Followup ] [ Jed Messages ]

Posted by Elanthil01 on February 23, 1998 at 14:08:35:

Ok. this is getting rediculous.

Every cog I make for patrolling runs PERFECTLY forward through the frames.

The PROBLEM is it then runs through the frames in reverse before running through em forward again (these are infinite loop cogs).

I will list a small version of a cog below:

save the below text as: 6FRAME_THING_PATROL.COG

symbols
message startup

thing elevator desc=elevator_object
flex speed=2.0 desc=movement_speed
flex waittime=4.0 desc=wait_time_at_stop

int CurFrame=0 local desc=not_used_yet

end

#COG code section
code

//-----------------------------------------------------------------------------
# while (1) causes this entire section to be repeated infinitely
# waitforstop pauses the cog till the item finishes its current movetoframe
# sleep(waittime) pauses the cog between moves for the specified (waittime)

startup:
while (1) {
movetoframe(elevator, 0, speed);
waitforstop(elevator);
sleep(waittime);
movetoframe(elevator, 1, speed);
waitforstop(elevator);
sleep(waittime);
movetoframe(elevator, 2, speed);
waitforstop(elevator);
sleep(waittime);
movetoframe(elevator, 3, speed);
waitforstop(elevator);
sleep(waittime);
movetoframe(elevator, 4, speed);
waitforstop(elevator);
sleep(waittime);
movetoframe(elevator, 5, speed);
waitforstop(elevator);
sleep(waittime);

}

return;

end

Very simple cog, although to use more frames, you have to copy the entire 3 line setting from waitforstop through movetoframe and change the frame number.
This can make for some humongous scripts (I have a 100 frame script sitting on the harddrive for a huge level..wanna talk about a lotta typing and number crunching? yeesh)

Now..can someone kindly tell me how to make the cog repeat from frame 1 instead of cycling in reverse?
________________________________________________________________________________

Since I KNOW folks are gonna post/email about how to use a cog, I'll put this below, Cogking and the others..feel free to reply and add to/modify what I put below :D

HOOKING UP THE ABOVE COG TO AN ITEM TO MAKE IT ROAM AROUND

To set up the 'thing' to be run by this script, run JED, open your project, place a 'thing' on the map, check its coordinates, then click on add value in the 'thing editor' window.

A window pops up saying THINGFLAGS. hit return

Add a value again, this time call it NUMFRAMES then hit return

in the box nex to numframes, type in the total number of frames you wish the item to move. count the first frame (start frame) as frame 1 for this.
(in the script, the first coord values in the things 'frame' fields is counted as 'frame 0), meaning if you type in 6 frame values in the thing editor, you actually only have 5 frame steps to configure in the cog plus the starting frame referred to as '0')

for each frame you will use, including the 'start frame' you must add a value in the thing editor. each of these values will be named 'frame'.

in this cogs case, you need to create 6 data fields, each called 'frame'

in the data field to the right of the word 'frame' for each value 'frame' you add, you will need a complete set of coordinates.

For the first coordinate set, hit 'copy as frame' click on the data field of the first value 'frame' and hit ctrl+insert or ctrl+v to paste the values there.

to make things easier, just go to the data field next to EVERY 'frame' youve added and hit ctrl+v or ctrl+insert. This will give you default values in each field the same as the first one.

To begin editing your frames, click in the second 'frame' settings data box. the entire string should be highlighted. wait for about a second then click in that box again, this will unhighlight the box and give you an editing cursor.

Move the cursor to the coordinates you want to change and do so. this will let you alter the coordinates to make this frame a different x,y,z,roll,pitch,yaw coordinate. this becomes frame 2 (or frame '1' in the cog interpreter)

just keep modifying the frames in each data field to get what you want.

go to tools, select placed cogs, on the left window click on 'project directory' (instead of resource2) and select the cog from the list then assign the things number to the field 'thing', set the speeds to what you want, click on the cog name to highlight it, click 'refresh' then save and gob yer level!

voila..




Follow Ups:



Post a Followup

Name:
E-Mail:
Subject:
Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ Jed Messages ]