Quote Originally Posted by pixie_frigo View Post
so @DarkstaR please fix this :x

Code:
int XenoScript::luaSleep(lua_State *L){
	XenoScript* currentScript = XenoScript::GetCurrentScript(L);
	if (!XenoScript::VerifyArgs(L, currentScript, "luaSleep", 1)) return 1;
	int time = max(XenoScript::GetIntegerArg(L, 1), 100);


	int criticals = currentScript->inLock;
	while (currentScript->inLock > 0)
		currentScript->endOperation();


	while (time > 0)
	{
		scriptSuicideAttempt(currentScript);


		int sleepFor = min(time, 100);
		Sleep(sleepFor);
		time -= sleepFor;
	}


	while (currentScript->inLock < criticals)
		currentScript->beginOperation();


	lua_pushnumber(L, 1);
	return 1;
}

The code is fine. If this is a problem, it has something to do with the thread synchronization. I'll check it out soon.