PLUGIN: Lua for AGS

Started by Denzil Quixode, Fri 04/09/2009 19:30:22

Previous topic - Next topic

Denzil Quixode

#120
Quote from: pietakio on Thu 17/01/2013 00:40:27
in case there are more folks like me who won't be able to use the lua plugin OR play games made with it....
Sure, I understand the potential severity of this... it does seem odd that you're the first person who's had this many problems with it, unless there are others who never bothered to post in the thread...?

Quote from: pietakio on Thu 17/01/2013 00:40:27
"Resolve Partial Assembly failed for Microsoft.VC80.CRT. Reference error message: The referenced assembly is not installed on your system."
As I understand it, this should be taken care of by the msvcr80.dll/Microsoft.VC80.CRT.manifest files that should also be found in the AGS editor folder after a normal installation. I'm no expert, though... hmm, does copying the msvcr*/msvcrm*/*.manifest files to the game project's "compiled" and "debug" folders help anything?

Quote from: pietakio on Thu 17/01/2013 00:40:27
"LuaValueList is not a public member of 'Lua'. Are you sure you spelt it correctly"
That's very weird, like the lscripts.dat error... it almost sounds like the script header is getting corrupt somehow.

Quote from: pietakio on Thu 17/01/2013 00:40:27
Running the "dependency walker" on the lua dlls in this system says GPSVC.dll and IESHIMS.dll are missing
Hmm, for me, dependency walker only mentions KERNEL32.dll and MSVCRT80.dll. It sounds like maybe you have a problem with the Microsoft Visual C Runtime (MSVCR) on both machines, but unfortunately, again, I'm no expert on it...

pietakio

Hey thanks again for your help, and yes, it is probably only some weird windows issue with my machines. 

A great idea and job with the lua plugin though, and I'm sad that I can't use it, but AGS-script will probably be fine in the end.

Thanks!
 

Denzil Quixode

I do hate to turn away an enthusiastic potential user :/ Thank you so much for documenting the errors you encountered though.

Calin Leafshade

It seems that loadscript doesnt return an error message. Is there anyway to see if a file exists in the script store? Currently it seems impossible to tell whether loadscript failed because the file does not exist or because there was a compilation error.

bslinger

I just started using the Lua plugin for a game prototype I'm working on after getting frustrated with the limits of AGS Script - it's working great so far, except when I compiled the game and sent it to one of our writers to check out, he got the "lscripts.dat signature mismatch" error mentioned by pietakio. Any ideas on what could be causing that, do we have to distribute some extra .dlls with the game or something? I was glad to find a solution to my AGS problems but if it's not going to reliably work on a variety of machines I'm not sure it's going to be viable. Hopefully we can find a solution, I really can't be bothered writing an adventure game engine in scratch in Unity! :)

Calin Leafshade

Try doing a rebuild all files and be sure to send him the files from the Compiled folder.

If you run the game again in debug I think it invalidates the stuff in the compiled folder because the lua plugin writes a new version of the lscripts.dat.

bslinger

Quote from: Calin Leafshade on Thu 13/06/2013 21:03:08
Try doing a rebuild all files and be sure to send him the files from the Compiled folder.

If you run the game again in debug I think it invalidates the stuff in the compiled folder because the lua plugin writes a new version of the lscripts.dat.

Thanks, looks like that was the problem!

bslinger

Is the documentation on the wiki still up to date? I'm having trouble getting return values from my Lua functions called from AGS Script.

I initially tried this, based on the example here: http://lua-for-ags.wikispaces.com/IntroducingLuaValueLists

Code: AGS

LuaValueList* results = Lua.Call("getQueueLength");
int queueLength = Lua.AsInt(results);


But AsInt doesn't seem to exist as a function of the Lua object.

I then tried to use the examples from here: http://lua-for-ags.wikispaces.com/UsingLuaForAGS

Code: AGS

