Jump to content

BlitzMax and custom Lua commands


Josh
 Share

Recommended Posts

The Lua command set exposure is a little tricky when you get into multiple levels of command sets, like when you have the engine command set, and you want to expose something else beyond that, like the Framewerk commands.

 

The attached example shows how Lua command set generation works. To expose types, all you have to do is add an "expose" tag in the meta data. To expose procedural functions, you add the functions as a method in a type with the "noclass" setting. To generate your command set file, do this:

 

generateGlueCode("lua-gluefunctions.bmx")
End

 

To run your program with the command set, do this:

Include "lua-gluefunctions.bmx"

 

I just include all three lines together, and comment them out depending on what I am doing:

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

 

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

 

Any time you make changes to any of your exposed class commands, you have to generate a new lua command set file. Otherwise your program might not even compile, because it will have function declarations that don't match the commands you changed.

 

Does this make sense? I could pull the Lua commands out of the engine and make this a requirement of any BlitzMax program that uses Lua. It's a little more complicated, but it allows you to change the commands I have exposed, add ones that may be missing, or expose your own types. For example, if you imported the framewerk module and generated the command set, you would have access to all the framewerk commands in Lua. This is how the editor and interpreter do it.

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

I keep getting errors because it doesn't find the interface for module "lugi.generator" if I do it like this:

Framework leadwerks.ENGINE
Import lugi.generator
Import "luacommands.bmx"
Include "lua-gluefunctions.bmx"
'generateGlueCode("lua-gluefunctions.bmx")
'End

 

If I comment this line out and the use the generateGluecode, I get an error that it doesn't recognize the generateGluecode command.

Framework leadwerks.ENGINE
'Import lugi.generator
Import "luacommands.bmx"
'Include "lua-gluefunctions.bmx"
generateGlueCode("lua-gluefunctions.bmx")
End

 

If I comment out the generateGluecode/End and lugi.generator, and include the "lua-glufunctions.bmx" then it works.

Framework leadwerks.ENGINE
'Import lugi.generator
Import "luacommands.bmx"
Include "lua-gluefunctions.bmx"
'generateGlueCode("lua-gluefunctions.bmx")
'End

 

So where do I get the lugi.generator module? I assume this contains the generategluecode command? and yes I have the lugi module inside the blitzmax module folder...

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

You can get the LuGI modules at http://github.com/nilium/lugi.mod. 0.9b should work with Leadwerks, but you may wish to clone and use the stable-0.8 tagged revision instead just for consistency's sake, since I don't believe Leadwerks is using 0.9b (yet, perhaps).

MacBook Pro 15.4", Intel Core 2 Duo T9600 2.80GHz, 4GB 1066MHz DDR3, GeForce 9400M 256MB, GeForce 9600M GT 512MB - Mac OS 10.6.2, Vista32

Link to comment
Share on other sites

You can get the LuGI modules at http://github.com/nilium/lugi.mod. 0.9b should work with Leadwerks, but you may wish to clone and use the stable-0.8 tagged revision instead just for consistency's sake, since I don't believe Leadwerks is using 0.9b (yet, perhaps).

 

do i just download the generator.mod and place that in the blitzmax mod folder for lugi.mod folder? sorry, I am not sure I understand what you mean when you say clone?

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

do i just download the generator.mod and place that in the blitzmax folder? sorry, I am not sure I understand what you mean when you say clone?

Start reading about git, or click 'Download' (not Downloads) and pick something.

MacBook Pro 15.4", Intel Core 2 Duo T9600 2.80GHz, 4GB 1066MHz DDR3, GeForce 9400M 256MB, GeForce 9600M GT 512MB - Mac OS 10.6.2, Vista32

Link to comment
Share on other sites

That file contains a type that declares all the procedural functions, since they aren't part of a class.

 

so this is the correct way to do it?

Framework leadwerks.ENGINE
Import lugi.generator
Import "luacommands.bmx"
Import leadwerks.framewerk
'Include "lua-gluefunctions.bmx"
'generateGlueCode("lua-gluefunctions.bmx")
'End
GenerateGlueCode("BMAX2luaFramewerk.bmx")
End

 

then include the "BMAX2luaFramewerk.bmx" from now on?

 

 

***edit--- ok that didn't work. The generated file still didn't allow skybox or water properties to be automatically created in bmax... So I assume I am doing something wrong. But in any case, this seems like this should already be built-in, especially if core objects in the editor are going to use framewerk methods. I realize this will probably eventually happen, and that it will just take time to do so... Seems like having the entire framewerk built in lua is a must if you expect users to be able to share scripted models with each other easily.

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

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