Jump to content

BlitzMax + Lua + Framework


Josh
 Share

Recommended Posts

This example shows how to use BlitzMax, Framework, and Lua together seamlessly! ;)

 

Framework is a little different from the main engine. Although it is compiled into the DLL, it is not compiled into the engine module. This allows the programmer to make their own customizations to the code. However, it also means we have to generate a code file of glue functions for Lua to be able to access the Framework commands. The attached example shows how to do this. You can also use this method to expose your own BlitzMax types to Lua!

 

Any time your command set changes, you need to regenerate the Lua glue code. This is done by commenting out the line that includes the glue code, and uncommenting the code that generates it:

'Include "lua-gluefunctions.bmx"
generateGlueCode("lua-gluefunctions.bmx")
End

Then switch the comments back to run the program:

Include "lua-gluefunctions.bmx"
'generateGlueCode("lua-gluefunctions.bmx")
'End

This allows your Lua scripts to access the entire framework command set, as well as your own types.

 

You also need to set the value of the global Lua variable "fw". This is done with the included SetScriptObject() function, which just uses Lua commands to set a variable.

 

The Framework code is distributed as code files instead of a module, mostly because BlitzMax does not allow compiling a module with the name "Framework".

fwtest.zip

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Compiler Error.."Can't find interface for module 'lugi.generator'"

 

Download from here. Run the generator.bmx program in maxide to create the modules inside the .bmx folder. Place those inside the Blitzmax/mod/lugi.mod/generator.mod folder.

 

Granted that line 'Import lugi.generator' is only needed if you need to create a new 'lua-gluefunctions.bmx' file. If you don't need to make a new one, just use the existing 'lua-gluefunctions.bmx' as-is, and it works just fine for getting lua framework commands to work inside bmax. Just don't forget to set all of your SetScriptObjects.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Download from here. Run the generator.bmx program in maxide to create the modules inside the .bmx folder. Place those inside the Blitzmax/mod/lugi.mod/generator.mod folder.

 

Granted that line 'Import lugi.generator' is only needed if you need to create a new 'lua-gluefunctions.bmx' file. If you don't need to make a new one, just use the existing 'lua-gluefunctions.bmx' as-is, and it works just fine for getting lua framework commands to work inside bmax. Just don't forget to set all of your SetScriptObjects.

 

Module LuGI.Generator

 

I get a compile error from this line in the generator. I just got BMX so I know idea what I am doing yet. :blink:

AMD Phenom II x6 1100T - 16GB RAM - ATI 5870 HD - OCZ Vertex 2 60GB SSD

76561197984667096.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...