本文整理汇总了C++中Npc::doSay方法的典型用法代码示例。如果您正苦于以下问题:C++ Npc::doSay方法的具体用法?C++ Npc::doSay怎么用?C++ Npc::doSay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Npc
的用法示例。
在下文中一共展示了Npc::doSay方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: luaActionSay
int NpcScriptInterface::luaActionSay(lua_State* L)
{
//selfSay(words [[, target], send_to_all])
// send_to_all defaults to true if there is no target, false otherwise
uint32_t parameters = lua_gettop(L);
uint32_t target = 0;
bool send_to_all = true;
if(parameters == 3)
{
send_to_all = (popNumber(L) == LUA_TRUE);
target = popNumber(L);
}
else if(parameters == 2)
{
target = popNumber(L);
send_to_all = false;
}
std::string msg(popString(L));
ScriptEnviroment* env = getScriptEnv();
Npc* npc = env->getNpc();
Player* focus = env->getPlayerByUID(target);
if(npc){
npc->doSay(msg, focus, send_to_all);
}
return 0;
}
示例2: luaActionSay
int32_t NpcScriptInterface::luaActionSay(lua_State* L)
{
//selfSay(words [[, target], publicize])
// publicize defaults to true if there is no target, false otherwise
uint32_t parameters = lua_gettop(L);
uint32_t target = 0;
bool publicize;
if (parameters >= 3) {
publicize = popBoolean(L);
} else {
publicize = true;
}
if (parameters >= 2) {
target = popNumber(L);
if (target != 0) {
publicize = false;
}
}
std::string text = popString(L);
Npc* npc = getScriptEnv()->getNpc();
if (npc) {
if (publicize) {
npc->doSay(text);
} else {
npc->doSayToPlayer(g_game.getPlayerByID(target), text);
}
}
return 0;
}
示例3: luaActionSay
int NpcScriptInterface::luaActionSay(lua_State* L)
{
//selfSay(words[, target])
Npc* npc = getScriptEnv()->getNpc();
if (!npc) {
return 0;
}
const std::string& text = getString(L, 1);
if (lua_gettop(L) >= 2) {
Player* target = getPlayer(L, 2);
if (target) {
npc->doSayToPlayer(target, text);
return 0;
}
}
npc->doSay(text);
return 0;
}
示例4: luaActionSay
int NpcScriptInterface::luaActionSay(lua_State* L)
{
//selfSay(words, <optional> delay)
int32_t parameters = lua_gettop(L);
uint32_t delay = SCHEDULER_MINTICKS;
if (parameters > 1) {
delay = std::max(delay, popNumber(L));
}
std::string msg(popString(L));
ScriptEnviroment* env = getScriptEnv();
Npc* npc = env->getNpc();
if(npc){
npc->doSay(msg, delay);
}
return 0;
}