LUA for BlitzMax v1.0
BlitzMax Forums/BlitzMax Module Tweaks/LUA for BlitzMax v1.0
| ||
Hi everyone, Until the lua modules become part of the pub modules in BMX, here is place to get the modules and samples http://www.tomkatgames.com/publicfiles/luamodules.zip http://www.tomkatgames.com/publicfiles/luasamples.zip Extract the modules into your pub.mod folder Extract the samples into your samples folder Lua for BMX is for Win32, MacOS and Linux. You must do a build of your modules before you try to compile the samples. Tommy. |
| ||
Hi, i tried to compile modules and pb : Building Modules Compiling:blitz_app.c G:\BlitzMAX\Win32\BlitzMaxBeta101\mod\brl.mod\blitz.mod\blitz_app.c: In function `bbReadStdin': G:\BlitzMAX\Win32\BlitzMaxBeta101\mod\brl.mod\blitz.mod\blitz_app.c:31: error: assignment of read-only location Build Error: failed to compile G:/BlitzMAX/Win32/BlitzMaxBeta101/mod/brl.mod/blitz.mod/blitz_app.c Process complete |
| ||
right click your Blitzmax folder, choose properties, make sure Read only is not ticked, if it is, untick it and apply it to all subfolders as well. |
| ||
Hey flaith did that fix it? |
| ||
already made, and it was not selected :( |
| ||
Sorry what was made? What was not selected? |
| ||
I checked the BlitzMax directory, read only wasn't ticked |
| ||
Okay so if you remove or rename the lua related module folders do yuo still get this error? |
| ||
i made another synchro from the web server (i changed mod's dir to another name). i made build modules, still the same error !!! what's your gcc version (mine : 3.4.2-20040916-1) ? |
| ||
My GCC version is 3.2.3. If you delete the lua based modules.. ie lua.mod and luascript.mod and compile your modules (with quick compile disabled, don't do a sync) and you still get this error, then it is something else and not the modules that are the problem. Maybe you've hit a bug??? hmmmmmmm |
| ||
agreed ! Thank you for your answers, i'm going to create a new topic now !!! :) |
| ||
Yes... I think I might hold off doing a sync on my win32 box :) |
| ||
yes, i seen it, your zlib mod ... back to previous ! |
| ||
Ok it work only after compiling it with a command line under a DOS Window :bmk makemods -r pub.lua bmk makemods -r pub.luascript bmk makemods -r pub.zlib bmk makemods -r pub.zipengine |
| ||
works fine here on XP. Great work! |
| ||
Sorry for my noobish ignorance, but what is LUA? I've never heard of it... |
| ||
www.lua.org Lua is a scripting language, basically. For the full deal, read the About section of their website, or this quote: Lua is a powerful light-weight programming language designed for extending applications. Lua is also frequently used as a general-purpose, stand-alone language. Lua is free software. Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, interpreted from bytecodes, and has automatic memory management with garbage collection, making it ideal for configuration, scripting, and rapid prototyping. A fundamental concept in the design of Lua is to provide meta-mechanisms for implementing features, instead of providing a host of features directly in the language. For example, although Lua is not a pure object-oriented language, it does provide meta-mechanisms for implementing classes and inheritance. Lua's meta-mechanisms bring an economy of concepts and keep the language small, while allowing the semantics to be extended in unconventional ways. Extensible semantics is a distinguishing feature of Lua. Lua is a language engine that you can embed into your application. This means that, besides syntax and semantics, Lua has an API that allows the application to exchange data with Lua programs and also to extend Lua with C functions. In this sense, Lua can be regarded as a language framework for building domain-specific languages. Lua is implemented as a small library of C functions, written in ANSI C, and compiles unmodified in all known platforms. The implementation goals are simplicity, efficiency, portability, and low embedding cost. The result is a fast language engine with small footprint, making it ideal in embedded systems too. |
| ||
Thanks Noel. |
| ||
Yeah, its also used alot when making evolving programs, In other words you declare a fitness goal, and generate random programs, evaluate them against this goal, mate the most successful ones, and repeast :). It works pretty well. Pretty cool, tommybear |
| ||
Hey Tommy, just wondering how the ode module is coming along? |
| ||
my blitzmax file is locked on readonly??? when i uncheck it it checks back next time i check the properties, does anyone know how to fix this? |
| ||
Tommy: I'm curious, why did you leave out the lua_rawset(), lua_next(), and lua_error()? These functions are very important. Rawset for declaring global functions, next for traversing tables, and error for the obvious. Anyhow, I added these myself. Also, istable() doesn't work properly- you have to recreate the macro in BlitzMax: Function lua_istable:Int(lua_state:Byte Ptr, index:Int) Return (lua_type(lua_state,index) = LUA_TTABLE) End Function Straight port. Thanks for the awesome implementation, by the way- I don't use your ScriptEngine class, but it's proven to be an excellent thing to base mine on, concept-wise. Now my engine has Lua bindings. :) |
| ||
So LUA is a language within a language? What types of applications would you use it for? Russell |
| ||
scripting for games? |
| ||
Tommy: I'm curious, why did you leave out the lua_rawset(), lua_next(), and lua_error()? These functions are very important. Rawset for declaring global functions, next for traversing tables, and error for the obvious. Anyhow, I added these myself. Also, istable() doesn't work properly- you have to recreate the macro in BlitzMax: Function lua_istable:Int(lua_state:Byte Ptr, index:Int) Return (lua_type(lua_state,index) = LUA_TTABLE) End Function Straight port. Thanks for the awesome implementation, by the way- I don't use your ScriptEngine class, but it's proven to be an excellent thing to base mine on, concept-wise. Now my engine has Lua bindings. :) Lazy/not enough time is the answer! :p Been very busy at my work and we have a tight schedule for release... I meant to implement that next but just didn't have the time. Those are good and needed additions. So if you want to take the reigns go for it for now, please do so... Just make sure you leave the copyright intact and add your own to it name to it. cya! Tommy. |
| ||
Hey Tommy, just wondering how the ode module is coming along? Oh that little nugget. When and If I get time soon I'll start looking at it again. If people want I'll release the source as it stands to somebody else to complete Tommy. |
| ||
Just dredging this thread up from the dead. Does anyone know how I would go about passing an object to Lua and back? I was thinking something like this: ' Call a Lua function and pass it a reference to the calling object Local ob:MyObject = New MyObject lua_pushlightuserdata(L, Varptr(ob)) ' Lua calles a BMX function and passes it the reference to the object Local ob:MyObject Ptr = MyObject Ptr(lua_touserdata(L, 1)) But naturally that doesn't work :) Anyone know the correct way to do it? |
| ||
Yeah you can team monkey, I pass objects to and from lua scripts without problems.(eventually ;) ) Basically, you have to think of it procedurely. I.e, Function Test:MyObj() return New MyObj end function IntHandle = Test() get an int handle to the object using a function(there's no direct way of doing this I know of, please lemme know if you find one) and then push it on return.(Don't just return it..when returning to a lua script you're passing the number of pars returned. Use, luaObject.returnnumbertolua(ls, ObjectINTHandle ) to pass it to the script. LS = the byte ptr you declared in the function. Function MakeCam:Int(ls:Byte Ptr) Cam = cCam() ListAddLast CamList,Cam rifas.returnNumberToLua( ls,cam) 'notice ls declared in function header, it's shared par space I think. Return 1 'How many pars you're returning. End Function for example. -- If people want I'll release the source as it stands to somebody else to complete If it's as well wrote as the lua one I'll gladly *try* to finish it off. I may not be as succesfull though :) |
| ||
Ahh, so that's how you use the index handle thing. I could convert objects to handles, but I couldn't figure out how to get them back. I now have: Type GameObject Method getSelf:GameObject() Return Self End Method Function getObj:GameObject(obj:GameObject) Return obj End Function End Type obj:GameObject = New GameObject idx:Int = obj.getSelf() ' Turns object into a handle obj2:GameObject = GameObject.getObj(idx) ' Turns handle into an object Thanks Antony. |