コード例 #1
0
	int Instance::lua_setParent(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(inst){
			bool throwErrorIf = true;
			Instance* otherInst = NULL;
			if(lua_isnil(L, 2)){
				throwErrorIf = false;
			}else{
				otherInst = checkInstance(L, 2);
			}
			if(otherInst != NULL || !throwErrorIf){
				try{
					inst->setParent(otherInst);
					propertyChanged("Parent", inst);
				}catch(std::runtime_error& ex){
					return luaL_error(L, ex.what());
				}
				return 0;
			}else{
				return luaL_typerror(L, 2, "Instance");
			}
			return 0;
		}
		return 0;
	}
コード例 #2
0
	//TODO: Implement these as methods of DataModel. We want it to be possible to write an OpenBlox game entirely in C++ if desired.
	void DataModel::register_lua_methods(lua_State* L){
		luaL_Reg methods[]{
			{"SetTitle", [](lua_State* L)->int{
				Instance* inst = checkInstance(L, 1);
				if(DataModel* dm = dynamic_cast<DataModel*>(inst)){
					dm->title = std::string(luaL_checkstring(L, 2));
					#ifndef OPENBLOX_SERVER
						glfwSetWindowTitle(OpenBlox::getWindow(), dm->title.c_str());
					#endif
					return 0;
				}
				return luaL_error(L, COLONERR, "SetTitle");
			}},
			{"GetTitle", [](lua_State* L)->int{
				Instance* inst = checkInstance(L, 1);
				if(DataModel* dm = dynamic_cast<DataModel*>(inst)){
					lua_pushstring(L, dm->title.c_str());
					return 1;
				}
				return luaL_error(L, COLONERR, "GetTitle");
			}},
			{"GetFPS", [](lua_State* L)->int{
				lua_pushnumber(L, OpenBlox::calculatedFPS);
				return 1;
			}},
			{NULL,NULL}
		};
		luaL_register(L, NULL, methods);
		ServiceProvider::register_lua_methods(L);
	}
コード例 #3
0
	void RunService::register_lua_events(lua_State* L){
		luaL_Reg events[]{
			{"RenderStepped", [](lua_State* L)->int{
				Instance* inst = checkInstance(L, 1);
				if(inst){
					if(RunService* rs = dynamic_cast<RunService*>(inst)){
						return rs->RenderStepped->wrap_lua(L);
					}
				}
				return 0;
			}},
			{"Stepped", [](lua_State* L)->int{
				Instance* inst = checkInstance(L, 1);
				if(inst){
					if(RunService* rs = dynamic_cast<RunService*>(inst)){
						return rs->Stepped->wrap_lua(L);
					}
				}
				return 0;
			}},
			{"Heartbeat", [](lua_State* L)->int{
				Instance* inst = checkInstance(L, 1);
				if(inst){
					if(RunService* rs = dynamic_cast<RunService*>(inst)){
						return rs->Heartbeat->wrap_lua(L);
					}
				}
				return 0;
			}},
			{NULL, NULL}
		};
		luaL_register(L, NULL, events);

		Instance::register_lua_events(L);
	}
コード例 #4
0
ファイル: Sound.cpp プロジェクト: RobloxLabs/OpenBlox-Legacy
	void Sound::register_lua_methods(lua_State* L){
			luaL_Reg methods[]{
				{"Pause", [](lua_State* L)->int{
					Instance* inst = checkInstance(L, 1);
					if(Sound* s = dynamic_cast<Sound*>(inst)){
						s->Pause();
						return 0;
					}
					return luaL_error(L, COLONERR, "Pause");
				}},
				{"Play", [](lua_State* L)->int{
					Instance* inst = checkInstance(L, 1);
					if(Sound* s = dynamic_cast<Sound*>(inst)){
						s->Play();
						return 0;
					}
					return luaL_error(L, COLONERR, "Play");
				}},
				{"Stop", [](lua_State* L)->int{
					Instance* inst = checkInstance(L, 1);
					if(Sound* s = dynamic_cast<Sound*>(inst)){
						s->Stop();
						return 0;
					}
					return luaL_error(L, COLONERR, "Stop");
				}},
				{NULL, NULL}
			};
			luaL_register(L, NULL, methods);

			Instance::register_lua_methods(L);
		}
コード例 #5
0
	int Instance::lua_eq(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(inst){
			Instance* oinst = checkInstance(L, 2);
			if(oinst){
				lua_pushboolean(L, inst == oinst);
				return 1;
			}
		}
		lua_pushboolean(L, false);
		return 1;
	}
