I'm trying to do what is probably a very simple thing, but I'm JUST starting with scripting my own simple stuff...Alright so I set an alias that when entered would set a variable to 1, and while this variable was set to 1 I am supposed to keep bashing stuff, until it is dead. But when I try to activate it, my mudlet freezes up and I need to close the process, so I'm assuming something went terribly, terribly wrong. Here is what I did.
Alias pattern: ^tab$
bashing = 1
end
if bashing then
if isbalanced then do
send("play minorsecond "..tar)
if haskilled then
bashing = 0
end
end
end
help a newb out ^_^
Comments
Signature!
if not bashing then enableTrigger[[EQ bash]]
echo("Auto bash enabled\n")
bashing = true
send("play minorsecond "..tar) -- makes it so you don't have to input the first attack
else if bashing then disableTrigger[[EQ bash]]
bashing = false
echo("Auto bash disabled")
end
end
And here is the trigger I have for 'EQ bash'
^You have recovered balance on all limbs\.$
isbalanced = true
if bashing and not haskilled
then send("play minorsecond "..tar)
else if haskilled and isbalanced
then send("get "..tar , false)
send("get essence" , false)
send("get gold" , false)
haskilled = false
end
end
Maybe not efficient, but it seems to be working. Any tips on efficiency to maybe make this slightly better?
For the second trigger, you don't have to make it a perl regex; you could have just used an exact match trigger for that line. Also there is no value added in having the "isbalanced = true" line, and then the "and isbalanced" later. If that trigger is firing, you already know that you have balance and don't need a variable to track it.
if not bashing then enableTrigger[[EQ bash right]]
enableTrigger[[EQ bash left]]
cecho("<blue>Auto bash enabled\n")
bashing = true
send("swing "..tar)
send("swing "..tar)
elseif bashing then disableTrigger[[EQ bash right]]
disableTrigger[[EQ bash left]]
bashing = false
cecho("<red>Auto bash disabled\n")
end
end
if bashing
then send("swing "..tar.." left hand")
end
I have one for the right arm set up the same way. I guess my final question is, is there any way to combine the two triggers in a way that it would still recognize that its either my left or my right hand that is balanced, and swing accordingly?
also..keep in mind that this is my first time ever trying to code anything in any language, so dont laugh at me T_T
^You have recovered balance on your (?:left|right) arm\.$
Or use a begin of line substring trigger and stop the line after "your"?