LuaValueList* results = Lua.NewValueList();
LuaCallResult status = Lua.Call("getQueueLength", null,  results);
Display(status);
Display(results.AsInts[1]);


but that gives me "Error (line 183): Type mismatch: cannot convert 'LuaValueList*' to 'LuaCallMode'" because it seems like the function signature doesn't line up with the documentation.

Any advice?

dbuske

#128
If another scripting language was used in AGS, would it be implemented in the same way?
Meaning it being tied to the editor in the same way.
AGS scriting is far easier then other scripting.
What if your blessings come through raindrops
What if your healing comes through tears...

Scavenger

Hey, I've been using the Lua plugin for a couple of days now, and I'm loving it's speed - this is the best thing for complex scripting. AGS Script has nothing on it.

However, I've been having a few problems with it.

Firstly, if you rename a script, it will duplicate the entry and deleting one of the entries will crash AGS and remove "both" scripts.

Secondly, I've been having some problems with the project getting corrupted if AGS doesn't crash cleanly. In 3.3.0, at least, if the engine stalls and needs to be shut down manually (prompting the "The AGS engine did not shut down properly" error in AGS), any Lua calls will crash a few loops in with:

QuoteAdventure Game Studio
---------------------------
An internal error has occurred. Please note down the following information.
If the problem persists, post the details on the AGS Technical Forum.
(ACI version 3.3.0.1148)

Error: [Lua] [string "local select = select;local error = error;l..."]:1: bad argument #2 to 'setter' (number expected, got nil)

I've included a copy of the ruined project here: https://dl.dropboxusercontent.com/u/50882197/Game/paltest_ruined.zip

Other than that, it's brilliant, and I love it! I want to continue using Lua for engine-intensive code.

Denzil Quixode

Yes, the renaming bug is an embarrassingly old one - I need to fix that, sorry!! :-[

I will have a look at the corrupted project though, I haven't seen that happen before...

Crimson Wizard

#131
This might as well be AGS 3.3.0 error.
Uh, sorry, I had to read the Scavenger's post more carefully. The crash might be the AGS 3.3.0 error, but the corruption is something I have no idea about.

Scavenger

#132
Additional suggestion: Can we get the 8 bit palette arrays accessable in Lua? I'm currently working on a module that relies on the palette and Lua doesn't have access to it (I tried ags.palette.r etc and it came up with nothing).

Also, LuaValueList.ToArray() seems to be missing from the copy of the plugin on the Downloads page? It doesn't show up in Autocomplete, and it doesn't compile, but it IS in the documentation.

Lua.Evaluate is also missing.

Crimson Wizard

#133
@Denzil Quixode, your lua-for-ags wiki states:
Quote
The run-time component is a DLL called agslua.dll. This DLL needs to be present in the same directory as your game when it runs, as well as lua51.dll and lua5.1.dll, which agslua.dll depends on. (These should hopefully all be copied in automatically.)
However lua51.dll is never copied to Compiled folder, and game seem to run without it as well.


Another thing I should mention just in case: the game will crash badly if the script .dat file is missing (AGS 3.2.1).

Denzil Quixode

#134
Quote from: Crimson Wizard on Sun 01/12/2013 12:57:00
@Denzil Quixode, your lua-for-ags wiki states:
Quote
The run-time component is a DLL called agslua.dll. This DLL needs to be present in the same directory as your game when it runs, as well as lua51.dll and lua5.1.dll, which agslua.dll depends on. (These should hopefully all be copied in automatically.)
However lua51.dll is never copied to Compiled folder, and game seem to run without it as well.
Ah, oops, thank you, I've changed it. (This was originally true, there WERE two DLLs, because of some confusing issue where some things want to link against "lua51" rather than "lua5.1" -- but once I realised it shouldn't affect this plugin, I removed the extra DLL copy, which only acted as a proxy to the other DLL anyway.)

