Pub.AngelScript
BlitzMax Forums/BlitzMax Module Tweaks/Pub.AngelScript
| ||
AngelScript module that -should- implement the classes correctly. So far I'm having trouble actually using AngelScript with BlitzMax, so if anyone wants to have a go at using (and making it work right) this, be my guest. This uses the 2.1.0c version of AngelScript. You will need MinGW for this, obviously. And I'd recommend downloading the AngelScript SDK, 'cause it has the documentation. DOWNLOAD |
| ||
I get a 96k corrupt zip :\ |
| ||
Weird, but my FTP isn't letting me upload it all the way (definitely haven't reached the maximum for my FTP, so dunno). I'll try uploading it again in a bit, in the mean time, just wait 'til I say it's good. |
| ||
Should be up now. |
| ||
yup, that's it |
| ||
Quick test...Strict Local r:Int ' Result Local engine:asIScriptEngine = asCreateScriptEngine( ANGELSCRIPT_VERSION ) Local codeString$ = "float global_var=0;void Add(){global_var++;if (global_var > 10)global_var = 0;}void Sub( ){ global_var--;if (global_var < 0)global_var = 10;}" Local code:Byte Ptr = codeString.ToCString( ) Local size:Int = codeString.Length r = engine.AddScriptSection( "module".ToCString( ), "section".ToCString( ), code, size, 0, 0 ) Assert r=0, "Failed to add script section" engine.Build( "module".ToCString( ), Null ) Local s$ Repeat s = Input( ">" ).Trim( ) If s.ToLower( ) = "q" Or s.ToLower( ) = "quit" Or s.ToLower( ) = "exit" Then Exit engine.ExecuteString( "module".ToCString( ), s.ToCString( ), Null, Null, 0 ) Local gvar:Int = engine.GetGlobalVarIDByName( "module".ToCString( ), "global_var".ToCString( ) ) Local pointer:Int engine.GetGlobalVarPtr( gvar, Byte Ptr Ptr(Varptr pointer) ) Print( ( Float Ptr( pointer ) )[0] ) Forever r = engine.Release_( ) |
| ||
Did you ever get this working properly? I tried the above example , it works, but adding a function always fails. Import "angelscript.bmx" Strict Local r:Int' Result Local engine:asIScriptEngine = asCreateScriptEngine( ANGELSCRIPT_VERSION ) Local codeString$ = "float global_var=0;void Add(){global_var++;if (global_var > 10)global_var = 0;}void Sub( ){global_var--;if (global_var < 0)global_var = 10;}" Local code:Byte Ptr = codeString.ToCString( ) Local size:Int = codeString.Length r = engine.AddScriptSection( "module".ToCString( ), "section".ToCString( ), code, size, 0, 0 ) Assert r=0, "Failed to add script section" Type test Method multi() End Method End Type Local c:Test = New test Local func:Byte Ptr = Byte Ptr( Sin ) engine.Build( "module".ToCString( ), Null ) Local gf = engine.registerGlobalFunction("float Sin(float)".tocstring(),func,asCALL_CDECL) Assert gf=0,"Failed to register func :"+gf Local s$ Repeat s = Input( ">" ).Trim( ) If s.ToLower( ) = "q" Or s.ToLower( ) = "quit" Or s.ToLower( ) = "exit" Then Exit engine.ExecuteString( "module".ToCString( ), s.ToCString( ), Null, Null, 0 ) Local gvar:Int = engine.GetGlobalVarIDByName( "module".ToCString( ), "global_var".ToCString( ) ) Local pointer:Int engine.GetGlobalVarPtr( gvar, Byte Ptr Ptr(Varptr pointer) ) Print( ( Float Ptr( pointer ) )[0] ) Forever r = engine.Release_( ) Function mult() End Function Your code but adds a global function and asserts it. Fails with -7 everytime here. |
| ||
Don't know what's up with it and don't have the time to figure it out. The module was never finished due to AngelScript just not being suited for use with BlitzMax. |
| ||
Not to fear Noel... I'm working on an AngelScript module right now... looks very promising. Until then |
| ||
Any progress on your module Tommy? |