Script Language

BlitzMax Forums/BlitzMax Beginners Area/Script Language

vinians(Posted 2010) [#1]
Hi guys!
How are you guys doing??
I trying to create a scripting facility for my application and I was wondering about using LUA script. But I need to know some things about LUA;
-There are tutorials of LUA and BMax integration?
-I not only need to execute LUA script but I need to access my types and funcitions from LUA. So, I need to execute functions, access fields etc...
Thanks in advance!


therevills(Posted 2010) [#2]
Try this:

http://www.blitzbasic.com/Community/posts.php?topic=85952#973606


vinians(Posted 2010) [#3]
Hey thanks therevills!!! Its exaclty what I want, but I need some more explanation of each module function or a tutorial on binding Lua and BMax. I need a way to do this:
-Expose some types to LUA
-Call BMax function from LUA
-Make all script safe, using minimun power from LUA

Or there are another scripting language avaiable for BMax???

Thanks in advance


Volker(Posted 2010) [#4]
Ingame scripting from the code archive. Never tested myself.
http://blitzbasic.com/codearcs/codearcs.php?code=2015


vinians(Posted 2010) [#5]
Hey thanks! I will give it a try :D


N(Posted 2010) [#6]
I would recommend using Lua or BriskVM. The alternatives all kind of suck by comparison. As for Lua, look at LuGI (in my signature) or write all the glue code yourself (at which point all of the responsibility for ease of use and such rests on you). Documentation for the former is in the wiki section of the project, as well.


Robb(Posted 2010) [#7]
I've been thinking about getting into Lua scripting.

Nillium - I tried your LuGi invaders example that was posted above however I get script errors when I run it:

Unhandled Excepton:alien_script.lua:4 '=' expected near 'clamp'

I also tried your lua scriptable type from the code archives and that gives me Max compile errors:

Compile Error: Identifier 'BindFunctionToType' not found

I have the LuGi module correctly installed but I can't seem to fix either of these errors. Any suggestions?


N(Posted 2010) [#8]
BindFunctionToType is part of the core module and was introduced as part of the update to v0.9b. This wasn't previously in the Downloads section (there was no tag for it), so if you downloaded it from there, you were doing it wrong.

The two recommended ways to get the latest version of LuGI at any time are to a) clone the repo (this is the ideal way) or b) click 'Download Source' from the source page (this is the "I can't use git" way). I will never put anything in the Downloads section intentionally because I see no reason to do so when there are already two equivalent ways of getting downloading the source. That said, I've added a tag for 0.9b, so at least that should mitigate future issues with people not understanding github's confusing layout. In the meantime, I should probably write a README, because I never bothered to.

As for the error with the alien script, I don't have a clue about that, because it works (and worked) fine for me.


Robb(Posted 2010) [#9]
Thanks for the reply.

Who'd have thought that 'downloading' the file from the 'downloads' section would be wrong. Github has a serious usability fail right there.

Anyhow I've now updated to v0.9b, built the module, created scriptable_glue.bmx and now woop.bmx gives me a new error:

Unable to create new object of abstract type scriptable.


N(Posted 2010) [#10]
Ah right, forgot I made that abstract.

Probably safe to not make it abstract, but the idea was that you should extend it instead of relying on it solely to provide that sort of thing. At any rate, code archive has been modified accordingly.

Github has a serious usability fail right there.
It's not so much of a usability issue as it is that it automagically creates download archives for any tags I push to the repository. The normal way to get anything off of GitHub is using git, which should be no surprise, since it's in the title of the page. I never use the downloads section because there's simply no reason to put anything in there when you can just clone the repo. If I could completely disable the downloads section, I would. Edit: Turns out I can, this is great!


Zeke(Posted 2010) [#11]
i first started using maxlua (blitxmax own lua module), made some tests and learned lua, but then i figured that its too slow for extreme use. Then Noel wrote Lugi module, and right now im using that. but even Lugi is not "perfect" about generating "glue" code.. so some code i write myself and other code is lugi generated. but im happy how easily i can share bmax types with luam and push/pop bmax types to/from lua stack.

so my suggestion is if you are first time lua user. then check maxlua, BUT dont stay with it any longer than needed. just learn bmax with lua basics.. then move to Lugi module.
if you have any experience with lua then i say, Go straight to Lugi.

and if you need some speed in lua then check my luajit module: http://www.blitzmax.com/Community/posts.php?topic=89186