function onStepIn(cid, item, position, fromPosition)
local npcPos = {x= 1014, y= 1029, z= 7, stackpos= 253}
local getPos = getThingFromPos(npcPos)
doCreatureSay(getPos.uid, "Testing 123", 1)
return false
end
Here is some idea of getting a specific NPC from a position to say something.
Now that you know what to do, you can play around with it.
![]()
LUA:function onStepIn(cid, item, position, fromPosition) local npcPos = {x= 1014, y= 1029, z= 7, stackpos= 253} local getPos = getThingFromPos(npcPos) doCreatureSay(getPos.uid, "Testing 123", 1) return false end
[09/08/2012 00:48:57] Lua Script Error: [MoveEvents Interface]
[09/08/2012 00:48:57] data/movements/scripts/npctalk.luanStepIn
[09/08/2012 00:48:57] data/movements/scripts/npctalk.lua:3: attempt to call global 'getThingFromPos' (a nil value)
[09/08/2012 00:48:57] stack traceback:
[09/08/2012 00:48:57] [C]: in function 'getThingFromPos'
[09/08/2012 00:48:57] data/movements/scripts/npctalk.lua:3: in function <data/movements/scripts/npctalk.lua:1>
Second, could you just give me what I put in movements.xml since I suck totally at scripting.
Sick of chewing for you guys.
Which server/version do you use?
getThingfromPos(npcPos)
Yes it's lowercase:
//getThingfromPos(pos)
lua_register(m_luaState, "getThingfromPos", LuaScriptInterface::luaGetThingfromPos);
local config = {
[aid] = {'npc', 'text'},
[aid] = {'npc', 'text'}
}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1555)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 5000)
function onStepIn(cid, item, position, fromPosition)
local current = config[item.actionid]
if current then
local npc = getCreatureByName(current[1])
if not getCreatureCondition(cid, CONDITION_EXHAUST, 1555) and isPlayer(cid) and npc then
doCreatureSay(npc, current[2], TALKTYPE_SAY)
doAddCondition(cid, exhaust)
end
end
return true
end
Here, you can use this to add multiple NPC's without adding a lot of scripts, just mark the ACTION ID of the tiles in the map editor that will set the NPC's off
LUA:local config = { [aid] = {'npc', 'text'}, [aid] = {'npc', 'text'} } local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1555) setConditionParam(exhaust, CONDITION_PARAM_TICKS, 5000) function onStepIn(cid, item, position, fromPosition) local current = config[item.actionid] if current then local npc = getCreatureByName(current[1]) if not getCreatureCondition(cid, CONDITION_EXHAUST, 1555) and isPlayer(cid) and npc then doCreatureSay(npc, current[2], TALKTYPE_SAY) doAddCondition(cid, exhaust) end end return true end
Here, you can use this to add multiple NPC's without adding a lot of scripts, just mark the ACTION ID of the tiles in the map editor that will set the NPC's off
LUA:local config = { [aid] = {'npc', 'text'}, [aid] = {'npc', 'text'} } local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1555) setConditionParam(exhaust, CONDITION_PARAM_TICKS, 5000) function onStepIn(cid, item, position, fromPosition) local current = config[item.actionid] if current then local npc = getCreatureByName(current[1]) if not getCreatureCondition(cid, CONDITION_EXHAUST, 1555) and isPlayer(cid) and npc then doCreatureSay(npc, current[2], TALKTYPE_SAY) doAddCondition(cid, exhaust) end end return true end
[09/08/2012 19:58:56] Lua Script Error: [Test Interface]
[09/08/2012 19:58:56] data/movements/scripts/npctalk.lua
[09/08/2012 19:58:56] data/movements/scripts/npctalk.lua:2: table index is nil
[09/08/2012 19:58:56] stack traceback:
[09/08/2012 19:58:56] [C]: in function '__newindex'
[09/08/2012 19:58:56] data/movements/scripts/npctalk.lua:2: in main chunk
[09/08/2012 19:58:56] Warning: [Event::checkScript] Can not load script. /scripts/npctalk.lua