Example #1
0
static int forcePrecacheResource(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	assert(pKernel);
	ResourceManager *pResource = pKernel->getResourceManager();
	assert(pResource);

#ifdef PRECACHE_RESOURCES
	lua_pushbooleancpp(L, pResource->precacheResource(luaL_checkstring(L, 1), true));
#else
	lua_pushbooleancpp(L, true);
#endif

	return 1;
}
Example #2
0
static int init(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	if (lua_gettop(L) == 0)
		lua_pushbooleancpp(L, pSfx->init(44100, 32));
	else if (lua_gettop(L) == 1)
		lua_pushbooleancpp(L, pSfx->init(static_cast<uint>(luaL_checknumber(L, 1)), 32));
	else
		lua_pushbooleancpp(L, pSfx->init(static_cast<uint>(luaL_checknumber(L, 1)), static_cast<uint>(luaL_checknumber(L, 2))));

	return 1;
}
Example #3
0
static int startService(lua_State *L) {
	// This function is used by system/boot.lua to init all services.
	// However, we do nothing here, as we just hard code the init sequence.
	lua_pushbooleancpp(L, true);

	return 1;
}
Example #4
0
bool LuaBindhelper::getMetatable(lua_State *L, const Common::String &tableName) {
	// Push the Metatable table onto the stack
	pushMetatableTable(L);

	// Versuchen, die gewünschte Metatabelle auf den Stack zu legen. Wenn sie noch nicht existiert, muss sie erstellt werden.
	lua_getfield(L, -1, tableName.c_str());
	if (lua_isnil(L, -1)) {
		// Pop nil from stack
		lua_pop(L, 1);

		// Create new table
		lua_newtable(L);

		// Set the __index field in the table
		lua_pushvalue(L, -1);
		lua_setfield(L, -2, "__index");

		// Flag the table as persisted. This ensures that objects within this table get stored
		lua_pushbooleancpp(L, true);
		lua_setfield(L, -2, "__persist");

		// Set the table name and push it onto the stack
		lua_pushvalue(L, -1);
		lua_setfield(L, -3, tableName.c_str());
	}

	// Remove the Metatable table from the stack
	lua_remove(L, -2);

	return true;
}
Example #5
0
static int r_isValid(lua_State *L) {
	Region *pR = checkRegion(L);
	assert(pR);

	lua_pushbooleancpp(L, pR->isValid());
	return 1;
}
Example #6
0
static int r_isPointInRegion(lua_State *L) {
	Region *pR = checkRegion(L);
	assert(pR);

	Vertex vertex;
	Vertex::luaVertexToVertex(L, 2, vertex);
	lua_pushbooleancpp(L, pR->isPointInRegion(vertex));
	return 1;
}
Example #7
0
static int executeFile(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	assert(pKernel);
	ScriptEngine *pSE = pKernel->getScript();
	assert(pSE);

	lua_pushbooleancpp(L, pSE->executeFile(luaL_checkstring(L, 1)));

	return 0;
}
Example #8
0
static int isSoundPlaying(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	lua_pushbooleancpp(L, pSfx->isSoundPlaying(static_cast<uint>(luaL_checknumber(L, 1))));

	return 1;
}
Example #9
0
static int isLogCacheMiss(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	assert(pKernel);
	ResourceManager *pResource = pKernel->getResourceManager();
	assert(pResource);

	// This isn't used in any script
	lua_pushbooleancpp(L, false);

	return 1;
}
Example #10
0
static int processMessages(lua_State *L) {
	// This is called by the main loop in system/boot.lua,
	// and the game keeps running as true is returned here.
	// It terminates if we return false.

	// TODO: We could do more stuff here if desired...

	// TODO: We could always return true here, and leave quit handling
	// to the closeWanted() opcode; see also the TODO comment in there.

	lua_pushbooleancpp(L, !Engine::shouldQuit());

	return 1;
}
Example #11
0
static int closeWanted(lua_State *L) {
	// This is called by system/interface.lua to determine whether the
	// user requested the game to close (e.g. by clicking the 'close' widget
	// of the game window). As a consequence (i.e. this function returns true),
	// a quit confirmation dialog is shown.

	// TODO: ScummVM currently has a bug / misfeature where some engines provide
	// quit confirmation dialogs, some don't; in addition, we have a global confirmation
	// dialog (but the user has to explicitly activate that in the config).
	// Anyway, this can lead to *two* confirmation dialogs being shown.
	// If it wasn't for that, we could simply check for Engine::shouldQuit() here,
	// and then invoke EventMan::resetQuit. But currently this would result in
	// the user seeing two confirmation dialogs. Bad.
	lua_pushbooleancpp(L, false);

	return 1;
}
Example #12
0
static int playSound(lua_State *L) {
	Kernel *pKernel = Kernel::getInstance();
	BS_ASSERT(pKernel);
	SoundEngine *pSfx = pKernel->getSfx();
	BS_ASSERT(pSfx);

	Common::String fileName;
	SoundEngine::SOUND_TYPES type;
	float volume;
	float pan;
	bool loop;
	int loopStart;
	int loopEnd;
	uint layer;
	processPlayParams(L, fileName, type, volume, pan, loop, loopStart, loopEnd, layer);

	lua_pushbooleancpp(L, pSfx->playSound(fileName, type, volume, pan, loop, loopStart, loopEnd, layer));

	return 1;
}
Example #13
0
static int hasFocus(lua_State *L) {
	// This function apparently is not used by the game scripts
	lua_pushbooleancpp(L, true);

	return 1;
}
Example #14
0
static int loadGame(lua_State *L) {
	lua_pushbooleancpp(L, PersistenceService::getInstance().loadGame(static_cast<uint>(luaL_checknumber(L, 1)) - 1));
	return 1;
}
Example #15
0
static int isSlotOccupied(lua_State *L) {
	lua_pushbooleancpp(L, PersistenceService::getInstance().isSlotOccupied(static_cast<uint>(luaL_checknumber(L, 1)) - 1));
	return 1;
}
Example #16
0
static int isSavegameCompatible(lua_State *L) {
	lua_pushbooleancpp(L, PersistenceService::getInstance().isSavegameCompatible(
	                       static_cast<uint>(luaL_checknumber(L, 1)) - 1));
	return 1;
}
Example #17
0
static int fileExists(lua_State *L) {
	lua_pushbooleancpp(L, FileSystemUtil::fileExists(luaL_checkstring(L, 1)));
	return 1;
}
Example #18
0
static int saveGame(lua_State *L) {
	lua_pushbooleancpp(L, PersistenceService::getInstance().saveGame(static_cast<uint>(luaL_checknumber(L, 1)) - 1, luaL_checkstring(L, 2)));
	return 1;
}
Example #19
0
static int createDirectory(lua_State *L) {
	// ScummVM engines cannot create directories, so we do nothing here.
	lua_pushbooleancpp(L, false);
	return 1;
}