GLBasic forum

Codesnippets => Inline / 3rd party => Topic started by: Albert on 2012-Jun-25

Title: LUA 5.2 wrapper
Post by: Albert on 2012-Jun-25
This is my attempt to embed LUA into glBasic in a cross-platform cross-compile way.

Tested in Windows and Android.
Added only some of the LUA commands, and a little set of GLBasic commands for testing purposes.
I hope that one of you interested in and have enough knowledge (more than me) to fix and extend this little sample.

Download with source: https://dl.dropbox.com/u/292449/glbasic/lua/lua1.zip
Install on Android: https://dl.dropbox.com/u/292449/glbasic/lua/lua1.apk

(https://dl.dropbox.com/u/292449/glbasic/lua/lua1.jpg)
Title: Re: LUA 5.2 wrapper
Post by: MrTAToad on 2012-Jun-25
Will be interesting to know if it compiles on a Mac too
Title: Re: LUA 5.2 wrapper
Post by: Albert on 2012-Jun-25
Please sbody try to compile to various platforms and test it. iPhone, linux, MacOS are the main platforms i want to know if compatible

Tapatalk 2-vel küldve az én GT-I9000-ről
Title: Re: LUA 5.2 wrapper
Post by: MrTAToad on 2012-Jun-25
I'll try Linux later on...

Bad news - as it standards, it won't compile - it doesn't find the header files unfortunately.
Title: Re: LUA 5.2 wrapper
Post by: trucidare on 2012-Jun-25
anyone using linux should provide the current headers. so lua will compile fine on linux - on osx is a bit tricky but possible.
Title: Re: LUA 5.2 wrapper
Post by: MrTAToad on 2012-Jun-25
Problem is it wont compile :

Code (glbasic) Select
/cygdrive/C/Users/Nicholas/AppData/Local/Temp/glbasic/gpc_temp1.cpp:54:18: math.h: No such file or directory
In file included from /cygdrive/C/Users/Nicholas/Desktop/lua/src/lapi.c:14,
                 from /cygdrive/C/Users/Nicholas/AppData/Local/Temp/glbasic/gpc_temp1.cpp:56:
/cygdrive/C/Users/Nicholas/Desktop/lua/src/lua.h:12:20: stdarg.h: No such file or directory
/cygdrive/C/Users/Nicholas/Desktop/lua/src/lua.h:13:20: stddef.h: No such file or directory
In file included from /cygdrive/C/Users/Nicholas/Desktop/lua/src/lua.h:16,
                 from /cygdrive/C/Users/Nicholas/Desktop/lua/src/lapi.c:14,
                 from /cygdrive/C/Users/Nicholas/AppData/Local/Temp/glbasic/gpc_temp1.cpp:56:
/cygdrive/C/Users/Nicholas/Desktop/lua/src/luaconf.h:11:20: limits.h: No such file or directory
/cygdrive/C/Users/Nicholas/Desktop/lua/src/luaconf.h:12:20: stddef.h: No such file or directory


I have come across this when using some code with Android - it looks like the compiler believes the path for the headers and code is different from it should be.
Title: Re: LUA 5.2 wrapper
Post by: Albert on 2012-Jun-26
Add to the compiler options:
Code (glbasic) Select
-I"%PROJECT_PATH%\include\linux" -I"%PROJECT_PATH%\include"
These are mingw win32 headers from the glBasic header rar. But I have a lot of problems with them :(
Title: Re: LUA 5.2 wrapper
Post by: Albert on 2012-Jun-26
you can add additional headers into the directory: include\linux
Title: Re: LUA 5.2 wrapper
Post by: Albert on 2012-Jun-26
I've needed to add big subset of glbasic header.rar and a #define LUA_USE_LINUX
Somebody please check this on linux:
https://dl.dropbox.com/u/292449/glbasic/lua/lua_linux.zip

Update: Somebody verified it"s works under linux!
Title: Re: LUA 5.2 wrapper
Post by: Albert on 2012-Jun-26
Screenshot from linux version.
Also I've updated the zip in the first post

(https://dl.dropbox.com/u/292449/glbasic/lua/lua1_linux.jpg)
Title: Re: LUA 5.2 wrapper
Post by: MrTAToad on 2012-Jun-26
Still having trouble getting it to compile for Linux...  Just wont find the headers for some reason...
Title: Re: LUA 5.2 wrapper
Post by: erico on 2012-Jun-26
If you guys would pardon the naive question...

What would be in for having LUA with GLBasic?

Within the little I know, lua is a script language widely used by other applications, like gfx or 3d applications.
What would be the benefits down to GLB?
Title: Re: LUA 5.2 wrapper
Post by: MrTAToad on 2012-Jun-26
Scripting allows a program to be controlled with external code - I want to include a scripting system in TSetup which will allow control of sprites (movement, scaling etc) and text.
Title: Re: LUA 5.2 wrapper
Post by: erico on 2012-Jun-27
ok, sounds promising! :good:
Title: Re: LUA 5.2 wrapper
Post by: Albert on 2012-Jun-27
Ok now I downloaded the lua1.rar to a second laptop, and tried to compile to linux, I have one compiler error, limits.h not found, strange 'cos there are 2 of them already, but in the limits.h there is this row:
Code (glbasic) Select
#include_next "limits.h"
never seemed include_next before, but google says that the compiler look further in the include directories to a secondary limits.h file.
I will check it out today.
Title: Re: LUA 5.2 wrapper
Post by: Hemlos on 2012-Jun-27
Hi this is interesting, first i heard of LUA  :whistle:


Can you tell  me if i got this right....you use LUA to make an image, by typing in commands REALTIME?
Title: Re: LUA 5.2 wrapper
Post by: Falstaff on 2012-Jun-27
Lua is a scripting language, so that means you can have compiled code that reads in other (non compiled) Lua code and execute it. So after your game is packaged and delivered it can still read in new code and do things with it.

Some people might use scripting languages for things like scripting events/sequences in RPG's, and others may find it useful for adding 'modding' support to their game/engine.
Title: Re: LUA 5.2 wrapper
Post by: fuzzy70 on 2012-Jun-27
World of Warcraft is a good example of a game which makes major use of LUA, anything from simple money trackers to completely different UI's, combat/class tools etc.

In fact the entire UI is LUA based & can be laid out however you want with as much or as little info you want. A quick search on Google for world of Warcraft addons will show you exactly how much you can tailor the game for yourself.

The non LUA code just deals with gfx/sound/input/net engine ;-)

Lee

Sent from my GT-I5700 using Tapatalk 2
Title: Re: LUA 5.2 wrapper
Post by: erico on 2012-Jun-27
Like Arexx uh? =D

GraFX2 supports lua too, probably on the filter/extension part of it.
Title: Re: LUA 5.2 wrapper
Post by: Hatonastick on 2012-Jul-04
There's a long list of commercial games that use LUA for scripting.  Even a few on consoles.  I once considered using it for an old, old project of my own.
Title: Re: LUA 5.2 wrapper
Post by: MrTAToad on 2012-Jul-04
It is a pretty good scripting language - would be good to get it working for all platforms!
Title: Re: LUA 5.2 wrapper
Post by: Hatonastick on 2012-Jul-04
I agree.  I was looking at updating my own script language for my latest project but after having had a brief look at this I think I might go with LUA again.  Just depends on whether we can get GLB and LUA to interface properly.  What I would really want is for it to work under Windows and Android -- but not sure it could be done with Android (Hmm? http://www.badlogicgames.com/wordpress/?p=943 (http://www.badlogicgames.com/wordpress/?p=943)).

Still, in my case at least, it's a lot of work for something that wont be used anywhere near its potential.  So maybe I'd be better off converting my old little script/macro language from C to GLB instead...
Title: Re: LUA 5.2 wrapper
Post by: MrTAToad on 2012-Jul-10
And if you want to make said code available, that would also be useful!