| Author | Message | 
        
			| zoidberg 
					Joined: Fri Feb 25, 2011 3:52 pm
 Posts: 39
   |   How to: Tablesi have a global tableindexes in this table are actor's IDs, so they stand not in a serial row
 
 as i know the "for i = 0, #table do" cycle will stop if tried to acces a nil element
 
 how can i cycle through the whole table?
 maybe table.foreach?
 
 
 | 
		
			| Sun Mar 13, 2011 10:55 am | 
					
					   | 
	
	
		|  | 
	
			| CaveCricket48 
					Joined: Tue Jun 12, 2007 11:52 pm
 Posts: 13144
 Location: Here
   |   Re: How to: Tables"for i = 1, #table do" will cycle through all of the table's non-nil items, even if it bumps into a nil one in the middle of cycling. 
 
 | 
		
			| Sun Mar 13, 2011 3:02 pm | 
					
					   | 
	
	
		|  | 
	
			| zoidberg 
					Joined: Fri Feb 25, 2011 3:52 pm
 Posts: 39
   |   Re: How to: Tablesok, i'll try again
 another question:
 is there any sense in using table.remove and table.insert?
 
 
 | 
		
			| Sun Mar 13, 2011 4:36 pm | 
					
					   | 
	
	
		|  | 
	
			| Abdul Alhazred DRL Developer 
					Joined: Tue Aug 11, 2009 5:09 am
 Posts: 395
   |   Re: How to: TablesInsert and remove can shift existing elements. You can read about it here: Lua 5.1 Reference Manual: Table insert One important thing that you may or may not be aware of: Lua Docs wrote: An unsigned char specifying the MOID that this MovableObject is assigned for the current frame only.In my experience the IDs usually stay the same between frames, but there are no guarantees.
 
 | 
		
			| Sun Mar 13, 2011 6:13 pm | 
					
					   | 
	
	
		|  | 
	
			| zoidberg 
					Joined: Fri Feb 25, 2011 3:52 pm
 Posts: 39
   |   Re: How to: Tablesi don't use IDs of multi-framed MOs, but 1-framed actors' IDsbtw, thanks!
 
 
 | 
		
			| Sun Mar 13, 2011 8:47 pm | 
					
					   | 
	
	
		|  | 
	
			| Roast Veg Data Realms Elite 
					Joined: Tue May 25, 2010 8:27 pm
 Posts: 4522
 Location: Constant motion
   |   Re: How to: TablesHe means processing update frames. 
 
 | 
		
			| Sun Mar 13, 2011 9:00 pm | 
					
					   | 
	
	
		|  | 
	
			| zoidberg 
					Joined: Fri Feb 25, 2011 3:52 pm
 Posts: 39
   |   Re: How to: TablesRoast Veg wrote: He means processing update frames.oh... i think i've trapped on that thing (with IDs and frames), cause my script suddenly started to do weird things with an actor which it should ignore (which wasn't added to operated table too)
 
 | 
		
			| Tue Mar 15, 2011 2:43 pm | 
					
					   | 
	
	
		|  | 
	
			| Grif REAL AMERICAN HERO 
					Joined: Sat Jan 27, 2007 10:25 pm
 Posts: 5655
   |   Re: How to: TablesQuestion: Why store actor IDs at all? Why not just GetMOFromID so you have a stable pointer rather than an unstable MOID? 
 
 | 
		
			| Wed Mar 16, 2011 2:48 am | 
					
					   | 
	
	
		|  | 
	
			| zoidberg 
					Joined: Fri Feb 25, 2011 3:52 pm
 Posts: 39
   |   Re: How to: Tablescause it's funny 
 
 | 
		
			| Thu Mar 17, 2011 12:34 pm | 
					
					   | 
	
	
		|  | 
	
			| 411570N3 
					Joined: Wed Jan 07, 2009 10:26 am
 Posts: 4074
 Location: That quaint little British colony down south
   |   Re: How to: TablesThat's probably not a great way to make programming decisions. 
 
 | 
		
			| Thu Mar 17, 2011 12:42 pm | 
					
					     | 
	
	
		|  | 
	
			| zoidberg 
					Joined: Fri Feb 25, 2011 3:52 pm
 Posts: 39
   |   Re: How to: Tablesnevermind. i've made it to work in some other way 
 
 | 
		
			| Thu Mar 17, 2011 12:59 pm | 
					
					   | 
	
	
		|  | 
	
	
		|  |