Exemplo n.º 1
0
void Actor::collisionHandlerCallback(Actor *other) const {
	LuaObjects objects;
	objects.add(this);
	objects.add(other);

	LuaBase::instance()->callback("collisionHandler", objects);
}
Exemplo n.º 2
0
bool LuaBase::callback(const char *name, const LuaObjects &objects) {
	lua_beginblock();

	lua_pushobject(lua_getref(refSystemTable));
	lua_pushstring(name);
	lua_Object table = lua_gettable();

	if (lua_istable(table)) {
		lua_pushobject(table);
		lua_pushstring(name);
		lua_Object func = lua_gettable();
		if (lua_isfunction(func)) {
			lua_pushobject(table);
			objects.pushObjects();
			lua_callfunction(func);
		} else {
			lua_endblock();
			return false;
		}
	} else if (lua_isfunction(table)) {
		objects.pushObjects();
		lua_callfunction(table);
	} else if (!lua_isnil(table)) {
		lua_endblock();
		return false;
	}

	lua_endblock();
	return true;
}
Exemplo n.º 3
0
void Actor::costumeMarkerCallback(int marker) {
	LuaObjects objects;
	objects.add(this);
	objects.add(marker);

	LuaBase::instance()->callback("costumeMarkerHandler", objects);
}
Exemplo n.º 4
0
void GrimEngine::handleChars(Common::EventType operation, const Common::KeyState &key) {
	if (!CHAR_KEY(key.ascii))
		return;

	char keychar[2];
	keychar[0] = key.ascii;
	keychar[1] = 0;

	LuaObjects objects;
	objects.add(keychar);

	if (!LuaBase::instance()->callback("characterHandler", objects)) {
		error("handleChars: invalid handler");
	}
}
Exemplo n.º 5
0
void GrimEngine::handleControls(Common::EventType operation, const Common::KeyState &key) {
	// Might also want to support keypad-enter?
	if (key.hasFlags(Common::KBD_ALT) && key.keycode == Common::KEYCODE_RETURN && operation == Common::EVENT_KEYDOWN) {
		_changeFullscreenState = true;
	}

	// If we're not supposed to handle the key then don't
	if (!_controlsEnabled[key.keycode])
		return;

	LuaObjects objects;
	objects.add(key.keycode);
	if (operation == Common::EVENT_KEYDOWN) {
		objects.add(1);
		objects.add(1);
	} else {
		objects.addNil();
		objects.add(0);
	}
	objects.add(0);
	if (!LuaBase::instance()->callback("buttonHandler", objects)) {
		error("handleControls: invalid keys handler");
	}
	// 	if (!LuaBase::instance()->callback("axisHandler", objects)) {
	// 		error("handleControls: invalid joystick handler");
	// 	}

	if (operation == Common::EVENT_KEYDOWN)
		_controlsState[key.keycode] = true;
	else if (operation == Common::EVENT_KEYUP)
		_controlsState[key.keycode] = false;
}
Exemplo n.º 6
0
void GrimEngine::cameraPostChangeHandle(int num) {
	LuaObjects objects;
	objects.add(num);
	LuaBase::instance()->callback("postCamChangeHandler", objects);
}
Exemplo n.º 7
0
void GrimEngine::cameraChangeHandle(int prev, int next) {
	LuaObjects objects;
	objects.add(prev);
	objects.add(next);
	LuaBase::instance()->callback("camChangeHandler", objects);
}