Quote from: Crimson Wizard on Sun 01/12/2013 12:57:00
Another thing I should mention just in case: the game will crash badly if the script .dat file is missing (AGS 3.2.1).
Thanks for the report, I'll start adding these things to the github tracker.

Denzil Quixode

#135
Quote from: Scavenger on Sat 30/11/2013 19:13:25
I've been having some problems with the project getting corrupted if AGS doesn't crash cleanly. In 3.3.0, at least, if the engine stalls and needs to be shut down manually (prompting the "The AGS engine did not shut down properly" error in AGS), any Lua calls will crash a few loops in with:

QuoteAdventure Game Studio
---------------------------
An internal error has occurred. Please note down the following information.
If the problem persists, post the details on the AGS Technical Forum.
(ACI version 3.3.0.1148)

Error: [Lua] [string "local select = select;local error = error;l..."]:1: bad argument #2 to 'setter' (number expected, got nil)

I've included a copy of the ruined project here:
Thank you very much for the test case!

So, I have to apologise for that error message. I know there's no way you would be able to guess this, but the actual problem here is that you end up assigning nil to OSSurface.DrawingColor in your ProcessTranslucency() function.

I will have to do something about that error message, so it actually shows your script/line number (instead of blaming the internal script that handles the "DrawingColor" getter/setter)

For now, you can do a temporary workaround get better error messages here by changing lines like this:

Code: lua
OSSurface.DrawingColor = <VALUE>


...to this:

Code: lua
OSSurface.DrawingColor = assert(  <VALUE>  ,'DrawingColor cannot be nil')


Digging in a bit, it looks like BGSurface:GetPixel(x,y) is returning -1 sometimes, and this leads to it looking up clut[ i ][ j ] for a negative j, which is where the nil value comes from. I'm afraid I have no idea whether GetPixel returning -1 is something that should ever happen or why it would be related to project corruption or 3.3.0, etc.

Quote from: Scavenger on Sat 30/11/2013 21:51:50
Also, LuaValueList.ToArray() seems to be missing from the copy of the plugin on the Downloads page? It doesn't show up in Autocomplete, and it doesn't compile, but it IS in the documentation.

Lua.Evaluate is also missing.
I must apologise for this too - I changed my mind several times on how the whole LuaValueList/LuaValue API stuff should work, and was inconsistent about both implementing and documenting features in it, as things got rewritten and moved around... I plan to move all the documentation and stuff over to GitHub soon, and as part of that I will double-check everything in the docs as I do it, so there's no more nasty surprises like this.

Calin Leafshade

GetPixel returns -1 because COLOR_TRANSPARENT is -1 so it just refers to a mask pixel.

Denzil Quixode

Quote from: Calin Leafshade on Sun 01/12/2013 22:57:31
GetPixel returns -1 because COLOR_TRANSPARENT is -1 so it just refers to a mask pixel.
That makes sense, but seems odd since we're talking about what I assume is a room background surface -- do room backgrounds have transparency masks?

(That's probably something to discuss further in the Advanced Technical Forum thread about this, which I've only just noticed)

Denzil Quixode

Quote from: Scavenger on Sat 30/11/2013 21:51:50
Additional suggestion: Can we get the 8 bit palette arrays accessable in Lua? I'm currently working on a module that relies on the palette and Lua doesn't have access to it (I tried ags.palette.r etc and it came up with nothing).
I've made changes to the code (there'll be a new build soon) to allow ags.palette[ i ].r etc. to work, and also a (probably faster) alternative form that uses Lua's multiple-return value feature:
Code: Lua
local r,g,b = ags.palette.getRGB(3)
ags.palette.setRGB(5, 0,63,0)

-- copying a colour from one slot to another
ags.palette.setRGB(30, ags.palette.getRGB(11))

dbuske

Ok, I converted the intro room script to Lua.
Do I put the Lua code in place of the original ags room code.
Or is their more?
What if your blessings come through raindrops
What if your healing comes through tears...

SMF spam blocked by CleanTalk