Moved some talk code to lua

This commit is contained in:
Henrique Santiago 2012-08-07 13:33:08 -03:00
parent 6feaeff8cc
commit 0e67bd97a5
4 changed files with 15 additions and 11 deletions

View File

@ -428,7 +428,6 @@ function setIgnoreNpcMessages(ignore)
ignoreNpcMessages = ignore
end
function navigateMessageHistory(step)
local numCommands = #messageHistory
if numCommands > 0 then
@ -455,6 +454,16 @@ end
function onTalk(name, level, mode, message, channelId, creaturePos)
if ignoreNpcMessages and mode == MessageModes.NpcFrom then return end
if (mode == MessageModes.Say or mode == MessageModes.Whisper or mode == MessageModes.Yell or
mode == MessageModes.Spell or mode == MessageModes.MonsterSay or mode == MessageModes.MonsterYell or
mode == MessageModes.NpcFrom or mode == MessageModes.BarkLow or mode == MessageModes.BarkLoud) and
creaturePos then
local staticText = StaticText.create()
staticText:addMessage(name, mode, message)
g_map.addThing(staticText, creaturePos, -1)
end
local defaultMessage = mode < 3 and true or false
speaktype = SpeakTypes[mode]

View File

@ -94,7 +94,7 @@ function displayMessage(mode, text)
end
function displayPrivateMessage(text)
displayMessage(254, text)
displayMessage(254, text)
end
function displayStatusMessage(text)

View File

@ -170,15 +170,6 @@ void Game::processTextMessage(Otc::MessageMode mode, const std::string& text)
void Game::processTalk(const std::string& name, int level, Otc::MessageMode mode, const std::string& text, int channelId, const Position& pos)
{
if(pos.isValid() && (mode == Otc::MessageSay || mode == Otc::MessageWhisper || mode == Otc::MessageYell || mode == Otc::MessageSpell ||
mode == Otc::MessageMonsterSay || mode == Otc::MessageMonsterYell || mode == Otc::MessageNpcFrom ||
mode == Otc::MessageBarkLow || mode == Otc::MessageBarkLoud))
{
StaticTextPtr staticText = StaticTextPtr(new StaticText);
staticText->addMessage(name, mode, text);
g_map.addThing(staticText, pos);
}
g_lua.callGlobalField("g_game", "onTalk", name, level, mode, text, channelId, pos);
}

View File

@ -351,7 +351,11 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<Effect, Thing>();
g_lua.registerClass<Missile, Thing>();
g_lua.registerClass<StaticText, Thing>();
g_lua.bindClassStaticFunction<StaticText>("create", []{ return StaticTextPtr(new StaticText); });
g_lua.bindClassMemberFunction<StaticText>("addMessage", &StaticText::addMessage);
g_lua.registerClass<AnimatedText, Thing>();
g_lua.registerClass<Player, Creature>();