コード例 #6
0
ファイル: Player.cpp プロジェクト: RobloxLabs/OpenBlox
	int Player::lua_setRespawnLocation(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(Player* plr = dynamic_cast<Player*>(inst)){
			Instance* toSetTo = checkInstance(L, 2);

			if(toSetTo != plr->RespawnLocation){
				plr->RespawnLocation = toSetTo;

				REPLICATE_PROPERTY_CHANGE(plr, "RespawnLocation", plr->RespawnLocation);

				propertyChanged("RespawnLocation", plr);
			}
		}
		return 0;
	}
コード例 #7
0
ファイル: TextButton.cpp プロジェクト: RobloxLabs/OpenBlox
int TextButton::lua_getTextColor3(lua_State* L) {
    Instance* inst = checkInstance(L, 1);
    if(TextButton* go = dynamic_cast<TextButton*>(inst)) {
        return go->TextColor3->wrap_lua(L);
    }
    return 0;
}
コード例 #8
0
ファイル: Model.cpp プロジェクト: RobloxLabs/OpenBlox
	int Model::lua_GetExtentsSize(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(Model* m = dynamic_cast<Model*>(inst)){
			return m->GetExtentsSize()->wrap_lua(L);
		}
		return luaL_error(L, COLONERR, "GetExtentsSize");
	}
コード例 #9
0
ファイル: nNaveoApplication.cpp プロジェクト: gan74/Naveo2
nNaveoApplication::nNaveoApplication(int argc, char *argv[]) : QApplication(argc, argv) {

    //UTF-8 support
    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));

	connect(this, SIGNAL(aboutToQuit()), this, SLOT(close()));
	console = new nDebugConsole();

	checkInstance();

	settings = new nSettingsManager(this);
	translator = new QTranslator();
	loadTranslator();


	theme = new nTheme();

	initWebSettings();

	engine = new nGoogleSearchEngine();
	downloadManager = new nDownloadManager();
	accessManager = new QNetworkAccessManager(this);
	historyManager = new nHistoryManager();
	QWebHistoryInterface::setDefaultInterface(historyManager);


	setWindowIcon(QIcon(":/icon.png"));
	connect(settings, SIGNAL(settingsChanged()), this, SIGNAL(settingsChanged()));
	connect(this, SIGNAL(settingsChanged()), this, SLOT(updateSettings()));
    updateSettings();
}
コード例 #10
0
SEXP InstanceObjectTable::get(const char * name, Rboolean* canCache) const {
  SEXP ans = R_UnboundValue;
  checkInstance();
  if (canCache) *canCache = TRUE;
  if (_internal) {
    if (!qstrcmp(name, "this"))
      ans = _instance->internalSexp(R_EmptyEnv);
    else if (!qstrcmp(name, "super"))
      ans = superClosure();
    else ans = findVarInFrame(fieldEnv(), install(name));
    if (ans == R_UnboundValue)
      ans = enumValue(name);
  }
  if (ans == R_UnboundValue) {
    Property *prop = _instance->klass()->property(name);
    if (prop) { // FIXME: throw error if not readable?
      if (prop->isReadable())
        ans = prop->read(_instance->sexp());
      delete prop;
    }
  }
  if (ans == R_UnboundValue && methodExists(name))
    ans = methodClosure(name); // make a wrapper for method
  
  return ans;
}
コード例 #11
0
ファイル: Model.cpp プロジェクト: RobloxLabs/OpenBlox
	int Model::lua_MakeJoints(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(Model* m = dynamic_cast<Model*>(inst)){
			m->MakeJoints();
			return 0;
		}
		return luaL_error(L, COLONERR, "MakeJoints");
	}
コード例 #12
0
	int Instance::lua_getName(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(inst){
			lua_pushstring(L, inst->Name.c_str());
			return 1;
		}
		return 0;
	}
コード例 #13
0
int LuaNoiseVolumeRenderer::addToWorld(lua_State* L)
{
	NoiseVolumeRenderer *noise = checkInstance(L, 1);

	World::instance()->addDrawable(noise);

	return 0;
}
コード例 #14
0
ファイル: TextButton.cpp プロジェクト: RobloxLabs/OpenBlox
int TextButton::lua_getText(lua_State* L) {
    Instance* inst = checkInstance(L, 1);
    if(TextButton* tb = dynamic_cast<TextButton*>(inst)) {
        lua_pushstring(L, tb->Text.toStdString().c_str());
        return 1;
    }
    return 0;
}
コード例 #15
0
ファイル: TextButton.cpp プロジェクト: RobloxLabs/OpenBlox
int TextButton::lua_getTextTransparency(lua_State* L) {
    Instance* inst = checkInstance(L, 1);
    if(TextButton* go = dynamic_cast<TextButton*>(inst)) {
        lua_pushnumber(L, go->TextTransparency);
        return 1;
    }
    return 0;
}
コード例 #16
0
ファイル: Player.cpp プロジェクト: RobloxLabs/OpenBlox
	int Player::lua_getNeutral(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(Player* plr = dynamic_cast<Player*>(inst)){
			lua_pushboolean(L, plr->Neutral);
			return 1;
		}
		return 0;
	}
コード例 #17
0
ファイル: Player.cpp プロジェクト: RobloxLabs/OpenBlox
	int Player::lua_Kick(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(Player* plr = dynamic_cast<Player*>(inst)){
			plr->Kick();
			return 0;
		}
		return luaL_error(L, COLONERR, "Kick");
	}
コード例 #18
0
	int Instance::lua_Remove(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(inst){
			inst->Remove();
			return 0;
		}
		return luaL_error(L, COLONERR, "Remove");
	}
コード例 #19
0
	int Instance::lua_Destroy(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(inst){
			inst->Destroy();
			return 0;
		}
		return luaL_error(L, COLONERR, "Destroy");
	}
コード例 #20
0
	//Methods
	int Instance::lua_ClearAllChildren(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(inst){
			inst->ClearAllChildren();
			return 0;
		}
		return luaL_error(L, COLONERR, "ClearAllChildren");
	}
コード例 #21
0
	int Instance::lua_getArchivable(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(inst){
			lua_pushboolean(L, inst->Archivable);
			return 1;
		}
		return 0;
	}
コード例 #22
0
int LuaFosterWaterVolume::addToWorld(lua_State* L)
{
	FosterWaterVolume *wv = checkInstance(L, 1);

	Orbis::World::instance()->addDynamic(wv);

	return 0;
}
コード例 #23
0
	int Instance::lua_toString(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(inst){
			lua_pushstring(L, inst->toString().c_str());
			return 1;
		}
		return 0;
	}
コード例 #24
0
int LuaFosterWaterVolume::viscosity(lua_State* L)
{
	FosterWaterVolume *wv = checkInstance(L, 1);

	lua_pushnumber(L, wv->viscosity());

	return 1;
}
コード例 #25
0
int LuaFosterWaterVolume::size(lua_State* L)
{
	FosterWaterVolume *wv = checkInstance(L, 1);

	lua_pushnumber(L, wv->sizeX());

	return 1;
}
コード例 #26
0
ファイル: Model.cpp プロジェクト: RobloxLabs/OpenBlox
	int Model::lua_TranslateBy(lua_State* L){
		Instance* inst = checkInstance(L, 1);
		if(Model* m = dynamic_cast<Model*>(inst)){
			ob_type::Vector3* v3 = ob_type::checkVector3(L, 2);
			m->TranslateBy(v3);
			return 0;
		}
		return luaL_error(L, COLONERR, "TranslateBy");
	}
コード例 #27
0
int LuaFosterWaterVolume::setBottom(lua_State* L)
{
	FosterWaterVolume *wv = checkInstance(L, 1);
	Orbis::Drawable::GridTerrain *t = LuaGridTerrain::checkInstance(L, 2);

	wv->setBottom(t);

	return 0;
}
コード例 #28
0
int LuaFosterWaterVolume::setViscosity(lua_State* L)
{
	FosterWaterVolume *wv = checkInstance(L, 1);
	double visc = luaL_checknumber(L, 2);

	wv->setViscosity(visc);

	return 0;
}
コード例 #29
0
ファイル: luacamera.cpp プロジェクト: asandroq/orbis
/* sets the location of the Camera */
int LuaCamera::setLocation(lua_State* L)
{
	Camera *c = checkInstance(L, 1);
	Point *p = LuaPoint::checkInstance(L, 2);

	c->setLocation(*p);

	return 0;
}
コード例 #30
0
ファイル: luacamera.cpp プロジェクト: asandroq/orbis
/* sets the up direction of the Camera */
int LuaCamera::setUp(lua_State* L)
{
	Camera *c = checkInstance(L, 1);
	Vector *v = LuaVector::checkInstance(L, 2);

	c->setUp(*v);

	return 0;
}