I will be posting snips of common things that happened in MQ but do it in Lua. I will also take the Sic approach, if it can be done better, I either didn't know how, or didn't want to at the time. However, I am not opposed to better, faster, cheaper methods..
Also, if this is not the appropriate place or can be added to another list/forum please advise..
So without further Adieu ..
Behold -- Walk To NPC in Lua
local WalkToNPC = function(npcName)
--convert userdata to number
npc_up = tonumber(tostring(mq.TLO.SpawnCount(npcName)))
if (npc_up == 0) then
mq.cmd.echo("\ao[\atTCS\ao]: \ag"..npcName.. " not up, waiting 10s to try to walk to it")
--not true.. delay is bogus..or not in correct zone.
mq.delay(100)
return false
else
mq.cmd('/tar',npcName)
mq.delay(100)
mq.cmd('/nav spawn npc '..npcName.. '|dist=14 los=on log=off')
--how do we know we mades it there precious.. nasty luases
--if (Navigation.Active - dunno how to access this
--user_moving = mq.TLO.Me.Moving
mq.delay(100)
mvv= tostring(mq.TLO.Me.Moving)
-- If we are moving do not end execution
while mvv == "TRUE" do
mq.delay(10)
mvv= tostring(mq.TLO.Me.Moving)
end
end
end
Invoke by...
WalkToNPC("Chef Denrun")
and I still don't know how to put quotes around a variable to be passed to a function. I stink
Also, if this is not the appropriate place or can be added to another list/forum please advise..
So without further Adieu ..
Behold -- Walk To NPC in Lua
local WalkToNPC = function(npcName)
--convert userdata to number
npc_up = tonumber(tostring(mq.TLO.SpawnCount(npcName)))
if (npc_up == 0) then
mq.cmd.echo("\ao[\atTCS\ao]: \ag"..npcName.. " not up, waiting 10s to try to walk to it")
--not true.. delay is bogus..or not in correct zone.
mq.delay(100)
return false
else
mq.cmd('/tar',npcName)
mq.delay(100)
mq.cmd('/nav spawn npc '..npcName.. '|dist=14 los=on log=off')
--how do we know we mades it there precious.. nasty luases
--if (Navigation.Active - dunno how to access this
--user_moving = mq.TLO.Me.Moving
mq.delay(100)
mvv= tostring(mq.TLO.Me.Moving)
-- If we are moving do not end execution
while mvv == "TRUE" do
mq.delay(10)
mvv= tostring(mq.TLO.Me.Moving)
end
end
end
Invoke by...
WalkToNPC("Chef Denrun")
and I still don't know how to put quotes around a variable to be passed to a function. I stink
Last edited:



