Lua Table

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua Table

Denis Lamarche
Why do I keep getting an error when I do this. Is there any way of doing it? It keeps telling me that I am trying to index a global.

[Lua]
anim={ {fname="Bmp1.bmp",
       time=100,
       dx=10,
       dy=12},

      {fname="Bmp2.bmp",
       time=300,
       dx=123,
       dy=0}
     }

anim[0].time=300  --This the line that I get the error on.




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


Reply | Threaded
Open this post in threaded view
|

Re: Lua Table

Terence Martin-2
Your problem seems like it's caused by thinking lua arrays work like C ones.
The first element in the array is index 1, not 0. So you're trying to pull
an element that doesn't exist.

----- Original Message -----
From: "Denis Lamarche" <[hidden email]>
To: "Multiple recipients of list" <[hidden email]>
Sent: Sunday, August 05, 2001 3:36 PM
Subject: Lua Table


> Why do I keep getting an error when I do this.  Is there any way of doing
> it?  It keeps telling me that I am trying to index a global.
>
> [Lua]
> anim={ {fname="Bmp1.bmp",
>         time=100,
>         dx=10,
>         dy=12},
>
>        {fname="Bmp2.bmp",
>         time=300,
>         dx=123,
>         dy=0}
>       }
>
> anim[0].time=300  --This the line that I get the error on.
>
>
>
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Lua Table

Diego Nehab-3
In reply to this post by Denis Lamarche
Hi,

Aren't you getting a "attempt to index a nil value" error?

> anim[0].time=300  --This the line that I get the error on.

The first index created automaticaly is 1, so that you should change
the line to

	anim[1].time=300

Regards,
Diego.


Reply | Threaded
Open this post in threaded view
|

Re: Lua Table

Denis Lamarche
In reply to this post by Denis Lamarche
Thanks that was my problem.


From: Diego Fernandes Nehab <[hidden email]>
Reply-To: [hidden email]
To: Multiple recipients of list <[hidden email]>
Subject: Re: Lua Table
Date: Sun, 5 Aug 2001 19:47:45 -0300 (BRT)

Hi,

Aren't you getting a "attempt to index a nil value" error?

> anim[0].time=300  --This the line that I get the error on.

The first index created automaticaly is 1, so that you should change
the line to

	anim[1].time=300

Regards,
Diego.



_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp