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. :)
Re: Simple xlua test crashes
Atom I nothing pops up when I double click. Any ideas what could be the reason?
Re: Simple xlua test crashes
Just to be clear when i say double click the icon, that is after you have added it to the Frame Editor with left double click.
An alternative way is to right click the icon/object in the Frame and select "Edit" from the top of the list, this will also open the open the editor.
Usually i just double click though as it is a bit faster, maybe it could be you have a slightly older version of the object if that won't work.
Re: Simple xlua test crashes
Nope that doesn't work either. Nothing pops up. Maybe it's some kind of security mechanism of windows?
Re: Simple xlua test crashes
make sure you have the latest version of xlua.
Re: Simple xlua test crashes
That was it. Even the icon is different now. Thanks again everyone.
Re: Simple xlua test crashes
Did you originally get your old copy from Fusion Updater, by any chance?
Re: Simple xlua test crashes
I don't remember really. The old extention, like the latest one, came in a folder called xlua-dist. Would it be this way if it was downloaded via the Fusion Updater?
Re: Simple xlua test crashes
No, I don't think so. I suppose you must have just downloaded it a long time ago.