Esempio n. 1
0
/* Open function */
TOLUA_API int tolua_tdirective_open (lua_State* tolua_S)
{
 tolua_open(tolua_S);
 tolua_reg_types(tolua_S);
 tolua_module(tolua_S,NULL,1);
 tolua_beginmodule(tolua_S,NULL);
 tolua_variable(tolua_S,"a",tolua_get_a,tolua_set_a);
{
 a = 3;
}

 { /* begin embedded lua code */
 static unsigned char B[] = {
  10, 65, 32, 61, 32, 52,32
 };
 lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code");
 } /* end of embedded lua code */


 { /* begin embedded lua code */
 static unsigned char B[] = {
  10,102,117,110, 99,116,105,111,110, 32,102,117,110, 99, 32,
  40, 41, 10,114,101,116,117,114,110, 32, 53, 10,101,110,100,
 32
 };
 lua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code");
 } /* end of embedded lua code */

 tolua_endmodule(tolua_S);
 return 1;
}
Esempio n. 2
0
TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name) {

 #ifdef LUA_VERSION_NUM /* lua 5.1 */
 luaL_loadbuffer(L, B, size, name) || lua_pcall(L, 0, 0, 0);
 #else
 lua_dobuffer(L, B, size, name);
 #endif
};
Esempio n. 3
0
static int luaB_dostring (lua_State *L) {
  int oldtop = lua_gettop(L);
  size_t l;
  const char *s = luaL_check_lstr(L, 1, &l);
  if (*s == '\27')  /* binary files start with ESC... */
    lua_error(L, "`dostring' cannot run pre-compiled code");
  return passresults(L, lua_dobuffer(L, s, l, luaL_opt_string(L, 2, s)), oldtop);
}
Esempio n. 4
0
static void luaB_dostring (void) {
  long l;
  char *s = luaL_check_lstr(1, &l);
  if (*s == ID_CHUNK)
    lua_error("`dostring' cannot run pre-compiled code");
  if (lua_dobuffer(s, l, luaL_opt_string(2, s)) == 0)
    if (luaA_passresults() == 0)
      lua_pushuserdata(NULL);  /* at least one result to signal no errors */
}
Esempio n. 5
0
TOLUA_API void tolua_dobuffer(lua_State *L, char *B, unsigned int size, const char *name)
{

#ifdef LUA_VERSION_NUM /* lua 5.1 */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-value"
	luaL_loadbuffer(L, B, size, name) || lua_pcall(L, 0, 0, 0);
#pragma GCC diagnostic pop
#else
	lua_dobuffer(L, B, size, name);
#endif
}
Esempio n. 6
0
int LuaBase::dofile(const char *filename) {
	Common::SeekableReadStream *stream;
	stream = g_resourceloader->openNewStreamFile(filename);
	if (!stream) {
		Debug::warning(Debug::Engine, "Cannot find script %s", filename);
		return 2;
	}

	int32 size = stream->size();
	char *buffer = new char[size];
	stream->read(buffer, size);
	int result = lua_dobuffer(const_cast<char *>(buffer), size, const_cast<char *>(filename));
	delete stream;
	delete[] buffer;
	return result;
}
Esempio n. 7
0
bool IsScriptTrue(const char* code, int size)
{
    if (size==0)
        return true;

    lua_State* L = CQuestManager::instance().GetLuaState();
    int x = lua_gettop(L);
    int errcode = lua_dobuffer(L, code, size, "IsScriptTrue");
    int bStart = lua_toboolean(L, -1);
    if (errcode)
    {
        char buf[100];
        snprintf(buf, sizeof(buf), "LUA ScriptRunError (code:%%d src:[%%%ds])", size);
        sys_err(buf, errcode, code);
    }
    lua_settop(L,x);
    return bStart != 0;
}
Esempio n. 8
0
int LuaBase::single_dofile(const char *filename) {
	Common::File *f = new Common::File();

	if (!f->open(filename)) {
		delete f;
		Debug::warning(Debug::Engine, "Cannot find script %s", filename);

		return 2;
	}

	int32 size = f->size();
	char *data = new char[size];
	f->read(data, size);

	int result = lua_dobuffer(data, size, const_cast<char *>(filename));
	delete f;
	delete[] data;

	return result;
}
Esempio n. 9
0
int LuaBase::bundle_dofile(const char *filename) {
	Common::SeekableReadStream *stream;
	stream = g_resourceloader->openNewStreamFile(filename);
	if (!stream) {
		// Don't print warnings on Scripts\foo.lua,
		// d:\grimFandango\Scripts\foo.lua
		if (!strstr(filename, "Scripts\\"))
			Debug::warning(Debug::Engine, "Cannot find script %s", filename);

		return 2;
	}

	int32 size = stream->size();
	char *buffer = new char[size];
	stream->read(buffer, size);
	int result = lua_dobuffer(const_cast<char *>(buffer), size, const_cast<char *>(filename));
	delete stream;
	delete buffer;
	return result;
}
Esempio n. 10
0
void ScriptManager::executeFile(const Common::UString &path) {
	assert(_luaState && _regNestingLevel == 0);

	if (isIgnoredFile(path)) {
		return;
	}

	Common::ScopedPtr<Common::SeekableReadStream> stream(ResMan.getResource(path, kFileTypeLUC));
	if (!stream) {
		const Common::UString fileName = TypeMan.setFileType(path, kFileTypeLUC);
		throw Common::Exception("No such LUC \"%s\"", fileName.c_str());
	}

	Common::ScopedPtr<Common::MemoryReadStream> memStream(stream->readStream(stream->size()));
	const char *data = reinterpret_cast<const char *>(memStream->getData());
	const int dataSize = memStream->size();

	const int execResult = lua_dobuffer(_luaState, data, dataSize, path.c_str());
	if (execResult != 0) {
		const Common::UString fileName = TypeMan.setFileType(path, kFileTypeLUC);
		throw Common::Exception("Failed to execute Lua file: %s", fileName.c_str());
	}
}
Esempio n. 11
0
int luaSystemInit() {
	SystemErrorStr[0]='\0';
	SystemErrorCode=0;
	if(SystemL) luaSystemEnd();
	for(int i=0;i<FILEMAX;i++) FpTable[i]=NULL;
	setlocale(LC_ALL, "");
    //
	SystemL = lua_open();  /* create state */
	// 関数を登録する(v1.5)
    lua_register(SystemL, "_CTRLLOCK", luaControlKeyLock);
    lua_register(SystemL, "_SENDALL", luaSendAllMessage);
    lua_register(SystemL, "_RECEIVE", luaReceiveMessage);
    lua_register(SystemL, "_RECEIVECLEAR", luaReceiveMessageClear);
    lua_register(SystemL, "_FOPEN", luaFileOpen);
    lua_register(SystemL, "_FCLOSE", luaFileClose);
    lua_register(SystemL, "_FPUTS", luaFilePuts);
    lua_register(SystemL, "_FGETS", luaFileGets);
	lua_register(SystemL, "_CHAT", luaGetLastChat);
	// 関数を登録する(v1.4)
    lua_register(SystemL, "_RESET", luaReset);
    lua_register(SystemL, "_COMPASS", luaSetTarget);
    lua_register(SystemL, "_SETVIEWUP", luaSetViewUp);
	// 関数を登録する(v1.3)
    lua_register(SystemL, "_KEYLOCK", luaKeyLock);
    lua_register(SystemL, "_STICKS", luaGetSystemTickCount);
    // 関数を登録する(v1.2)
    lua_register(SystemL, "_SETVIEW", luaSetView);
    lua_register(SystemL, "_GETVIEW", luaGetView);
    lua_register(SystemL, "_SETVIEWTYPE", luaSetViewType);
    lua_register(SystemL, "_GETVIEWTYPE", luaGetViewType);
    lua_register(SystemL, "_SETVIEWZOOM", luaSetViewZoom);
    lua_register(SystemL, "_GETVIEWZOOM", luaGetViewZoom);

    // 関数を登録する(v1.1)
    lua_register(SystemL, "_GET", luaGetChip);
    lua_register(SystemL, "_GETCHILD", luaGetChild);

    // 関数を登録する(v1.0)
    lua_register(SystemL, "out", luaSystemPrint);

    lua_register(SystemL, "_SETREG", luaSetRegulationFlag);

    lua_register(SystemL, "_LOADLAND", luaLoadLand);

    lua_register(SystemL, "_SETWIND", luaWind);
    lua_register(SystemL, "_GETWIND", luaGetWind);

	lua_register(SystemL, "_ADDBALL", luaAddBall);
    lua_register(SystemL, "_SETOBJFIX", luaSetObjFix);
    lua_register(SystemL, "_SETOBJCOLOR", luaSetObjColor);

    lua_register(SystemL, "_SETRINGSTATE", luaSetRingState);
    lua_register(SystemL, "_GETRINGSTATE", luaGetRingState);
    lua_register(SystemL, "_SETRING", luaSetRing);
    lua_register(SystemL, "_GETRING", luaGetRing);
    lua_register(SystemL, "_SETRINGCOLOR", luaSetRingColor);
    lua_register(SystemL, "_CHECK", luaCheckRingArea);
    lua_register(SystemL, "_CHECKOBJ", luaCheckObjRingArea);
    lua_register(SystemL, "_CHECK2", luaCollisionRingArea);
    lua_register(SystemL, "_CHECK2OBJ", luaCollisionObjRingArea);

    lua_register(SystemL, "_WARP", luaWarp);
    lua_register(SystemL, "_WARPOBJ", luaWarpObj);

    lua_register(SystemL, "_FORCE", luaApplyForce);
    lua_register(SystemL, "_FORCEOBJ", luaApplyForceObj);

    lua_register(SystemL, "_TORQUE", luaApplyTorque);
    lua_register(SystemL, "_TORQUEOBJ", luaApplyTorqueObj);

    lua_register(SystemL, "_GETHIT", luaHitCount);
    lua_register(SystemL, "_GETHITOBJ", luaHitCountObj);
	

    lua_register(SystemL, "_SET", luaSetChip);
	
    lua_register(SystemL, "_ROTATE", luaRotate);
    lua_register(SystemL, "_ROTATEOBJ", luaRotateObj);
    lua_register(SystemL, "_DIRECT", luaDirect);
    lua_register(SystemL, "_DIRECTOBJ", luaDirectObj);

    lua_register(SystemL, "_ENERVATE", luaEnervate);
    lua_register(SystemL, "_ENERVATEOBJ", luaEnervateObj);

    lua_register(SystemL, "_PAUSE", luaPause);
    lua_register(SystemL, "_PLAY", luaPlay);

    lua_register(SystemL, "_SKEY", luaGetSystemKey);
    lua_register(SystemL, "_SKEYDOWN", luaGetSystemKeyDown);
    lua_register(SystemL, "_SKEYUP", luaGetSystemKeyUp);

    lua_register(SystemL, "_GETY", luaGetH);

    lua_register(SystemL, "_ADDCHIP", luaAddChip);
    lua_register(SystemL, "_RELOAD", luaUpdateChips);
    lua_register(SystemL, "_SAVE", luaSaveChips);

	lua_register(SystemL, "_MX", luaGetSMouseX);
	lua_register(SystemL, "_MY", luaGetSMouseY);
	lua_register(SystemL, "_ML", luaGetSMouseL);
	lua_register(SystemL, "_MR", luaGetSMouseR);
	lua_register(SystemL, "_MM", luaGetSMouseM);

	lua_register(SystemL, "_DT", luaGetDt);
    lua_register(SystemL, "_FPS", luaGetFps);
    lua_register(SystemL, "_BASE", luaGetBase);
    lua_register(SystemL, "_TICKS", luaGetTickCount);
    lua_register(SystemL, "_SETTICKS", luaSetTicks);
    lua_register(SystemL, "_KEY", luaKey2);
    lua_register(SystemL, "_KEYDOWN", luaKeyDown2);
    lua_register(SystemL, "_KEYUP", luaKeyUp2);
    lua_register(SystemL, "_ANALOG", luaAnalog);
    lua_register(SystemL, "_HAT", luaHat);
    lua_register(SystemL, "_CHIPS", luaChips);
    lua_register(SystemL, "_WEIGHT", luaWeight);
    lua_register(SystemL, "_WIDTH", luaGetWidth);
    lua_register(SystemL, "_HEIGHT", luaGetHeight);
    lua_register(SystemL, "_FACE", luaGetFaces);
    lua_register(SystemL, "_ZOOM", luaSetCCDZoom);
    lua_register(SystemL, "_OX", luaObjPosx);
    lua_register(SystemL, "_OY", luaObjPosy);
    lua_register(SystemL, "_OZ", luaObjPosz);
    lua_register(SystemL, "_X", luaPosx);
    lua_register(SystemL, "_Y", luaPosy);
    lua_register(SystemL, "_Z", luaPosz);
    lua_register(SystemL, "_H", luaGetY);
    lua_register(SystemL, "_AX", luaAx);
    lua_register(SystemL, "_AY", luaAy);
    lua_register(SystemL, "_AZ", luaAz);
    lua_register(SystemL, "_EX", luaEx);
    lua_register(SystemL, "_EY", luaEy);
    lua_register(SystemL, "_EZ", luaEz);
    lua_register(SystemL, "_GX", luaGx);
    lua_register(SystemL, "_GY", luaGy);
    lua_register(SystemL, "_GZ", luaGz);
    lua_register(SystemL, "_XX", luaXx);
    lua_register(SystemL, "_XY", luaXy);
    lua_register(SystemL, "_XZ", luaXz);
    lua_register(SystemL, "_YX", luaYx);
    lua_register(SystemL, "_YY", luaYy);
    lua_register(SystemL, "_YZ", luaYz);
    lua_register(SystemL, "_ZX", luaZx);
    lua_register(SystemL, "_ZY", luaZy);
    lua_register(SystemL, "_ZZ", luaZz);
    lua_register(SystemL, "_QX", luaQx);
    lua_register(SystemL, "_QY", luaQy);
    lua_register(SystemL, "_QZ", luaQz);
    lua_register(SystemL, "_QW", luaQw);
    lua_register(SystemL, "_RX", luaRx);
    lua_register(SystemL, "_RY", luaRy);
    lua_register(SystemL, "_RZ", luaRz);
    lua_register(SystemL, "_LX", luaLx);
    lua_register(SystemL, "_LY", luaLy);
    lua_register(SystemL, "_LZ", luaLz);
    lua_register(SystemL, "_VX", luaVx);
    lua_register(SystemL, "_VY", luaVy);
    lua_register(SystemL, "_VZ", luaVz);
    lua_register(SystemL, "_FX", luaFx);
    lua_register(SystemL, "_FY", luaFy);
    lua_register(SystemL, "_FZ", luaFz);
    lua_register(SystemL, "_WX", luaWx);
    lua_register(SystemL, "_WY", luaWy);
    lua_register(SystemL, "_WZ", luaWz);
    lua_register(SystemL, "_CCD", luaGetCCD);
    lua_register(SystemL, "_RED", luaGetCCDRed);
    lua_register(SystemL, "_GREEN", luaGetCCDGreen);
    lua_register(SystemL, "_BLUE", luaGetCCDBlue);
    lua_register(SystemL, "_BYE", luaUnLinkBye);
    lua_register(SystemL, "_SPLIT", luaUnLink);
    lua_register(SystemL, "_RND", luaRnd);
    lua_register(SystemL, "_TODEG", luaToDeg);
    lua_register(SystemL, "_TORAD", luaToRad);
    lua_register(SystemL, "_TYPE", luaGetType);
    lua_register(SystemL, "_OPTION", luaGetOption);
    lua_register(SystemL, "_EFFECT", luaGetEffect);
    lua_register(SystemL, "_USER1", luaGetUserEffect);
    lua_register(SystemL, "_USER2", luaGetUserOption);
    lua_register(SystemL, "_DIR", luaGetDir);
    lua_register(SystemL, "_ANGLE", luaGetAngle);
    lua_register(SystemL, "_POWER", luaGetPower);
    lua_register(SystemL, "_SPRING", luaGetSpring);
    lua_register(SystemL, "_DAMPER", luaGetDamper);
    lua_register(SystemL, "_BRAKE", luaGetBrake);
    lua_register(SystemL, "_COLOR", luaGetColor);
    lua_register(SystemL, "_PARENT", luaGetParent);
    lua_register(SystemL, "_TOP", luaGetTop);
    lua_register(SystemL, "_M", luaGetM);
    lua_register(SystemL, "_I", luaGetI);
    lua_register(SystemL, "_MOBJ", luaGetObjM);
    lua_register(SystemL, "_IOBJ", luaGetObjI);
    lua_register(SystemL, "_E", luaGetEnergy);
	lua_register(SystemL, "_T",luaGetTolerant);
	lua_register(SystemL, "_MOVE3D",luaMove3D);
	lua_register(SystemL, "_LINE3D",luaLine3D);
	lua_register(SystemL, "_MOVE2D",luaMove2D);
	lua_register(SystemL, "_LINE2D",luaLine2D);
	lua_register(SystemL, "_SETCOLOR",luaSetColor);
	lua_register(SystemL, "_PLAYERS",luaGetPlayers);
	lua_register(SystemL, "_PLAYERHOSTID",luaGetPlayerHostID);
	lua_register(SystemL, "_PLAYERMYID",luaGetPlayerMyID);
	lua_register(SystemL, "_PLAYERID",luaGetPlayerID);
	lua_register(SystemL, "_PLAYERCHIPS",luaGetPlayerChips);
	lua_register(SystemL, "_PLAYERCRUSHES",luaGetPlayerCrushes);
	lua_register(SystemL, "_PLAYERRESETS",luaGetPlayerResets);
	lua_register(SystemL, "_PLAYERINITS",luaGetPlayerInits);
	lua_register(SystemL, "_PLAYERCOLOR",luaGetPlayerColor);
	lua_register(SystemL, "_PLAYERX",luaGetPlayerX);
	lua_register(SystemL, "_PLAYERY",luaGetPlayerY);
	lua_register(SystemL, "_PLAYERZ",luaGetPlayerZ);
	lua_register(SystemL, "_PLAYERARMS",luaGetPlayerArms);
	lua_register(SystemL, "_PLAYEYFORCES",luaGetPlayerYForces);
	lua_register(SystemL, "_PLAYERNAME",luaGetPlayerName);
	lua_register(SystemL, "_FUEL",luaGetFuel);
	lua_register(SystemL, "_FUELMAX",luaGetFuelMax);
	luaL3dx=luaL3dy=luaL3dz=0.0f;
	luaGraColor=0xffffff;
	for(int i=0;i<8;i++) ControlKeysLock[i]=false;
	//グローバル変数の登録
	for(int i=0;i<VarCount;i++) {
		lua_pushnumber(SystemL,ValList[i].Val);
		lua_setglobal(SystemL,ValList[i].Name);
	}
	//スクリプトをセットする
      luaopen_string(SystemL);
      luaopen_base(SystemL);
      luaopen_table(SystemL);
      luaopen_math(SystemL);
//      luaopen_io(SystemL);
	int e=lua_dobuffer (SystemL,SystemSource,strlen(SystemSource),"System.rcs");
	if(e!=0) {
		SystemErrorCode=-1;
		sprintf(SystemErrorStr,"%s\n",lua_tostring(SystemL,0));
		lua_close(SystemL);
		SystemL=NULL;
		return 1;
	}
	return 0;
}
Esempio n. 12
0
LUALIB_API int lua_dostring (lua_State *L, const char *str) {
  return lua_dobuffer(L, str, strlen(str), str);
}
Esempio n. 13
0
int lua_dostring (char *str) {
  return lua_dobuffer(str, strlen(str), str);
}
Esempio n. 14
0
int32 lua_dostring(const char *str) {
	return lua_dobuffer(str, strlen(str), NULL);
}
Esempio n. 15
0
lua_State *luaScriptInit(char *buff) {
	ScriptErrorStr[0]='\0';
	ScriptErrorCode=0;
	setlocale(LC_ALL, "");
    //
	lua_State *L = lua_open();  /* create state */
    // 関数を登録する
    lua_register(L, "out", luaPrint);

	lua_register(L, "_MX", luaGetMouseX);
	lua_register(L, "_MY", luaGetMouseY);
	lua_register(L, "_ML", luaGetMouseL);
	lua_register(L, "_MR", luaGetMouseR);
	lua_register(L, "_MM", luaGetMouseM);

	lua_register(L, "_DT", luaGetDt);
    lua_register(L, "_FPS", luaGetFps);
    lua_register(L, "_BASE", luaGetBase);
    lua_register(L, "_TICKS", luaGetTickCount);
    lua_register(L, "_SETTICKS", luaSetTicks);
    lua_register(L, "_KEY", luaKey);
    lua_register(L, "_KEYDOWN", luaKeyDown);
    lua_register(L, "_KEYUP", luaKeyUp);
    lua_register(L, "_ANALOG", luaAnalog);
    lua_register(L, "_HAT", luaHat);
    lua_register(L, "_CHIPS", luaChips);
    lua_register(L, "_WEIGHT", luaWeight);
    lua_register(L, "_WIDTH", luaGetWidth);
    lua_register(L, "_HEIGHT", luaGetHeight);
    lua_register(L, "_FACE", luaGetFaces);
    lua_register(L, "_ZOOM", luaSetCCDZoom);
    lua_register(L, "_OX", luaObjPosx);
    lua_register(L, "_OY", luaObjPosy);
    lua_register(L, "_OZ", luaObjPosz);
    lua_register(L, "_X", luaPosx);
    lua_register(L, "_Y", luaPosy);
    lua_register(L, "_Z", luaPosz);
    lua_register(L, "_H", luaGetY);
    lua_register(L, "_AX", luaAx);
    lua_register(L, "_AY", luaAy);
    lua_register(L, "_AZ", luaAz);
    lua_register(L, "_EX", luaEx);
    lua_register(L, "_EY", luaEy);
    lua_register(L, "_EZ", luaEz);
    lua_register(L, "_GX", luaGx);
    lua_register(L, "_GY", luaGy);
    lua_register(L, "_GZ", luaGz);
    lua_register(L, "_XX", luaXx);
    lua_register(L, "_XY", luaXy);
    lua_register(L, "_XZ", luaXz);
    lua_register(L, "_YX", luaYx);
    lua_register(L, "_YY", luaYy);
    lua_register(L, "_YZ", luaYz);
    lua_register(L, "_ZX", luaZx);
    lua_register(L, "_ZY", luaZy);
    lua_register(L, "_ZZ", luaZz);
    lua_register(L, "_QX", luaQx);
    lua_register(L, "_QY", luaQy);
    lua_register(L, "_QZ", luaQz);
    lua_register(L, "_QW", luaQw);
    lua_register(L, "_RX", luaRx);
    lua_register(L, "_RY", luaRy);
    lua_register(L, "_RZ", luaRz);
    lua_register(L, "_LX", luaLx);
    lua_register(L, "_LY", luaLy);
    lua_register(L, "_LZ", luaLz);
    lua_register(L, "_VX", luaVx);
    lua_register(L, "_VY", luaVy);
    lua_register(L, "_VZ", luaVz);
    lua_register(L, "_FX", luaFx);
    lua_register(L, "_FY", luaFy);
    lua_register(L, "_FZ", luaFz);
    lua_register(L, "_WX", luaWx);
    lua_register(L, "_WY", luaWy);
    lua_register(L, "_WZ", luaWz);
    lua_register(L, "_CCD", luaGetCCD);
    lua_register(L, "_RED", luaGetCCDRed);
    lua_register(L, "_GREEN", luaGetCCDGreen);
    lua_register(L, "_BLUE", luaGetCCDBlue);
    lua_register(L, "_BYE", luaUnLinkBye);
    lua_register(L, "_SPLIT", luaUnLink);
    lua_register(L, "_RND", luaRnd);
    lua_register(L, "_TODEG", luaToDeg);
    lua_register(L, "_TORAD", luaToRad);
    lua_register(L, "_TYPE", luaGetType);
    lua_register(L, "_OPTION", luaGetOption);
    lua_register(L, "_EFFECT", luaGetEffect);
    lua_register(L, "_USER1", luaGetUserEffect);
    lua_register(L, "_USER2", luaGetUserOption);
    lua_register(L, "_DIR", luaGetDir);
    lua_register(L, "_ANGLE", luaGetAngle);
    lua_register(L, "_POWER", luaGetPower);
    lua_register(L, "_SPRING", luaGetSpring);
    lua_register(L, "_DAMPER", luaGetDamper);
    lua_register(L, "_BRAKE", luaGetBrake);
    lua_register(L, "_COLOR", luaGetColor);
    lua_register(L, "_PARENT", luaGetParent);
    lua_register(L, "_TOP", luaGetTop);
    lua_register(L, "_M", luaGetM);
    lua_register(L, "_I", luaGetI);
    lua_register(L, "_MOBJ", luaGetObjM);
    lua_register(L, "_IOBJ", luaGetObjI);
    lua_register(L, "_E", luaGetEnergy);
	lua_register(L, "_T",luaGetTolerant);
	lua_register(L, "_MOVE3D",luaMove3D);
	lua_register(L, "_LINE3D",luaLine3D);
	lua_register(L, "_MOVE2D",luaMove2D);
	lua_register(L, "_LINE2D",luaLine2D);
	lua_register(L, "_SETCOLOR",luaSetColor);
	lua_register(L, "_PLAYERS",luaGetPlayers);
	lua_register(L, "_PLAYERHOSTID",luaGetPlayerHostID);
	lua_register(L, "_PLAYERMYID",luaGetPlayerMyID);
	lua_register(L, "_PLAYERID",luaGetPlayerID);
	lua_register(L, "_PLAYERCHIPS",luaGetPlayerChips);
	lua_register(L, "_PLAYERCRUSHES",luaGetPlayerCrushes);
	lua_register(L, "_PLAYERRESETS",luaGetPlayerResets);
	lua_register(L, "_PLAYERINITS",luaGetPlayerInits);
	lua_register(L, "_PLAYERCOLOR",luaGetPlayerColor);
	lua_register(L, "_PLAYERX",luaGetPlayerX);
	lua_register(L, "_PLAYERY",luaGetPlayerY);
	lua_register(L, "_PLAYERZ",luaGetPlayerZ);
	lua_register(L, "_PLAYERARMS",luaGetPlayerArms);
	lua_register(L, "_PLAYERYFORCES",luaGetPlayerYForces);
	lua_register(L, "_PLAYERNAME",luaGetPlayerName);
	lua_register(L, "_FUEL",luaGetFuel);
	lua_register(L, "_FUELMAX",luaGetFuelMax);

	luaL3dx=luaL3dy=luaL3dz=0.0f;
	luaGraColor=0xffffff;
	//グローバル変数の登録
	for(int i=0;i<VarCount;i++) {
		lua_pushnumber(L,ValList[i].Val);
		lua_setglobal(L,ValList[i].Name);
	}
	//スクリプトをセットする
      luaopen_string(L);
      luaopen_base(L);
      luaopen_table(L);
      luaopen_math(L);
//      luaopen_io(L);
	int e=lua_dobuffer (L,buff,strlen(buff),szUpdateFileName0);
	if(e!=0) {
		ScriptErrorCode=-1;
		sprintf(ScriptErrorStr,"%s\n",lua_tostring(L,0));
		lua_close(L);
		return NULL;
	}
	return L;
}