Re: Simple xlua test crashes
You need to export the object before attempting to reference it.
Re: Simple xlua test crashes
I did export it. The object gets repositioned fine, it is the draw function(meant to paste to the background) that crashes the program. If draw() is removed the program runs but doesn't paste to the background.
Re: Simple xlua test crashes
Nope, you need to export it before you call the function. In your code, the line that says "export object with ID = 1" is called after you call function rand. You just need to simply rearrange the order of events so it is called first.
But uh, in general, you should only export an object once- not every single loop. Once the object is exported, xlua will track it on its own until it is destroyed, you don't need to export it each time you want to work with it.
Re: Simple xlua test crashes
Great, works now. moved to the top of the start of frame list. Thanks Pixelthief.
Re: Simple xlua test crashes
Yeah keokeo, I modified it also and it works. May I ask what you were going to do with an XLua example such as this. Or were you just doing this as a learning experience?
Thanks,
Marv
Re: Simple xlua test crashes
Nivram it is just a learning experience. Here's another that wont work:
http://www.mediafire.com/?kg5cw4vifotow9f
Could anyone take a look? It is meant to retrieve the name and width of an active object and display them in a string and counter object. But it just returns 0 no matter what.
Re: Simple xlua test crashes
You need to enable MMF Interface and export the object before you call the function (check action order)
Also you need a "function" keyword before obj() in your lua code to define a function.
Re: Simple xlua test crashes
It was the "function" keyword that was missing after all. I am extremely careless, thank you Retriever2.
Re: Simple xlua test crashes
You should probably use the Embedded Script editor option. To open the editor simply double click the XLua icon and it will make the editor appear.
It's much nicer because you can then have code highlighting and line number etc so it makes writing the code much better than just using a standard string. If you use it also remember to use the Run Embedded Script action so it will start.
If you haven't seen it yet there is the Lua forum also -
http://www.clickteam.com/epicenter/ubbthreads.php?ubb=postlist&Board=89&page=1
Which might be a better place to post i guess but it seems you have things sorted now which is good. :)