Beispiel #1
0
void lua_open() {
    if (lua_state)
        return;
    lua_rootState = lua_state = luaM_new(LState);
    lua_stateinit(lua_state);
    lua_resetglobals();
    luaT_init();
    luaB_predefine();
    luaL_addlibtolist(stdErrorRimFunc, (sizeof(stdErrorRimFunc) / sizeof(stdErrorRimFunc[0])));
    if (Debug::isChannelEnabled(Debug::Lua))
        lua_callhook = callHook;
}
Beispiel #2
0
void start_script() {
	lua_Object paramObj = lua_getparam(1);
	lua_Type type = ttype(Address(paramObj));

	if (paramObj == LUA_NOOBJECT || (type != LUA_T_CPROTO && type != LUA_T_PROTO)) {
		warning("lua: Bad argument to start_script. - lua/ltask.cpp:32");
		// NOTE: Decomment the lua_error if you want to see the stacktrace.
		// It is commented out because si.lua, in the function si.set_up_actors (line 848),
		// calls "start_script(si.naranja_drinking)", which doesn't exist. The problem with
		// that is that lua_error ends the function that was going on, breaking
		// si.set really badly.
 		// lua_error("Bad argument to start_script");
		return;
	}

	LState *state = luaM_new(LState);
	lua_stateinit(state);

	state->next = lua_state->next;
	state->prev = lua_state;
	if (state->next)
		state->next->prev = state;
	lua_state->next = state;

	state->taskFunc.ttype = type;
	state->taskFunc.value = Address(paramObj)->value;

	int l = 2;
	for (lua_Object object = lua_getparam(l++); object != LUA_NOOBJECT; object = lua_getparam(l++)) {
		TObject ptr;
		ptr.ttype = Address(object)->ttype;
		ptr.value = Address(object)->value;
		LState *tmpState = lua_state;
		lua_state = state;
		luaA_pushobject(&ptr);
		lua_state = tmpState;
	}

	ttype(lua_state->stack.top) = LUA_T_TASK;
	nvalue(lua_state->stack.top) = (float)state->id;
	incr_top;
}
Beispiel #3
0
void start_script() {
	lua_Object paramObj = lua_getparam(1);
	lua_Type type = paramObj == LUA_NOOBJECT ? LUA_T_NIL : ttype(Address(paramObj));

	if (paramObj == LUA_NOOBJECT || (type != LUA_T_CPROTO && type != LUA_T_PROTO)) {
		lua_error("Bad argument to start_script");
		return;
	}

	LState *state = luaM_new(LState);
	lua_stateinit(state);

	state->next = lua_state->next;
	state->prev = lua_state;
	if (state->next)
		state->next->prev = state;
	lua_state->next = state;

	state->taskFunc.ttype = type;
	state->taskFunc.value = Address(paramObj)->value;

	int l = 2;
	for (lua_Object object = lua_getparam(l++); object != LUA_NOOBJECT; object = lua_getparam(l++)) {
		TObject ptr;
		ptr.ttype = Address(object)->ttype;
		ptr.value = Address(object)->value;
		LState *tmpState = lua_state;
		lua_state = state;
		luaA_pushobject(&ptr);
		lua_state = tmpState;
	}

	ttype(lua_state->stack.top) = LUA_T_TASK;
	nvalue(lua_state->stack.top) = (float)state->id;
	incr_top;
}