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 → Create, Stop, NoRand and NoSlow.
Create, Stop, NoRand and NoSlow.
2003-10-11, 6:29 AM #1
Hi!
I have a COG here that moves a crate across a conveyor belt. But, things happen!
Code:
# Crates on Conveyor belt
#
# By Edward
symbols

message		startup
message		arrived
message		removed

thing		create

thing		c	local

flex		speed

int		numframes

int		turnframe0=0
int		turnframe1=0
int		turnframe2=0
int		turnframe3=0

int		usedtf

template	crate0
template	crate1
template	crate2
template	crate3
template	crate4
template	crate5
template	crate6
template	crate7
template	crate8
template	crate9
template	crate10
template	crate11
template	crate12
template	crate13
template	crate14
template	crate15

int		numcrates

int		i		local

int		frame=0		local

end
#
code
startup:
	sleep(1);
	c=CreateThing(crate0[rand()*numcrates],create);
	CaptureThing(c);
	MoveToFrame(c,1,speed);
	frame=0;
return;
arrived:
	If(GetSenderRef()!=c) return;
	frame=frame+1;
	if(usedtf!=0)
	{
		for(i=0; i<usedtf; i=i+1)
		{
			If(GetCurFrame(c)==turnframe0)
			{
				MoveToFrame(c,turnframe0+1,1);
			}
			else
			{
				MoveToFrame(c,frame+1,speed);
			}
		}
	}
	if(GetCurFrame(c)==numframes)
	{
		DestroyThing(c);
		c=CreateThing(crate0[rand()*numcrates],create);
		CaptureThing(c);
		MoveToFrame(c,1,speed);
		frame=0;
	}
return;
removed:
	If(GetSenderRef()!=c) return;
	c=CreateThing(crate0[rand()*numcrates],create);
	CaptureThing(c);
	MoveToFrame(c,1,speed);
	frame=0;
return;
end


The ghost (create) has 6 frames (5 if you don't count the first one), and when I look in the hole where they are supposed to come out, the first crate is stuck on frame 2 (1), and the other crates come normally, but aren't random!
And when the crates come to turnframe0 (wich is 2 (1)) they won't slow down to speed 1. But they will slow down at turnframe1 (which is 4 (3)). Help!

/Edward
------------------
I'm addicted to the following things:
Computers
Coca Cola/Jolt Cola
JK
Edward's Cognative Hazards
2003-10-22, 9:41 PM #2
Can anyone help???
Edward's Cognative Hazards
2003-10-23, 4:40 PM #3
take out the removed part and that should fix the crate getting stuck.

to fix the random thing make sure that all the crate0 - crate15 templates have something in them, even if they just start repeating.
when i tested it if i didnt have them all filled in it would only make the first one.
dont know why that is.

when i was testing it the crates seemed to slow down for the turns just fine, sorry no idea whats wrong there.

try the other things and see if they help.

------------------
Famous last words - "It seemed like a good idea at the time."

[This message has been edited by DSLS_DeathSythe (edited October 23, 2003).]
Famous last words - "It seemed like a good idea at the time."
2003-10-24, 2:46 AM #4
Ah, thanks... But I think I need that removed message. You see, one of the things I'm creating is a fuel tank, and if that blows up, the cog won't register the end of the line for that 'crate'. So, how do I do this?

/Edward
Edward's Cognative Hazards
2003-10-24, 2:53 AM #5
Just brainstorming...but here's an idea.

Make the crate appear to be destroyed but not actually do so.

Add a class cog for the crate that captures damage, always returns zero. When the crate is 'destroyed' set its flags to invisible and collide type to 0. That way its there still to capture frames, but it doesn't appear to be there.

Just an idea.

------------------
-El Scorcho

"Its dodgeball time!" -Stormy Waters
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2003-10-24, 3:05 AM #6
OK, guess what!
I added another turn and the first and second turn, moved at speed 'speed' but the last turn moved at speed 1.

/Edward
Edward's Cognative Hazards
2003-10-24, 7:42 AM #7
if you want to keep the removed part then take out the CreateThing() above the removed message.
so that part of the cog would look like this:
Code:
     if(GetCurFrame(c)==numframes)
       {
       DestroyThing(c);
       }
return;
removed:
     If(GetSenderRef()!=c) return;
     c=CreateThing(crate0[rand()*numcrates],create);
     CaptureThing(c);
     MoveToFrame(c,1,speed);
     frame=0;
return;
end

still have no idea how to fix the turn speed problem, maybe you could try using RotatePivot() instead of MoveToFrame() when the crates are supposed to turn.

------------------
Famous last words - "It seemed like a good idea at the time."
Famous last words - "It seemed like a good idea at the time."
2003-10-24, 9:48 AM #8
Thank you for the remove thing. Now the turn, it isn't just turning like on a turn-table, it is turn and move, like when it is touching 2 conveyer belts at the same time. One pushing the crate fowards and one pulling it to the... left... Hang on... If the pull at the same speed, then the crate should turn at the same speed... Only problem is that the turning has a max-free-speed. If I try to MoveToFrame during a frame that changes the PYR at a speed of 100, it will not turn at that speed. Why is that?

/Edward
Edward's Cognative Hazards

↑ Up to the top!