Example #1
0
void Sound::luaBindings(sol::state &lua) {

    lua.new_usertype<Properties>("SoundProperties",

        sol::base_classes, sol::bases<Touchable>(),

        "playState", &Properties::playState,
        "loop", &Properties::loop,
        "volume", &Properties::volume,
        "maxDistance", &Properties::maxDistance,
        "rolloffFactor", &Properties::rolloffFactor,
        "referenceDistance", &Properties::referenceDistance,
        "priority", &Properties::priority
    );
    
    lua.new_usertype<Sound>("Sound",

        sol::constructors<sol::types<std::string, std::string>>(),

        "PlayState", sol::var(lua.create_table_with(
                "Play", PlayState::Play,
                "Pause", PlayState::Pause,
                "Stop", PlayState::Stop
            )),
            
        "name", &Sound::name,
        "pause", &Sound::pause,
        "play", &Sound::play,
        "stop", &Sound::stop,

        "properties", sol::readonly(&Sound::m_properties)
    );
}
Example #2
0
  static void luaBinding(sol::state &lua) {
  	lua.new_usertype<WebDriver>("WebDriver",
      "getDriverAddress",&WebDriver::getDriverAddress,
      "setDriverAddress",&WebDriver::setDriverAddress,
      "getSession",&WebDriver::getSession,
      "setSession",&WebDriver::setSession,
      "newSession", &WebDriver::newSession,
      "go", &WebDriver::go,
      "getCurrentURL",&WebDriver::getCurrentURL,
      "getPageSource", &WebDriver::getPageSource,
      "takeScreenshot", &WebDriver::takeScreenshot,
      "executeScript", &WebDriver::executeScript,
      "executeScriptFromFile", &WebDriver::executeScriptFromFile,
      "deleteSession", &WebDriver::deleteSession
  	);

    lua["webDriver"] = lua.create_table_with(
      "chrome",chromeWebDriver,
      "fireFox",fireFoxWebDriver
    );
  }
Example #3
0
void OgreLightComponent::luaBindings(
    sol::state &lua
){

    lua.new_usertype<Properties>("OgreLightComponentProperties",

        sol::base_classes, sol::bases<Touchable>(),

        "attenuationConstant", &Properties::attenuationConstant,
        "attenuationLinear", &Properties::attenuationLinear,
        "attenuationRange", &Properties::attenuationRange,
        "attenuationQuadratic", &Properties::attenuationQuadratic,
        "diffuseColour", &Properties::diffuseColour,
        "specularColour", &Properties::specularColour,
        "spotlightFalloff", &Properties::spotlightFalloff,
        "spotlightInnerAngle", &Properties::spotlightInnerAngle,
        "spotlightNearClipDistance", &Properties::spotlightNearClipDistance,
        "spotlightOuterAngle", &Properties::spotlightOuterAngle,
        "type", &Properties::type
    );
    
    lua.new_usertype<OgreLightComponent>("OgreLightComponent",

        "new", sol::factories([](){
                return std::make_unique<OgreLightComponent>();
            }),

        COMPONENT_BINDINGS(OgreLightComponent),

        "setRange", &OgreLightComponent::setRange,
        "properties", sol::readonly(&OgreLightComponent::m_properties),

        "LightTypes", sol::var(lua.create_table_with(
                "LT_POINT", Ogre::Light::LT_POINT,
                "LT_DIRECTIONAL", Ogre::Light::LT_DIRECTIONAL,
                "LT_SPOTLIGHT", Ogre::Light::LT_SPOTLIGHT
            ))
    );
}
Example #4
0
}

TEST_CASE("tables/as-enums", "Making sure enums can be put in and gotten out as values") {
	enum direction {
		up,
		down,
		left,
		right
	};
	
	sol::state lua;
	lua.open_libraries(sol::lib::base);

	lua["direction"] = lua.create_table_with(
		"up", direction::up,
		"down", direction::down,
		"left", direction::left,
		"right", direction::right
	);

	sol::object obj = lua["direction"]["up"];
	bool isdir = obj.is<direction>();
	REQUIRE(isdir);
	auto dir = obj.as<direction>();
	REQUIRE(dir == direction::up);
}

TEST_CASE("tables/as-enum-classes", "Making sure enums can be put in and gotten out as values") {
	enum class direction {
		up,
		down,
		left,