All pastes #571400 Raw Edit

jlulian38

public cpp v1 · immutable
·published 2007-06-17 03:50 UTC
rendered paste body
const char* getError(lua_State* Q){	const char* err = "";	if (lua_isstring(Q,-1)) //if we have a string(here an error)	{		err = lua_tostring(Q,-1);		lua_pop(Q,1);	}	return err;}void printError(lua_State* L,const char* str){	const char* err = getError(L);	printf("%s %s\n",str,err);}int dostring(lua_State* L,const char* str){	if (luaL_loadstring(L,str))	{		printError(L,"Error during parse\n ->");		return 1; //BAAAAD	}	if (lua_pcall(L,0,0,0)) {		printError(L,"Runtime Error!\n-> ");		return 1; //BAAAAD	}	return 0; //All good}int dofile(lua_State* L,const char* str){	if (luaL_loadfile(L,str) != 0)	{		printError(L,"Error during parse\n ->");		return 1; //BAAAAD	}	if (lua_pcall(L,0,0,0)) {		printError(L,"Runtime Error!\n-> ");		return 1; //BAAAAD	}	return 0; //All good}void killLoop(lua_State* L) //Calling this kills the doThink loop and ends the program.{	lua_pushboolean(L,0); //push false	lua_setglobal(L,"Run"); // 'Run' = false (the top stack value)}#include <lua_funcs.h>