PDA

View Full Version : Lua Compatabiliy



S Ferguson
January 26th, 2013, 22:31
I know that FG has Lua 5.1 capabilities built into it, but I also know that semi-colons aren't part of the Lua language. I'm interested in porting a few extraneous files from their native Lua, to FG's Lua. Any pitfalls that anyone has encountered?

Moon Wizard
January 26th, 2013, 22:35
FG uses v5.1.4 of Lua under the hood, so anything that works in that version of Lua should run in FG script code.

Regards,
JPG

S Ferguson
January 26th, 2013, 22:39
Not to be picky, but does file requirement, and lines like:

local chatOut = .addChatMessage

to make the code more readable?

Moon Wizard
January 26th, 2013, 23:09
Depends. It potentially makes the code more readable in some situations, but it also introduces complexity for people trying to understand code in other situations. Sort of a wash in my mind.

Cheers,
JPG

S Ferguson
January 26th, 2013, 23:18
I'll write it *very* carefully. I promise.:D

phantomwhale
January 27th, 2013, 00:35
I know that FG has Lua 5.1 capabilities built into it, but I also know that semi-colons aren't part of the Lua language

I've been taking all those nasty semi-colons out of the Savage Worlds code base. Less clutter = more readable. As far as I am aware, Lua just ignores them anyway, and as long as you stick to one statement per line, it's all good

S Ferguson
January 27th, 2013, 01:15
That's what I was finding. The semi-colons were producing more errors than benefits. Bad semi-colon, bad :mad:.

S Ferguson
January 27th, 2013, 01:40
Oh and "require" doesn't seem to operarate from FG.

phantomwhale
January 27th, 2013, 02:01
Oh and "require" doesn't seem to operarate from FG.

dofile is out for FG scripting, so I suspect require is out too: https://www.fantasygrounds.com/modguide/scripting.xcp

S Ferguson
January 27th, 2013, 04:17
Yep. No luck with Modules and "require" either. The limitations seems to make the programming more cumbersome in some places, terse in others.

S Ferguson
January 27th, 2013, 15:55
And some of the higher level functions I've seen in libraries, surprisingly few and far between, use the metatable functions to build macros. Given the language's original reliance on C and C++, the "excised" version mabye safer and faster for overall FG performance, but poor for porting code from "standard" Lua 5.1.

Of the code I've come across in my travels on the wire, it seems that simple "example" programs are the ones that seem to work.