/* * Copyright (c) 2010-2012 OTClient * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "otclient.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void OTClient::registerLuaFunctions() { Application::registerLuaFunctions(); g_lua.registerStaticClass("g_thingsType"); g_lua.bindClassStaticFunction("g_thingsType", "load", std::bind(&ThingsType::load, &g_thingsType, _1)); g_lua.bindClassStaticFunction("g_thingsType", "isLoaded", std::bind(&ThingsType::isLoaded, &g_thingsType)); g_lua.bindClassStaticFunction("g_thingsType", "getSignature", std::bind(&ThingsType::getSignature, &g_thingsType)); g_lua.registerStaticClass("g_sprites"); g_lua.bindClassStaticFunction("g_sprites", "load", std::bind(&SpriteManager::load, &g_sprites, _1)); g_lua.bindClassStaticFunction("g_sprites", "isLoaded", std::bind(&SpriteManager::isLoaded, &g_sprites)); g_lua.bindClassStaticFunction("g_sprites", "getSignature", std::bind(&SpriteManager::getSignature, &g_sprites)); g_lua.bindClassStaticFunction("g_sprites", "preloadSprites", std::bind(&SpriteManager::preloadSprites, &g_sprites)); g_lua.registerStaticClass("g_map"); g_lua.bindClassStaticFunction("g_map", "isLookPossible", std::bind(&Map::isLookPossible, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "isCovered", std::bind(&Map::isCovered, &g_map, _1, _2)); g_lua.bindClassStaticFunction("g_map", "isCompletelyCovered", std::bind(&Map::isCompletelyCovered, &g_map, _1, _2)); g_lua.bindClassStaticFunction("g_map", "addThing", std::bind(&Map::addThing, &g_map, _1, _2, _3)); g_lua.bindClassStaticFunction("g_map", "getThing", std::bind(&Map::getThing, &g_map, _1, _2)); g_lua.bindClassStaticFunction("g_map", "removeThingByPos", std::bind(&Map::removeThingByPos, &g_map, _1, _2)); g_lua.bindClassStaticFunction("g_map", "removeThing", std::bind(&Map::removeThing, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "cleanTile", std::bind(&Map::cleanTile, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "getTile", std::bind(&Map::getTile, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "setCentralPosition", std::bind(&Map::setCentralPosition, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "getCentralPosition", std::bind(&Map::getCentralPosition, &g_map)); g_lua.bindClassStaticFunction("g_map", "getCreatureById", std::bind(&Map::getCreatureById, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "removeCreatureById", std::bind(&Map::removeCreatureById, &g_map, _1)); g_lua.bindClassStaticFunction("g_map", "getSpectators", std::bind(&Map::getSpectators, &g_map, _1, _2)); g_lua.bindGlobalFunction("getOufitColor", Outfit::getColor); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &ProtocolLogin::create); g_lua.bindClassMemberFunction("login", &ProtocolLogin::login); g_lua.bindClassMemberFunction("cancelLogin", &ProtocolLogin::cancelLogin); g_lua.registerClass(); g_lua.registerClass(); g_lua.bindClassMemberFunction("setId", &Thing::setId); g_lua.bindClassMemberFunction("setPosition", &Thing::setPosition); g_lua.bindClassMemberFunction("getId", &Thing::getId); g_lua.bindClassMemberFunction("getPosition", &Thing::getPosition); g_lua.bindClassMemberFunction("getStackPriority", &Thing::getStackPriority); g_lua.bindClassMemberFunction("getAnimationPhases", &Thing::getAnimationPhases); g_lua.bindClassMemberFunction("asThing", &Thing::asThing); g_lua.bindClassMemberFunction("asItem", &Thing::asItem); g_lua.bindClassMemberFunction("asCreature", &Thing::asCreature); g_lua.bindClassMemberFunction("asEffect", &Thing::asEffect); g_lua.bindClassMemberFunction("asMissile", &Thing::asMissile); g_lua.bindClassMemberFunction("asPlayer", &Thing::asPlayer); g_lua.bindClassMemberFunction("asLocalPlayer", &Thing::asLocalPlayer); g_lua.bindClassMemberFunction("asAnimatedText", &Thing::asAnimatedText); g_lua.bindClassMemberFunction("asStaticText", &Thing::asStaticText); g_lua.bindClassMemberFunction("isGround", &Thing::isGround); g_lua.bindClassMemberFunction("isGroundBorder", &Thing::isGroundBorder); g_lua.bindClassMemberFunction("isOnBottom", &Thing::isOnBottom); g_lua.bindClassMemberFunction("isOnTop", &Thing::isOnTop); g_lua.bindClassMemberFunction("isContainer", &Thing::isContainer); g_lua.bindClassMemberFunction("isForceUse", &Thing::isForceUse); g_lua.bindClassMemberFunction("isMultiUse", &Thing::isMultiUse); g_lua.bindClassMemberFunction("isRotateable", &Thing::isRotateable); g_lua.bindClassMemberFunction("isNotMoveable", &Thing::isNotMoveable); g_lua.bindClassMemberFunction("isPickupable", &Thing::isPickupable); g_lua.bindClassMemberFunction("isIgnoreLook", &Thing::isIgnoreLook); g_lua.bindClassMemberFunction("isStackable", &Thing::isStackable); g_lua.bindClassMemberFunction("isTranslucent", &Thing::isTranslucent); g_lua.bindClassMemberFunction("isFullGround", &Thing::isFullGround); g_lua.registerClass(); g_lua.bindClassMemberFunction("getName", &Creature::getName); g_lua.bindClassMemberFunction("getShield", &Creature::getShield); g_lua.bindClassMemberFunction("setOutfit", &Creature::setOutfit); g_lua.bindClassMemberFunction("getOutfit", &Creature::getOutfit); g_lua.bindClassMemberFunction("setSkullTexture", &Creature::setSkullTexture); g_lua.bindClassMemberFunction("setShieldTexture", &Creature::setShieldTexture); g_lua.bindClassMemberFunction("setEmblemTexture", &Creature::setEmblemTexture); g_lua.bindClassMemberFunction("asMonster", &Creature::asMonster); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", &Item::create); g_lua.bindClassMemberFunction("getCount", &Item::getCount); g_lua.registerClass(); g_lua.registerClass(); g_lua.registerClass(); g_lua.registerClass(); g_lua.registerClass(); g_lua.bindClassMemberFunction("isWalking", &Creature::isWalking); g_lua.registerClass(); g_lua.registerClass(); g_lua.registerClass(); g_lua.bindClassMemberFunction("getAttackingCreature", &LocalPlayer::getAttackingCreature); g_lua.bindClassMemberFunction("getFollowingCreature", &LocalPlayer::getFollowingCreature); g_lua.bindClassMemberFunction("getHealth", &LocalPlayer::getHealth); g_lua.bindClassMemberFunction("getMaxHealth", &LocalPlayer::getMaxHealth); g_lua.bindClassMemberFunction("getFreeCapacity", &LocalPlayer::getFreeCapacity); g_lua.bindClassMemberFunction("getExperience", &LocalPlayer::getExperience); g_lua.bindClassMemberFunction("getLevel", &LocalPlayer::getLevel); g_lua.bindClassMemberFunction("getLevelPercent", &LocalPlayer::getLevelPercent); g_lua.bindClassMemberFunction("getMana", &LocalPlayer::getMana); g_lua.bindClassMemberFunction("getMaxMana", &LocalPlayer::getMaxMana); g_lua.bindClassMemberFunction("getMagicLevel", &LocalPlayer::getMagicLevel); g_lua.bindClassMemberFunction("getMagicLevelPercent", &LocalPlayer::getMagicLevelPercent); g_lua.bindClassMemberFunction("getSoul", &LocalPlayer::getSoul); g_lua.bindClassMemberFunction("getStamina", &LocalPlayer::getStamina); g_lua.registerClass(); g_lua.bindClassMemberFunction("clean", &Tile::clean); g_lua.bindClassMemberFunction("addThing", &Tile::addThing); g_lua.bindClassMemberFunction("getThing", &Tile::getThing); g_lua.bindClassMemberFunction("getThingStackpos", &Tile::getThingStackpos); g_lua.bindClassMemberFunction("getTopThing", &Tile::getTopThing); g_lua.bindClassMemberFunction("removeThing", &Tile::removeThing); g_lua.bindClassMemberFunction("getTopLookThing", &Tile::getTopLookThing); g_lua.bindClassMemberFunction("getTopUseThing", &Tile::getTopUseThing); g_lua.bindClassMemberFunction("getTopCreature", &Tile::getTopCreature); g_lua.bindClassMemberFunction("getTopMoveThing", &Tile::getTopMoveThing); g_lua.bindClassMemberFunction("getTopMultiUseThing", &Tile::getTopMultiUseThing); g_lua.bindClassMemberFunction("getPosition", &Tile::getPosition); g_lua.bindClassMemberFunction("getDrawElevation", &Tile::getDrawElevation); g_lua.bindClassMemberFunction("getCreatures", &Tile::getCreatures); g_lua.bindClassMemberFunction("getGround", &Tile::getGround); g_lua.bindClassMemberFunction("isWalkable", &Tile::isWalkable); g_lua.bindClassMemberFunction("isFullGround", &Tile::isFullGround); g_lua.bindClassMemberFunction("isFullyOpaque", &Tile::isFullyOpaque); g_lua.bindClassMemberFunction("isLookPossible", &Tile::isLookPossible); g_lua.bindClassMemberFunction("hasCreature", &Tile::hasCreature); g_lua.bindClassMemberFunction("isEmpty", &Tile::isEmpty); g_lua.bindClassMemberFunction("isClickable", &Tile::isClickable); g_lua.registerClass(); g_lua.registerClass(); g_lua.bindClassStaticFunction("loginWorld", std::bind(&Game::loginWorld, &g_game, _1, _2, _3, _4, _5)); g_lua.bindClassStaticFunction("logout", std::bind(&Game::logout, &g_game, _1)); g_lua.bindClassStaticFunction("cancelLogin", std::bind(&Game::cancelLogin, &g_game)); g_lua.bindClassStaticFunction("isOnline", std::bind(&Game::isOnline, &g_game)); g_lua.bindClassStaticFunction("requestOutfit", std::bind(&Game::requestOutfit, &g_game)); g_lua.bindClassStaticFunction("requestChannels", std::bind(&Game::requestChannels, &g_game)); g_lua.bindClassStaticFunction("joinChannel", std::bind(&Game::joinChannel, &g_game, _1)); g_lua.bindClassStaticFunction("setOutfit", std::bind(&Game::setOutfit, &g_game, _1)); g_lua.bindClassStaticFunction("look", std::bind(&Game::look, &g_game, _1)); g_lua.bindClassStaticFunction("open", std::bind(&Game::open, &g_game, _1, _2)); g_lua.bindClassStaticFunction("use", std::bind(&Game::use, &g_game, _1)); g_lua.bindClassStaticFunction("useWith", std::bind(&Game::useWith, &g_game, _1, _2)); g_lua.bindClassStaticFunction("move", std::bind(&Game::move, &g_game, _1, _2, _3)); g_lua.bindClassStaticFunction("useInventoryItem", std::bind(&Game::useInventoryItem, &g_game, _1, _2)); g_lua.bindClassStaticFunction("turn", std::bind(&Game::turn, &g_game, _1)); g_lua.bindClassStaticFunction("walk", std::bind(&Game::walk, &g_game, _1)); g_lua.bindClassStaticFunction("forceWalk", std::bind(&Game::forceWalk, &g_game, _1)); g_lua.bindClassStaticFunction("attack", std::bind(&Game::attack, &g_game, _1)); g_lua.bindClassStaticFunction("cancelAttack", std::bind(&Game::cancelAttack, &g_game)); g_lua.bindClassStaticFunction("follow", std::bind(&Game::follow, &g_game, _1)); g_lua.bindClassStaticFunction("cancelFollow", std::bind(&Game::cancelFollow, &g_game)); g_lua.bindClassStaticFunction("rotate", std::bind(&Game::rotate, &g_game, _1)); g_lua.bindClassStaticFunction("partyInvite", std::bind(&Game::partyInvite, &g_game, _1)); g_lua.bindClassStaticFunction("partyJoin", std::bind(&Game::partyJoin, &g_game, _1)); g_lua.bindClassStaticFunction("partyRevokeInvitation", std::bind(&Game::partyRevokeInvitation, &g_game, _1)); g_lua.bindClassStaticFunction("partyPassLeadership", std::bind(&Game::partyPassLeadership, &g_game, _1)); g_lua.bindClassStaticFunction("partyLeave", std::bind(&Game::partyLeave, &g_game)); g_lua.bindClassStaticFunction("partyShareExperience", std::bind(&Game::partyShareExperience, &g_game, _1)); g_lua.bindClassStaticFunction("addVip", std::bind(&Game::addVip, &g_game, _1)); g_lua.bindClassStaticFunction("removeVip", std::bind(&Game::removeVip, &g_game, _1)); g_lua.bindClassStaticFunction("talk", std::bind(&Game::talk, &g_game, _1)); g_lua.bindClassStaticFunction("talkChannel", std::bind(&Game::talkChannel, &g_game, _1, _2, _3)); g_lua.bindClassStaticFunction("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3)); g_lua.bindClassStaticFunction("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game)); g_lua.bindClassStaticFunction("getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game)); g_lua.bindClassStaticFunction("getProtocolGame", std::bind(&Game::getProtocolGame, &g_game)); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIItemPtr(new UIItem); }); g_lua.bindClassMemberFunction("setItemId", &UIItem::setItemId); g_lua.bindClassMemberFunction("setItemCount", &UIItem::setItemCount); g_lua.bindClassMemberFunction("setItem", &UIItem::setItem); g_lua.bindClassMemberFunction("setVirtual", &UIItem::setVirtual); g_lua.bindClassMemberFunction("getItemId", &UIItem::getItemId); g_lua.bindClassMemberFunction("getItemCount", &UIItem::getItemCount); g_lua.bindClassMemberFunction("getItem", &UIItem::getItem); g_lua.bindClassMemberFunction("isVirtual", &UIItem::isVirtual); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UICreaturePtr(new UICreature); } ); g_lua.bindClassMemberFunction("getCreature", &UICreature::getCreature); g_lua.bindClassMemberFunction("setCreature", &UICreature::setCreature); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIMapPtr(new UIMap); } ); g_lua.bindClassMemberFunction("getTile", &UIMap::getTile); g_lua.bindClassMemberFunction("zoomIn", &UIMap::zoomIn); g_lua.bindClassMemberFunction("zoomOut", &UIMap::zoomOut); g_lua.registerClass(); g_lua.bindClassStaticFunction("create", []{ return UIGamePtr(new UIGame); } ); }