Data Realms Fan Forums
http://45.55.195.193/

How to: Tables
http://45.55.195.193/viewtopic.php?f=73&t=21794
Page 1 of 1

Author:  zoidberg [ Sun Mar 13, 2011 10:55 am ]
Post subject:  How to: Tables

i have a global table
indexes 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?

Author:  CaveCricket48 [ Sun Mar 13, 2011 3:02 pm ]
Post subject:  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.

Author:  zoidberg [ Sun Mar 13, 2011 4:36 pm ]
Post subject:  Re: How to: Tables

ok, i'll try again

another question:
is there any sense in using table.remove and table.insert?

Author:  Abdul Alhazred [ Sun Mar 13, 2011 6:13 pm ]
Post subject:  Re: How to: Tables

Insert 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.

Author:  zoidberg [ Sun Mar 13, 2011 8:47 pm ]
Post subject:  Re: How to: Tables

i don't use IDs of multi-framed MOs, but 1-framed actors' IDs
btw, thanks!

Author:  Roast Veg [ Sun Mar 13, 2011 9:00 pm ]
Post subject:  Re: How to: Tables

He means processing update frames.

Author:  zoidberg [ Tue Mar 15, 2011 2:43 pm ]
Post subject:  Re: How to: Tables

Roast 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)

Author:  Grif [ Wed Mar 16, 2011 2:48 am ]
Post subject:  Re: How to: Tables

Question: Why store actor IDs at all? Why not just GetMOFromID so you have a stable pointer rather than an unstable MOID?

Author:  zoidberg [ Thu Mar 17, 2011 12:34 pm ]
Post subject:  Re: How to: Tables

cause it's funny

Author:  411570N3 [ Thu Mar 17, 2011 12:42 pm ]
Post subject:  Re: How to: Tables

That's probably not a great way to make programming decisions.

Author:  zoidberg [ Thu Mar 17, 2011 12:59 pm ]
Post subject:  Re: How to: Tables

nevermind. i've made it to work in some other way

Page 1 of 1 All times are UTC [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/