Soandso2
Well-known member
- Joined
- Mar 13, 2023
- RedCents
- 937¢
Alright, so after having uploaded my bam.mac, people kept telling me to "DO'ET IN Lua INSTEAD, DOOOO EEEEEET, FOOL!"
So I thought I would convert bam.mac to bam.Lua. I read up on Lua a bit, looked at a few examples and I decided to start out small and carefully. But since I am not 100% familiar with the documentation yet, I struggle to find the solution to the first major issue.
(I think) I know what the problem is, just not how to correct it.
[CODE lang="Lua" title="bam.Lua"]mq = require('mq')
print('Running Bam.Lua')
local terminate = false
mq.bind('/bamend', function() terminate = true end)
local function doShortDiscs(discName,targetDist)
local shortDisc = mq.TLO.Spell(discName).RankName
if mq.TLO.Me.CombatAbilityReady(shortDisc) and mq.TLO.Target.Distance() < targetDist then
mq.cmd('/doability '..shortDisc)
print(shortDisc)
mq.delay(3)
end
end
while not terminate do
if mq.TLO.Me.Combat() and mq.TLO.Target.ID() then
doShortDiscs('Vigorous Shuriken',175)
end
end[/CODE]
The error occurs in line 11: mq.cmd('/doability '..shortDisc) and I presume it has to do with the fact that shortDisc in this case contains a space. I also tried to use mq.cmdf('/doability %s',shortDisc) but then I got something along the lines of "you dont seem to have that ability: vigorous" (again, just taking the first word of the string).
I have also seen mq.cmd.doability() ... what is the difference and which way is the prefered way?
EDIT: I just found this in LeRouge lua
start = function() mq.cmdf('/useitem "%s"', mq.TLO.FindItem(name).Name()) end
I guess I just answered my own question. Sorry for taking up your time, folks.
So I thought I would convert bam.mac to bam.Lua. I read up on Lua a bit, looked at a few examples and I decided to start out small and carefully. But since I am not 100% familiar with the documentation yet, I struggle to find the solution to the first major issue.
(I think) I know what the problem is, just not how to correct it.
[CODE lang="Lua" title="bam.Lua"]mq = require('mq')
print('Running Bam.Lua')
local terminate = false
mq.bind('/bamend', function() terminate = true end)
local function doShortDiscs(discName,targetDist)
local shortDisc = mq.TLO.Spell(discName).RankName
if mq.TLO.Me.CombatAbilityReady(shortDisc) and mq.TLO.Target.Distance() < targetDist then
mq.cmd('/doability '..shortDisc)
print(shortDisc)
mq.delay(3)
end
end
while not terminate do
if mq.TLO.Me.Combat() and mq.TLO.Target.ID() then
doShortDiscs('Vigorous Shuriken',175)
end
end[/CODE]
The error occurs in line 11: mq.cmd('/doability '..shortDisc) and I presume it has to do with the fact that shortDisc in this case contains a space. I also tried to use mq.cmdf('/doability %s',shortDisc) but then I got something along the lines of "you dont seem to have that ability: vigorous" (again, just taking the first word of the string).
I have also seen mq.cmd.doability() ... what is the difference and which way is the prefered way?
EDIT: I just found this in LeRouge lua
start = function() mq.cmdf('/useitem "%s"', mq.TLO.FindItem(name).Name()) end
I guess I just answered my own question. Sorry for taking up your time, folks.
Last edited:



