Example #1
0
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;
}
Example #2
0
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;
}
Example #3
0
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;
}
Example #4
0
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;
}