virtual void SomeMember() { if( overide.isFunction() ) overide(); else { cout << "Overide is not a function" << endl; } }
bool ScriptSystem::GetComponents(GameObject* pObj, Components* pComp) { pComp->pScript = Component<ScriptComponent>::GetComponent(pObj); if(pComp->pScript != NULL) { LuaRef& luaRef = (*pComp->pScript->pLuaRef); LuaRef init = luaRef["GetComponents"]; LuaRef run = luaRef["Run"]; if(init.isFunction() && run.isFunction()) { bool bOk = init((*pComp->pScript->pLuaRef)); return bOk; } } return false; }
void DialogueLoader::loadDialogue() { lua_State* L = luaL_newstate(); luaL_openlibs(L); getGlobalNamespace(L) .beginClass<DialogueLoader>("Dialogue") .addFunction("isNPCState", &DialogueLoader::isNPCState) .addFunction("isQuestState", &DialogueLoader::isQuestState) .addFunction("isQuestComplete", &DialogueLoader::isQuestComplete) .addFunction("createCendricNode", &DialogueLoader::createCendricNode) .addFunction("createNPCNode", &DialogueLoader::createNPCNode) .addFunction("createChoiceNode", &DialogueLoader::createChoiceNode) .addFunction("createTradeNode", &DialogueLoader::createTradeNode) .addFunction("addChoice", &DialogueLoader::addChoice) .addFunction("changeNPCState", &DialogueLoader::changeNPCState) .addFunction("changeQuestState", &DialogueLoader::changeQuestState) .addFunction("addQuestProgress", &DialogueLoader::addQuestProgress) .addFunction("addItem", &DialogueLoader::addItem) .addFunction("removeItem", &DialogueLoader::removeItem) .addFunction("addGold", &DialogueLoader::addGold) .addFunction("removeGold", &DialogueLoader::removeGold) .addFunction("setRoot", &DialogueLoader::setRoot) .addFunction("addNode", &DialogueLoader::addNode) .endClass(); if (luaL_dofile(L, m_dialogue.getID().c_str()) != 0) { g_logger->logError("DialogeLoader", "Cannot read lua script: " + m_dialogue.getID()); return; } LuaRef function = getGlobal(L, "loadDialogue"); if (!function.isFunction()) { g_logger->logError("DialogeLoader", "Lua script: " + m_dialogue.getID() + " has no loadDialogue function."); return; } try { function(this); } catch (LuaException const& e) { g_logger->logError("DialogeLoader", "LuaException: " + std::string(e.what())); } }
void Bot::queue(LuaRef action) { if (!action.isNil() && action.isFunction()) _queue.push_back(action); }