123456789101112131415161718192021222324252627282930313233343536373839404142 |
- The MaxLua module provides a way to use the Lua scripting language from within Blitzmax programs.
- Lua is a simple but fast and powerful scripting language. For more information on programming in Lua, please visit the official Lua site at https://www.lua.org
- Here is an example of the MaxLua module in action:
- {{
- SuperStrict
- ' Our TDemo type...
- Type TDemo
- Method SayHello:String( name:String )
- Return "Hello " + name + "! Peace be with you..."
- End Method
- End Type
- ' Register a demo object with Lua.
- ' Lua code can now access the object using the identifier "Demo".
- Local demo:TDemo = New TDemo
- LuaRegisterObject( demo, "Demo" )
- ' Source code to our little Lua program...
- Local source:String = """
- function hello()
- print( Demo.SayHello( 'Fredborg' ) )
- end
- function goodbye()
- print( Demo.SayHello( 'CandyMan' ) )
- end
- """
- ' Create a Lua 'class' and set it's source code...
- Local class:TLuaClass = TLuaClass.Create( source )
- ' Now, create an instance of the class.
- Local instance:TLuaObject = TLuaObject.Create( class, Null )
- ' We can no invoke methods of the class.
- instance.Invoke( "hello", Null )
- instance.Invoke( "goodbye", Null )
- }}
|