Jump to content
  • Advertisement
Sign in to follow this  
raydog

tolua allocated pointer problems

This topic is 4849 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Using lua 5.0.2 and tolua, i'm trying to access an allocated pointer (int *integers) in a global variable (mytest). I allocate the pointer in C, and try to access the values in my lua script: -- indices are 1-based for i=1,mytest.num_integers do printf( "integers: %d\n", mytest.integers ); end However, I get an error: test.lua:17: attempt to index field '?' (a nil value) How can I get this to work? My class: class MYTEST { public: int num_integers; int *integers; }; extern MYTEST mytest; I allocate the global variable before calling my script, so I don't why it's telling me the pointer is nil: mytest.num_integers = 10; mytest.integers = new int[mytest.num_integers]; for(int i=0; i < mytest.num_integers; i++) { mytest.integers = i; } [Edited by - raydog on March 10, 2005 10:22:03 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!