i am makeing a coruscant level, and i amde this cog useing arrays (so simple i thoguht) but parsec tells me the lanespeed variables arent assighened, but the array thingy up top did that. also when i tested it... nothing happened. not one fo teh ships moved... i dunno whats wong..
------------------
I am Darth PJB!
well, go on, run away!
i have a plastic lightsaber and a jedi cape.. am i a nerd?
If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
Code:
# JK cogscript
#
# PJ_coru_traffic.cog
#
# cotroles the differet types of
# traffic on the coruscant level
# Beta Vertion, dunno what its gonna
# do quite yet.
#
# ??/jan/2004
#
# [PJB]
flags=0x240 # local only cog, no sync
symbols
int lanespeed0 local
thing lane0ship0
thing lane0ship1
thing lane0ship2
thing lane0ship3
thing lane0ship4
thing lane0ship5
int lanespeed1 local
thing lane1ship0
thing lane1ship1
thing lane1ship2
thing lane1ship3
thing lane1ship4
thing lane1ship5
int lanespeed2 local
thing lane2ship0
thing lane2ship1
thing lane2ship2
thing lane2ship3
thing lane2ship4
thing lane2ship5
int lanespeed3 local
thing lane3ship0
thing lane3ship1
thing lane3ship2
thing lane3ship3
thing lane3ship4
thing lane3ship5
int lanespeed4 local
thing lane4ship0
thing lane4ship1
thing lane4ship2
thing lane4ship3
thing lane4ship4
thing lane4ship5
int lanespeed5 local
thing lane5ship0
thing lane5ship1
thing lane5ship2
thing lane5ship3
thing lane5ship4
thing lane5ship5
int i=0 local
int a=0 local
int shipnum=6
int lanenum=6
int maxlanespeed=20
int minlanespeed=10
int framenum=3
message startup
message arrived
end
code
startup:
// as we are controleing three lanes of traffic over two rows
// eatch lane needs to move at a different speed,uses frame.
for(i=0;i < lanenum; i=i+1)
{
lanespeed0=(rand()*(maxlanespeed-minlanespeed))+minlanespeed;
}
// i am gonna try and use an array here, prehaps it will
// controle the ships like AI, prehaps not, adding key's
// is a possobillity, if i do, they will be for movement
// not the actual flying.
for(a=0;a < lanenum; a=a+2)
{
for(i=0;i < shipnum; i=i+2)
{
if(a==0){ movetoframe(lane0ship0,framenum,lanespeed0[a]); return;}
if(a==1){ movetoframe(lane1ship0,framenum,lanespeed0[a]); return;}
if(a==2){ movetoframe(lane2ship0,framenum,lanespeed0[a]); return;}
if(a==3){ movetoframe(lane3ship0,framenum,lanespeed0[a]); return;}
if(a==4){ movetoframe(lane4ship0,framenum,lanespeed0[a]); return;}
if(a==5){ movetoframe(lane5ship0,framenum,lanespeed0[a]); return;}
}
}
return;
arrived:
for(a=0;a < lanenum; a=a+2)
{
for(i=0;i < shipnum; i=i+2)
{
if(a==0)if(getsenderref()==lane0ship0)if(GetCurFrame(getsenderref())==framenum) movetoframe(getsenderref(),0,lanespeed0);
if(a==1)if(getsenderref()==lane1ship0)if(GetCurFrame(getsenderref())==framenum) movetoframe(getsenderref(),0,lanespeed1);
if(a==2)if(getsenderref()==lane2ship0)if(GetCurFrame(getsenderref())==framenum) movetoframe(getsenderref(),0,lanespeed2);
if(a==3)if(getsenderref()==lane3ship0)if(GetCurFrame(getsenderref())==framenum) movetoframe(getsenderref(),0,lanespeed3);
if(a==4)if(getsenderref()==lane4ship0)if(GetCurFrame(getsenderref())==framenum) movetoframe(getsenderref(),0,lanespeed4);
if(a==5)if(getsenderref()==lane5ship0)if(GetCurFrame(getsenderref())==framenum) movetoframe(getsenderref(),0,lanespeed5);
if(a==0)if(getsenderref()==lane0ship0)if(GetCurFrame(getsenderref())==0) movetoframe(getsenderref(),framenum,lanespeed0);
if(a==1)if(getsenderref()==lane1ship0)if(GetCurFrame(getsenderref())==0) movetoframe(getsenderref(),framenum,lanespeed1);
if(a==2)if(getsenderref()==lane2ship0)if(GetCurFrame(getsenderref())==0) movetoframe(getsenderref(),framenum,lanespeed2);
if(a==3)if(getsenderref()==lane3ship0)if(GetCurFrame(getsenderref())==0) movetoframe(getsenderref(),framenum,lanespeed3);
if(a==4)if(getsenderref()==lane4ship0)if(GetCurFrame(getsenderref())==0) movetoframe(getsenderref(),framenum,lanespeed4);
if(a==5)if(getsenderref()==lane5ship0)if(GetCurFrame(getsenderref())==0) movetoframe(getsenderref(),framenum,lanespeed5);
}
}
return;
end
------------------
I am Darth PJB!
well, go on, run away!
i have a plastic lightsaber and a jedi cape.. am i a nerd?
If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
I am Darth PJB!
well, go on, run away!
i have a plastic lightsaber and a jedi cape.. am i a nerd?
If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?
well, go on, run away!
i have a plastic lightsaber and a jedi cape.. am i a nerd?
If gravity is a crule mistress, and bar tenders with bad grammar are untrustworthy, what is air?

![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)
It also can handle bigger fleet of fighters and ofcourse no limits (adjoin SICK
(the arrays tutorial)
![http://forums.massassi.net/html/biggrin.gif [http://forums.massassi.net/html/biggrin.gif]](http://forums.massassi.net/html/biggrin.gif)

