Пример #1
0
 void safeCall(const std::string &entrypoint, const Args &... args) {
     try {
         auto luaEntrypoint = buildEntrypoint(entrypoint);
         luaEntrypoint(args...);
     } catch (luabind::error &e) {
         writeErrorMsg();
     }
 };
Пример #2
0
void LuaNPCScript::nextCycle() {
    init_functions();

    try {
        World::get()->setCurrentScript(this);
        call("nextCycle")();
    } catch (luabind::error &e) {
        writeErrorMsg();
    }
}
Пример #3
0
void LuaNPCScript::beforeReload() {
    init_functions();

    try {
        World::get()->setCurrentScript(this);
        Logger::writeMessage("scripts","LuaNPCScript::beforeReload called for: " + _thisnpc->name);
        call("beforeReload")();
    } catch (luabind::error &e) {
        writeErrorMsg();
    }
}
Пример #4
0
bool LuaNPCScript::lookAtNpc(Character *source, unsigned char mode) {
    init_functions();

    try {
        World::get()->setCurrentScript(this);
        fuse_ptr<Character> fuse_source(source);
        call("lookAtNpc")(fuse_source, mode);
        return true;
    } catch (luabind::error &e) {
        writeErrorMsg();
        return false;
    }
}
Пример #5
0
void LuaMagicScript::CastMagicOnItem(Character *caster, ScriptItem TargetItem, unsigned short counter, unsigned short int param, unsigned char ltastate) {
    // ToDo Script Calling
    try {
        World::get()->setCurrentScript(this);
        // World::get()->monitoringClientList->sendCommand( new SendMessageTS("CastMagicOnItem called for: " + Logger::toString(_MagicFlag ),3));
        Logger::writeMessage("scripts","CastMagicOnItem called for: " + Logger::toString(_MagicFlag));
        fuse_ptr<Character> fuse_caster(caster);
        call("CastMagicOnItem")(fuse_caster, TargetItem, counter, param, ltastate);
    } catch (luabind::error &e) {
        //CWorld::get()->monitoringClientList->sendCommand( new SendMessageTS("Error: CastMagicOnItem called for: " + Logger::toString(_MagicFlag ) + " " + e.what(),3));
        writeErrorMsg();
    }
}
Пример #6
0
    T safeCall(const std::string &entrypoint, const Args &... args) {
        try {
            auto luaEntrypoint = buildEntrypoint(entrypoint);
            auto result = luaEntrypoint(args...);
            return luabind::object_cast<T>(result);
        } catch (luabind::cast_failed &e) {
            writeCastErrorMsg(entrypoint, e);
        } catch (luabind::error &e) {
            writeErrorMsg();
        }

        return T();
    };
Пример #7
0
void LuaNPCScript::useNPC(Character *user, unsigned short counter, unsigned short int param, unsigned char ltastate) {
    init_functions();

    try {
        World::get()->setCurrentScript(this);
        //CWorld::get()->monitoringClientList->sendCommand( new SendMessageTS("LuaNPCScript::useNPC called for: " + _thisnpc->name,3));
        Logger::writeMessage("scripts","LuaNPCScript::useNPC called for: " + _thisnpc->name);
        fuse_ptr<Character> fuse_user(user);
        call("useNPC")(fuse_user, counter, param, ltastate);
    } catch (luabind::error &e) {
        writeErrorMsg();
        //CWorld::get()->monitoringClientList->sendCommand( new SendMessageTS("Error: LuaNPCScript::useNPC called for: " + _thisnpc->name + " " + e.what(),3));
    }
}
Пример #8
0
// we heard <cc> say <message>
void LuaNPCScript::receiveText(Character::talk_type tt, std::string message, Character *cc) {
    init_functions();

    try {
        World::get()->setCurrentScript(this);
#ifdef MAJORSCRIPTLOG
        //CWorld::get()->monitoringClientList->sendCommand( new SendMessageTS("LuaNPCScript::receiveText called for: " + _thisnpc->name,3));
        Logger::writeMessage("scripts","LuaNPCScript::receiveText called for: " + _thisnpc->name);
#endif
        fuse_ptr<Character> fuse_cc(cc);
        call("receiveText")((int)tt, message, fuse_cc);
    } catch (luabind::error &e) {
        writeErrorMsg();
        //CWorld::get()->monitoringClientList->sendCommand( new SendMessageTS("Error: LuaNPCScript::receiveText called for: " + _thisnpc->name + " " + e.what(),3));
    }
}
Пример #9
0
void LuaNPCScript::abortRoute(Character *npc) {
    init_functions();

    try {
        World::get()->setCurrentScript(this);
#ifdef MAJORSCRIPTLOG
        //CWorld::get()->monitoringClientList->sendCommand( new SendMessageTS("enemyNear called for: " + Monster->name,3));
        Logger::writeMessage("scripts","abortRoute called for: " + npc->name);
#endif
        fuse_ptr<Character> fuse_npc(npc);
        call("abortRoute")(fuse_npc);
    } catch (luabind::error &e) {
        writeErrorMsg();
        //CWorld::get()->monitoringClientList->sendCommand( new SendMessageTS("Error: enemyNear called for: " + Monster->name + " " + e.what(),3));
    }
}