Josh Posted November 30, 2009 Share Posted November 30, 2009 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 Quote 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 More sharing options...
macklebee Posted December 4, 2009 Share Posted December 4, 2009 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... Quote 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 More sharing options...
Nilium Posted December 4, 2009 Share Posted December 4, 2009 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). Quote 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 More sharing options...
macklebee Posted December 4, 2009 Share Posted December 4, 2009 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? Quote 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 More sharing options...
Nilium Posted December 4, 2009 Share Posted December 4, 2009 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. Quote 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 More sharing options...
macklebee Posted December 4, 2009 Share Posted December 4, 2009 thanks... i grabbed the 0.8 version and built/documented that in bmax and Josh's example appears to work now... appreciate it. Quote 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 More sharing options...
macklebee Posted December 5, 2009 Share Posted December 5, 2009 any chance to get an example of how the bmax framewerk can be implemented this way? Quote 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 More sharing options...
Josh Posted December 5, 2009 Author Share Posted December 5, 2009 Import framewerk and do what I did. It will automatically detect the exposed types. Quote 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 More sharing options...
macklebee Posted December 5, 2009 Share Posted December 5, 2009 Import framewerk and do what I did. It will automatically detect the exposed types. what is the "luacommands.bmx" needed for? Do we need that if we use bmax framewerk with lua? Quote 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 More sharing options...
Josh Posted December 5, 2009 Author Share Posted December 5, 2009 That file contains a type that declares all the procedural functions, since they aren't part of a class. Quote 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 More sharing options...
macklebee Posted December 5, 2009 Share Posted December 5, 2009 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. Quote 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 More sharing options...
Josh Posted December 6, 2009 Author Share Posted December 6, 2009 Yeah, I'll have some examples soon. I have to rearrange some of the script stuff right now. Quote 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 More sharing options...
macklebee Posted December 6, 2009 Share Posted December 6, 2009 Yeah, I'll have some examples soon. I have to rearrange some of the script stuff right now. understand. Quote 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 More sharing options...
Recommended Posts
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.