Skip to main content

Home/ game programming/ Group items tagged Lua

Rss Feed Group items tagged

metacipher

GameDev.net - An Introduction to Lua - 1 views

    • metacipher
       
      This is seemingly out of date (4.0 perhaps). But, a lot of the logic will still work. There is no example in this article for calling a Lua function. You can do it simply by: lua_getglobal(Lua_Handle, "myfunction"); if(lua_pcall(Lua_Handle, 0, 1, 0) != 0) { printf("Error running function: %s\n", lua_tostring(Lua_Handle, -1)); } int Return = (int)lua_tointeger(Lua_Handle, -1); lua_pop(Lua_Handle, 1); Take note though that your script must FIRST be loaded into the vm.
  • lua_baselibopen(luaVM); lua_iolibopen(luaVM); lua_strlibopen(luaVM); lua_mathlibopen(luaVM);
    • metacipher
       
      This seemingly won't work in version 5.1, not sure why. Try using this instead: luaL_openlibs(luaVM);
    • metacipher
       
      Lua seemingly keeps all scripts loaded in the same VM. That is, if you have script1.lua and script2.lua loaded, they will share the same global table. So if you declate a = 1 in script1.lua, script2.lua can see it.
1 - 2 of 2
Showing 20 items per page