Log in

View Full Version : Lua Mob.Say() optional language parameter


Shendare
08-29-2014, 04:17 PM
A while back an optional Language parameter was added to the Perl function for having an NPC say something, so that NPCs could speak other languages besides common.

When I skimmed over the Lua API reference taking a first look, I didn't see that as an option:


Mob member functions:

...
Void Say(String message);
...


Would it be possible to add an optional language parameter to the existing Lua function?

Or, alternatively, to add like a SayLang() function that would take a language code as well as the message text?

KLS
08-31-2014, 03:41 PM
I'm going to add a way to do this for you.

Shendare
08-31-2014, 03:55 PM
You ROCK! \m/

KLS
08-31-2014, 11:22 PM
As of next release you'll be able to add something like:

function eq.Say(msg, lang)
local owner = eq.get_owner();
if(owner.null) then
return;
end

if(lang == nil) then
owner:Say(msg);
else
local entity_list = eq.get_entity_list();

entity_list:ChannelMessage(owner, 8, lang, msg);
end
end

in your lua_modules/general_ext.lua

Then you'll be able to use it in scripts like:

if(e.message:findi("hail")) then
eq.Say("Test string 1");
elseif(e.message:findi("there")) then
eq.Say("Test string in thieve's cant.", 10);
end


In the same way quest::say is used in perl more or less.

Shendare
08-31-2014, 11:32 PM
Perfection. Thanks, KLS.

This can add a very nice level of flavor, and means we won't have to revert to Perl for the functionality.

Thanks a ton for the quick turnaround.