Moved some talk code to lua
This commit is contained in:
parent
6feaeff8cc
commit
0e67bd97a5
|
@ -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]
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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>();
|
||||
|
|
Loading…
Reference in New Issue