Author Topic: PLUGIN: Lua for AGS  (Read 39082 times)

Re: PLUGIN: Lua for AGS
« Reply #120 on: 17 Jan 2013, 20:41 »
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...?

"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?

"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.

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...
« Last Edit: 17 Jan 2013, 21:01 by Denzil Quixode »

Re: PLUGIN: Lua for AGS
« Reply #121 on: 17 Jan 2013, 23:00 »
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!
 

Re: PLUGIN: Lua for AGS
« Reply #122 on: 18 Jan 2013, 13:41 »
I do hate to turn away an enthusiastic potential user :/ Thank you so much for documenting the errors you encountered though.

Calin Leafshade

  • AGS Project Tracker Admins
  • Long live King Cat!
    • I can help with making music
    •  
    • I can help with voice acting
    •  
    • Calin Leafshade worked on a game that was nominated for an AGS Award!
      Calin Leafshade worked on a game that won an AGS Award!
Re: PLUGIN: Lua for AGS
« Reply #123 on: 05 Jun 2013, 21:24 »
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.

Re: PLUGIN: Lua for AGS
« Reply #124 on: 13 Jun 2013, 19:00 »
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

  • AGS Project Tracker Admins
  • Long live King Cat!
    • I can help with making music
    •  
    • I can help with voice acting
    •  
    • Calin Leafshade worked on a game that was nominated for an AGS Award!
      Calin Leafshade worked on a game that won an AGS Award!
Re: PLUGIN: Lua for AGS
« Reply #125 on: 13 Jun 2013, 21:03 »
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.

Re: PLUGIN: Lua for AGS
« Reply #126 on: 14 Jun 2013, 06:25 »
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!

Re: PLUGIN: Lua for AGS
« Reply #127 on: 14 Jun 2013, 19:56 »
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: Adventure Game Studio
  1. LuaValueList* results = Lua.Call("getQueueLength");
  2. 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: Adventure Game Studio
  1. LuaValueList* results = Lua.NewValueList();
  2. LuaCallResult status = Lua.Call("getQueueLength", null,  results);
  3. Display(status);
  4. 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?

Re: PLUGIN: Lua for AGS
« Reply #128 on: 10 Jul 2013, 16:13 »
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.
« Last Edit: 10 Jul 2013, 18:49 by dbuske »
What if your blessings come through raindrops
What if your healing comes through tears...

Scavenger

  • Cavefish
  • In Four Glorious Colours!
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with scripting
    •  
    • Scavenger worked on a game that was nominated for an AGS Award!
      Scavenger worked on a game that won an AGS Award!
Re: PLUGIN: Lua for AGS
« Reply #129 on: 30 Nov 2013, 19:13 »
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:

Quote
Adventure 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.

Re: PLUGIN: Lua for AGS
« Reply #130 on: 30 Nov 2013, 21:08 »
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

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: PLUGIN: Lua for AGS
« Reply #131 on: 30 Nov 2013, 21:21 »
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.
« Last Edit: 30 Nov 2013, 21:33 by Crimson Wizard »

Scavenger

  • Cavefish
  • In Four Glorious Colours!
    • I can help with animation
    •  
    • I can help with backgrounds
    •  
    • I can help with characters
    •  
    • I can help with scripting
    •  
    • Scavenger worked on a game that was nominated for an AGS Award!
      Scavenger worked on a game that won an AGS Award!
Re: PLUGIN: Lua for AGS
« Reply #132 on: 30 Nov 2013, 21:51 »
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.
« Last Edit: 01 Dec 2013, 03:18 by Scavenger »

Crimson Wizard

  • AGS Project Tracker Admins
    • Best Innovation Award Winner 2013, for spearheading the AGS 3.3.0 project
    •  
    • Lifetime Achievement Award Winner
    •  
    • Crimson Wizard worked on a game that was nominated for an AGS Award!
      Crimson Wizard worked on a game that won an AGS Award!
Re: PLUGIN: Lua for AGS
« Reply #133 on: 01 Dec 2013, 12:57 »
@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).
« Last Edit: 01 Dec 2013, 13:00 by Crimson Wizard »

Re: PLUGIN: Lua for AGS
« Reply #134 on: 01 Dec 2013, 18:24 »
@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.)

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.
« Last Edit: 01 Dec 2013, 18:27 by Denzil Quixode »

Re: PLUGIN: Lua for AGS
« Reply #135 on: 01 Dec 2013, 22:47 »
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:

Quote
Adventure 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
  1. OSSurface.DrawingColor = <VALUE>

...to this:

Code: Lua
  1. 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.

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.
« Last Edit: 01 Dec 2013, 23:06 by Denzil Quixode »

Calin Leafshade

  • AGS Project Tracker Admins
  • Long live King Cat!
    • I can help with making music
    •  
    • I can help with voice acting
    •  
    • Calin Leafshade worked on a game that was nominated for an AGS Award!
      Calin Leafshade worked on a game that won an AGS Award!
Re: PLUGIN: Lua for AGS
« Reply #136 on: 01 Dec 2013, 22:57 »
GetPixel returns -1 because COLOR_TRANSPARENT is -1 so it just refers to a mask pixel.

Re: PLUGIN: Lua for AGS
« Reply #137 on: 01 Dec 2013, 23:17 »
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)

Re: PLUGIN: Lua for AGS
« Reply #138 on: 02 Dec 2013, 13:40 »
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
  1. local r,g,b = ags.palette.getRGB(3)
  2. ags.palette.setRGB(5, 0,63,0)
  3.  
  4. -- copying a colour from one slot to another
  5. ags.palette.setRGB(30, ags.palette.getRGB(11))

Re: PLUGIN: Lua for AGS
« Reply #139 on: 11 Sep 2014, 14:04 »
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...