Ooops
August 15, 2020, 02:16:38 PM

Author Topic: Sample BlitzMax + Lua?  (Read 2463 times)

Offline Yue

  • Hero Member
  • *****
  • Posts: 579
    • YiHosting Your Hosting Free
Sample BlitzMax + Lua?
« on: July 04, 2017, 04:59:12 PM »
 :-X

Hi,
I'm trying to understand this, but I can not understand it, any suggestions on how to use Lua and BlitzMax?

https://en.wikibooks.org/wiki/BlitzMax/Modules/Other/Lua_Core#Running_Lua_Scripts_From_Within_BlitzMax

Offline therevills

  • Hero Member
  • *****
  • Posts: 611
Re: Sample BlitzMax + Lua?
« Reply #1 on: July 05, 2017, 10:43:51 AM »
Hey Yue, check this thread out:

http://wasted.nz/posts.php?topic=85952


(Wow that took too long to find!  :o)

Offline markcwm

  • Sr. Member
  • ****
  • Posts: 469
Re: Sample BlitzMax + Lua?
« Reply #2 on: July 05, 2017, 06:06:01 PM »
I think Yue solved his own problem over on Discord. I've never used Lua myself.
Quote
Ok, no problem, here run script. :)
Code: BlitzMax
  1. Local LuaState:Byte Ptr = luaL_newstate()
  2. luaL_openlibs(LuaState)
  3.  
  4. lua_pushstring(LuaState, "BMXString")
  5. lua_setglobal (LuaState, "luaglobal")
  6.  
  7. Function BMXName:Int (LuaState:Byte Ptr)
  8.  Local int_value:Int = luaL_checkinteger(LuaState, 1)
  9.  Local str_value:String = luaL_checkstring(LuaState, 2)
  10.  Print int_value
  11.  Print str_value
  12.  Return 0 ' number of values returned to Lua
  13. End Function
  14.  
  15. Function Inc(LuaState:Byte Ptr )
  16.  Local file:String = luaL_checkstring(LuaState, 1)
  17.  luaL_loadfile(LuaState,file)
  18.  Return 0
  19. End Function
  20.  
  21. lua_register(LuaState, "luaname", BMXName)
  22.  
  23. luaL_dofile(LuaState,"Hola.txt")
  24. lua_close(LuaState)

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal