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 → ARRAY
ARRAY
2005-09-29, 10:18 AM #1
A cog i have written fails when I add too many items to an array list. Right around 130 items it just decides not to do what it does...but under that number it does everything. Is this one of JK's limits?
2005-09-29, 11:14 AM #2
Probably. What are you using the array for? Perhaps you can use the heap instead.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-09-29, 11:44 AM #3
Yeah, I got the same thing when I tried to increase the rbot path node array to 200
I ended up cutting it at 120 nodes

[hypothetical]

What you could try is changing the array variable name partway through...

For example:
Code:
list_a0
list_a1
list_a2
.
.
.
list_a99
list_b0
list_b1
list_b2
.
.
.

What's cool about JK arrays is that the array entries do not have to have the same names.... so, to access 'list_b0', you can use 'list_a0[100]'

Of course, because of that feature, it is possible that this error could also be some sort of symbols limit.... I don't have any info on those limits though.

[/hypothetical]
May the mass times acceleration be with you.
2005-09-29, 4:21 PM #4
I believe that there is a symbol limit.

While I was first making my ship cog I had tons of symbols (don't know how many) and the cog just wouldn't work. I removed some unused symbols and suddenly it worked.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-09-29, 5:05 PM #5
What Emon said, a heap may work better. Post what you need this working for.
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2005-09-29, 11:34 PM #6
Well this uses the heap verb too. I'll display the cog. This is the ridiculous way in which I've made Jedi Knight diplay all the senate platforms of the Galactic Senate Building as you move around the room. I already split up the variables into 2 lists so now its working. Before it tested for the first list to be excluded in all the mumbo-jumbo after the frame jumps occur.


Code:
# Jedi Knight Cog Script


symbols

thing       spinbackdrop0
thing       spinbackdrop1
thing       spinbackdrop2
thing       spinbackdrop3
thing       spinbackdrop4
thing       spinbackdrop5
thing       spinbackdrop6
thing       spinbackdrop7
thing       spinbackdrop8
thing       spinbackdrop9
thing       spinbackdrop10
thing       spinbackdrop11
thing       spinbackdrop12
thing       spinbackdrop13
thing       spinbackdrop14
thing       spinbackdrop15


thing		spinner0
thing		spinner1                              
thing		spinner2                              
thing		spinner3                              
thing		spinner4                              
thing		spinner5                              
thing		spinner6
thing		spinner7
thing		spinner8                              
thing		spinner9                              
thing		spinner10                              
thing		spinner11                              
thing		spinner12                              
thing		spinner13
thing		spinner14
thing		spinner15                              
thing		spinner16                              
thing       spinner17 
thing		spinner18
thing		spinner19                              
thing		spinner20                              
thing		spinner21                              
thing		spinner22                              
thing		spinner23                              
thing		spinner24
thing		spinner25
thing		spinner26                              
thing		spinner27                              
thing		spinner28                              
thing		spinner29                              
thing		spinner30                              
thing		spinner31
thing		spinner32
thing		spinner33                              
thing		spinner34                              
thing       spinner35                            
thing		spinner36
thing		spinner37                              
thing		spinner38                              
thing		spinner39                              
thing		spinner40                              
thing		spinner41                              
thing		spinner42
thing		spinner43
thing		spinner44                              
thing		spinner45                              
thing		spinner46                              
thing		spinner47                              
thing		spinner48                              
thing		spinner49
thing		spinner50
thing		spinner51                              
thing		spinner52                              
thing       spinner53
thing		spinner54                              
thing		spinner55                              
thing		spinner56
thing		spinner57
thing		spinner58                              
thing		spinner59
thing		spinner60
thing		spinner61                              
thing		spinner62                              
thing       spinner63
thing		spinner64                              
thing		spinner65                              
thing		spinner66
thing		spinner67
thing		spinner68                              
thing		spinner69
thing		spinner70
thing		spinner71                              
thing		spinner72                              
thing		spinner73                              
thing		spinner74                              
thing		spinner75                              
thing		spinner76
thing		spinner77
thing		spinner78                              
thing		spinner79                              
thing		spinner80
thing		spinner81                              
thing		spinner82                              
thing		spinner83                              
thing		spinner84                              
thing		spinner85                              
thing		spinner86
thing		spinner87
thing		spinner88                              
thing		spinner89                                                                                                                                                                                                        
thing		spinner90
thing		spinner91                              
thing		spinner92                              
thing		spinner93                              
thing		spinner94                              
thing		spinner95                              
thing		spinner96
thing		spinner97
thing		spinner98                              
thing		spinner99                                                    
thing		spinner100
thing		spinner101                              
thing		spinner102                              
thing		spinner103                              
thing		spinner104                              
thing		spinner105                              
thing		spinner106
thing		spinner107
thing		spinner108                              
thing		spinner109
thing		spinner110
thing		spinner111                              
thing		spinner112                              
thing		spinner113                              
                                                                                       


                                                                                                                    
sector      sec               	 

thing      	player					local


int         i=0						local
int		j=0						local
int         k=0						local
int         m=0						local
int         z=0						local
int         section=-1					local
int         lastsection=-1				local
int		ghost=151					local
int         HeapTotal=0					local
int         HeapTotalHere=0				local
int		Cropped=0					local
int 		lockpulse=0					local

vector     	vec                    			local
flex       	dot                    			local
vector     	pos 			     			local
flex       	y                      			local

vector    	origin					local
vector    	playerpos					local
vector    	playerpos2					local
				

message     startup
message     pulse
message 	trigger

end

# ========================================================================================

code

startup:
	Sleep(0.2);
	player = GetLocalPlayerThing();
	pos = vectorset(1,0,0);
	origin = vectorset(0,0,0);
	HeapNew(GetThingCount()+1000);
		for (m=0; m<114; m=m+1) 
		HeapSet(m+1000, 0.1);
	SetPulse(0.05);
	Return;

Trigger:
	If (GetSourceRef()==55558) 
		{
		HeapTotal=HeapTotal+1;
		PrintInt(HeapTotal);
		HeapSet(HeapTotal, GetParam(0));
		HeapSet(HeapTotal+1000, 0.1);
		HeapSet(HeapTotal*3 , GetParam(1));
		Return;
		}
	Return;


pulse:
	playerpos=GetThingPos(player);
	playerpos2=vectorset(VectorX(playerpos), VectorY(playerpos), 0);
      vec = VectorSub(playerpos2, origin);
	dot = VectorDot(VectorNorm(vec), VectorNorm(pos));
      y = VectorY(vec);
		     if  (dot > 0.951)  section=0;
	      else if  (dot > 0.809)  section=1;	
		else if  (dot > 0.588)  section=2;	
		else if  (dot > 0.309)  section=3;	
		else if  (dot > 0.000)  section=4;	
		else if  (dot > -0.309)  section=5;	
		else if  (dot > -0.588)  section=6;		
		else if  (dot > -0.809)  section=7;		
		else if  (dot > -0.951)  section=8;	
		else if  (dot > -1.000)  section=9;
		     	if (y<0) section = 19-section;
			if ((section==lastsection) || (lockpulse==1)) Return;

		lockpulse=1;
	for(i=0; i<16; i=i+1)
		JumpToFrame (spinbackdrop0, section, sec);
	for(i=0; i<114; i=i+1)
			{
		JumpToFrame (spinner0, section, sec);
			if (HeapTotal>0)	  
					{
				for(j=1 ; j<=HeapTotal; j=j+1)
						{
						if (VectorX(GetThingPos(spinner0))==HeapGet(j))
							{
							teleportThing(spinner0, ghost);
							Print("Second teleport occured");
							HeapSet(j+1000, 1);
							}
						}
					}
			}
  				lastsection=section;
				if (HeapTotal<=0) 
					{
					lockpulse=0;
					 Return;
					}	

				HeapTotalHere=HeapTotal;
				Cropped=0;
			for (k=1; k<=HeapTotalHere; k=k+1)
					{
					if (HeapGet(k+1000)!= 1) 					
						{
						z=k;	
						while((k<=HeapTotal+1) && (z!=0))
						{
							if (HeapGet(k+1000+1)== 1)
							{ 
							HeapSet(z, HeapGet(k+1));
							HeapTotal=HeapTotal-1;
							Cropped=k-z+1;
							z=0;
							} 
								else
								{	
								k=k+1;
								HeapTotal=HeapTotal-1;
								}							
						}
						}
						else 
							{
							HeapSet(k-Cropped, HeapGet(k)); 
							Print("Heap should be replacing value with the same value");
							PrintInt(k);
							PrintFlex(HeapGet(k));
							}			
					 }
				for (m=1; m<=HeapTotal; m=m+1) 
					HeapSet(m+1000, 0.1);
				lockpulse=0;
		Return;


End  


Maybe it could be improved on. It does what I need it to though.
2005-09-30, 10:19 AM #7
You don't need to define all the things as symbols. All that does is pass the thing number of the platform to the COG. So if you have 200 platforms, the first one is thing number 44 and the last one is thing number 244, just pass the COG the first and last thing numbers and have it loop through those. You don't need to define each one. Just make sure that thing numbers 44 through 244 are platforms only, mixing other things in there will obviously cause trouble. Also this assumes the platforms will never get destroyed.
Bassoon, n. A brazen instrument into which a fool blows out his brains.
2005-09-30, 10:57 AM #8
But you see, I've got it working now after splitting 1 for-loop list into 2 for-loops which both use 2 different arrays.

I could do that easily because some of the things that are moved don't need to be processed by the rest of the cog, so those are all in the first for-loop now.
2005-10-01, 6:11 PM #9
Oh wait. Check that last thing I said about it working...
All objects but the very last two objects jump.

↑ Up to the top!