function knightAI:modatk(newhit)
if (newhit == "dsl") then
atk = "dsl"
dslcolor = "red"
end
knightAI:attackwindow()
end
I'm working on an automated offense for my Paladin in Aetolia, I want to be able to click on "DSL" in the window defined above, have it change my variable which sets which attack I use to "dsl" and change the colour of the text to red. When I call the function knightAI:attackwindow() with an alias I've created to test however, MUSHClient lags for like 30s and then outputs the following error:
Run-time error
World: AMTS
Immediate execution
.\knightAI.lua:231: stack overflow
stack traceback:
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
...
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
.\knightAI.lua:231: in function 'modatk'
.\knightAI.lua:222: in function 'attackwindow'
[string "Alias: "]:1: in main chunk
Your modatk function calls attackwindow and attackwindow calls modatk when adding the hotspot, thus the infinite loop causing the stack overflow. What you probably want is to wrap the hotspot's modatk call in an anonymous function or alias.
Just realised I was running v3.77 ha. Update to the latest version. So now I'm seeing the text "DSL" change to red when I redraw the window, but without clicking in the hotspot.
You are supposed to pass the name of a function. "knightAI:modatk()" is not the name of a function (it has brackets). Try "knightAI:modatk" (including the quotes).
MUSHclient looks up the function name in the environment table, and finds nested functions at the periods. The ":" notation is for a slightly different case (where you want the table to be passed as the self parameter), but this won't work.
print ("math.abs") --> "math.abs" (the name of the function)
print (math.abs) --> function: 01FDC8C8 (the function itself)
print (math.abs (-1)) --> 1 (the result of calling the function)
I changed the hotspot syntax to pass the name of the function, and simplified the function so I could test only the hotspot. Still when I click on the hotspot nothing happens. I wondered if I'd placed the hotspot improperly so I made a rectangle with the same dimensions in the window. Found that I'd made a tiny line for a hotspot. So I worked out the dimensions I wanted with the rectangle, then rewrote the hotspot to fit it. Still, nothing happening when I click inside the rectangle/hotspot.
Depends which version he is using I guess. That functionality was added in version 4.46, the "official" version of MUSHclient on the Downloads page is 4.43.
Two things would help here:
If you are having problems with stuff like miniwindows not behaving as you think they should, add "check ( ... )" around function calls.
That at least confirms the window exists, the arguments are in range, etc.
Advise which version of MUSHclient you are using
He still would have got errors or mis-behaviour about things like passing a function rather than a function name, so upgrading to the latest version is not the only issue.
On the Downloads page just in front of the link to download the file is this announcement:
Want the very latest version?
The version shown on this page is considered the latest stable version. That is, it has been released for a while with no major bugs reported. However often more recent versions are available on the MUSHclient Announcements part of the Forum. Follow that link to see if there is a more recent version announced. Look for a thread with a heading like "Version 4.xx released".
Ah, I see. It's not very obvious :( I've had a lot of people not know that there's a newer version. Maybe putting <a href="http://www.gammon.com.au/forum/?id=10458">(Beta: 4.55)</a> in the heading in both places would make it more obvious.
Very few of the usual users I see visit the forums, so the forums notice misses a lot of people too.
[EDIT] An email newsletter every time a version is released sure would be nice, IMO. Just a thought :D
Apart from all the other issues I mentioned, like giving the function name, in quotes, without the brackets, and without the ":" symbol, I would upgrade: