   Calling a Lua function from c++ every frame
  ok so i'm a little fuzzy on how to do this, the function dose not need to return any thing. i'm confused on how lua_getglobal works, i want to use a function in Lua that i'm going to call "main_loop" but after a declare it as a global variable using get global how do i call it? i think i just use lua_call(L,0,0)  since there are no return values or arguments. but i'm unsure thats why i'm asking.   
  did you try it? what happened when you did?I'd suggest taking a look at somehting like luabind if your planning on using lua alot, it makes all this (and more) really simple. Sooner you start using it, easier it'll all be.   ;  it said "PANIC: error in call to Lua API (attempt to call nil valuue)" here is my test programs code:#include <iostream>extern "C" {    #include "lua.h"    #include "lualib.h"    #include "lauxlib.h"}using namespace std;lua_State* L;void LuaPrint() { lua_getglobal(L, "PrintMsg"); lua_call(L, 0, 0);}int main(){    L = lua_open();    luaL_openlibs(L);    luaL_dofile(L, "foo.lua");    LuaPrint();    lua_close(L);    return 0;}and here is the lua script:function PrintMsg() {io.write("ok this is how you will call it");}   ;  That's not valid Lua.It should look like: function PrintMessage()   io.write("...")endYou need to check the return value from luaL_dofile so you can catch these sorts of errors. Likely you'd want to use lua_pcall over lua_call and check its return value also.   ;  o oops, now it's working thank you. i guess i need to remember to shift gears from c++ to Lua, not C++ to some mixture between flash and Lua, any way thanks again   