Thanks! This is a great help!
EDIT: The script interpreter works, and I was able to define a few functions for use with the Lua language. I've run into two problems, though:
1. I can't seem to figure out how to return values from Lua functions. I've found that there's a function named lua_yield(lua_State* L, int numValues), but any attempt to use it results in an error for attempting to call an empty function.

Here's the relevant code:
Code:
int lua_gettimestep(lua_State* L) {
	lua_pushnumber(L,time_step);
	return lua_yield(L,1);
}
//...
function lua_init() {
	lua_register(L,"getTimeStep",lua_gettimestep);
}



Here's how I try to use it:
Code:
Lua console>> a = getTimeStep()



Here's the exact response I get (it opens a message window):
Code:
Empty function called in lua_gettimestep



2. Whenever one of my functions includes a wait(n) instruction, I get a script crash in that function. This is a problem, since I would like to allow users to use a wait(n) instruction.

Here's the relevant code:
Code:
int lua_wait(lua_State* L) {
	if (lua_gettop(L) == 0) {
		wait(1);
	} else {
		wait(lua_tonumber(L,1));
	}
	return 0;
}
//...
function lua_init() {
	lua_register(L,"sys_wait",lua_wait);
}



Here's how I try to use it:
Code:
Lua console>> sys_wait(3)



Here's the exact response I get (it opens a message window):
Code:
Script crash in lua_wait



EDIT2: I tried using the FFI libraries to import the wait() function from Gamestudio, and it errors because I attempt to use the data type 'var'. If I don't use it, it doesn't find the function.

In an attempt to work around this, I've imported the Sleep() function, and it does work, but it appears to freeze the entire program instead of just the script. This makes it useless for my purposes. Any ideas how I can fix this?

Last edited by TehV; 11/28/13 19:57.