🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Arrays under LUA

Started by
3 comments, last by Prozak 20 years, 3 months ago
Would like to know how to implement arrays under LUA, both in C++''s side, how to "pop" them onto a normal C++ array, and on the LUA side, how to access them, create them and work with them. Thanks for any pointers on this... Salsa cooked it, your eyes eat it! [Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
Prozak - The GameDever formally known as pentium3id
Advertisement
Sorry, forgot to mention the context of this.

I''m developing a "LUA Vertex-Shading Language", to test out and debug very simple vertex shaders. I''m tentavely calling it LuShade.

LuShade on version 1.0 will have the following caracteristics:
- Its a per-vertex shader
- Its designed for very-low complexity meshes
- Has access to:
* Position
* Normal
* Color
* tUV1 (texture 1 UV coordinates)
* tUV2 (2nd texture)
* Matrices (usual transformation matrices)
* Parameters (user-defined parameters, like LightPosition for example)
- Has a dedicated vertex, matrix and shader-oriented function library, to access textures, perform dot products, etc...

As you can see in the above list, many of these variables are either a float4 vector or a float4x4 matrix, and I need information on using float-resolution variables under LUA, is it possible? I have only had experience with integers...

Don''t know if anyone is interested in LuShade, as i''m developing it to debug/test shaders in my own engine... if anyone is interested in lending a helping hand...

Anyways, all I need help with at this moment is:
- Arrays under LUA 5 "how to", on C++ side and LUA side
- Float-resolution variables under LUA 5.

Thanks for any replies

Salsa cooked it, your eyes eat it! [Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
Prozak - The GameDever formally known as pentium3id
I moved this to Scripting Languages and Mods because this is where most of the Lua users post.
Thanks Kylotan, hadnt noticed that...

Salsa cooked it, your eyes eat it! [Hugo Ferreira][Positronic Dreams][Colibri 3D Engine][Entropy HL2 MOD][My DevDiary]
[Yann L.][Enginuity] [Penny Arcade] [MSDN][VS RoadMap][Humus][BSPs][UGP][NeHe]
Prozak - The GameDever formally known as pentium3id
A Lua table contains an array to store its integer keys. You can treat a table just like an array, and access it from C with the gettable and settable functions.

Note that array subscripts in Lua start from 1. Read here for more details.

Alternatively, you can expose a C array to Lua as a userdata, by writing an appropriate metatable. Read the manual for more details.

"Sneftel is correct, if rather vulgar." --Flarelocke

This topic is closed to new replies.

Advertisement