Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Miniwindows ➜ Hotspot problem - stack overflow

Hotspot problem - stack overflow

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Mendacitas   (10 posts)  Bio
Date Thu 05 Aug 2010 02:34 PM (UTC)
Message

atkwin = "knightattacks"
dslcolor = "silver"

function knightAI:attackwindow()
WindowCreate (atkwin, 640, 325, 175, 200, 6, 2, ColourNameToRGB("black"))
WindowShow (atkwin, true)
WindowFont (atkwin, "a","Trebuchet MS", 12, true, false, false, false)
WindowText (atkwin, "f","Attacks:", 4, 0, 0, 0, ColourNameToRGB ("lightgreen"), false)
WindowText (atkwin, "a","DSL", 4, 13, 0, 0, ColourNameToRGB (dslcolor), false)
WindowText (atkwin, "a","SSL", 6.5, 30, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","IMPALE", 4, 47, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","HELLSIGHT/ARC", 40, 13, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","DISEMBOWEL", 40, 30, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "f", "Spells:", 5, 67, 0, 0, ColourNameToRGB ("lightgreen"), false)
WindowText (atkwin, "a","ENGAGE", 4, 80, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","PIETY", 75, 80, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","HEAL", 4, 97, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","REVIT", 55, 97, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","DEMONS", 4, 114, 0, 0, ColourNameToRGB ("silver"), false)
WindowAddHotspot(atkwin, "dsl", 3, 12, 25, 12, "", "", "", "", knightAI:modatk("dsl"), "", 1, 0)

end

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

here's the alias:


<aliases>
<alias
match="^testme1$"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>knightAI:attackwindow()</send>
</alias>
</aliases>
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #1 on Thu 05 Aug 2010 02:45 PM (UTC)
Message
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.
Top

Posted by Mendacitas   (10 posts)  Bio
Date Reply #2 on Thu 05 Aug 2010 02:58 PM (UTC)
Message
I removed the thing causing the loop, now I have this:

atkwin = "knightattacks"
dslcolor = "silver"

function knightAI:attackwindow()
WindowCreate (atkwin, 640, 325, 175, 200, 6, 2, ColourNameToRGB("black"))
WindowShow (atkwin, true)
WindowFont (atkwin, "a","Trebuchet MS", 12, true, false, false, false)
WindowText (atkwin, "f","Attacks:", 4, 0, 0, 0, ColourNameToRGB ("lightgreen"), false)
WindowText (atkwin, "a","DSL", 4, 13, 0, 0, ColourNameToRGB (dslcolor), false)
WindowText (atkwin, "a","SSL", 6.5, 30, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","IMPALE", 4, 47, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","HELLSIGHT/ARC", 40, 13, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","DISEMBOWEL", 40, 30, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "f", "Spells:", 5, 67, 0, 0, ColourNameToRGB ("lightgreen"), false)
WindowText (atkwin, "a","ENGAGE", 4, 80, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","PIETY", 75, 80, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","HEAL", 4, 97, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","REVIT", 55, 97, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","DEMONS", 4, 114, 0, 0, ColourNameToRGB ("silver"), false)
WindowAddHotspot(atkwin, "dsl", 3, 12, 25, 12, "", "", "", "", knightAI:modatk(), "", 1, 0)

end

function knightAI:modatk()
atk = "dsl"
dslcolor = "red"
end

when I tried that, I got an error saying 'bad argument #11, string required', so I changed it to


WindowAddHotspot(atkwin, "dsl", 3, 12, 25, 12, "", "", "", "", "knightAI:modatk()", "", 1, 0)

But nothing happens when I redraw the window with my 'testme1' alias posted above after clicking in the hotspot, the text should be turning red.
Top

Posted by Mendacitas   (10 posts)  Bio
Date Reply #3 on Thu 05 Aug 2010 03:33 PM (UTC)
Message
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.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #4 on Thu 05 Aug 2010 08:25 PM (UTC)

Amended on Thu 05 Aug 2010 09:46 PM (UTC) by Nick Gammon

Message
Mendacitas said:

WindowAddHotspot(atkwin, "dsl", 3, 12, 25, 12, "", "", "", "", "knightAI:modatk()", "", 1, 0)


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).

[EDIT] However, see next post.

Before when you had:


WindowAddHotspot(atkwin, "dsl", 3, 12, 25, 12, "", "", "", "", knightAI:modatk(), "", 1, 0)


That was *calling* the function. Nor will this work:



WindowAddHotspot(atkwin, "dsl", 3, 12, 25, 12, "", "", "", "", knightAI:modatk, "", 1, 0)


That is the function but not the name of a function.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #5 on Thu 05 Aug 2010 08:28 PM (UTC)
Message
In fact I would change the ":" to ".".

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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #6 on Thu 05 Aug 2010 09:12 PM (UTC)
Message
Nick Gammon said:


WindowAddHotspot(atkwin, "dsl", 3, 12, 25, 12, "", "", "", "", knightAI:modatk, "", 1, 0)

That is the function but not the name of a function.

It's in fact invalid, the : syntax can only be used when calling a function.

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #7 on Thu 05 Aug 2010 09:44 PM (UTC)
Message
I've amended the documentation to make it clearer you pass the name of a function, not a function.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #8 on Thu 05 Aug 2010 09:51 PM (UTC)
Message
Just to clarify the difference:


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)


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Mendacitas   (10 posts)  Bio
Date Reply #9 on Fri 06 Aug 2010 11:56 AM (UTC)
Message
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.


atkwin = "knightattacks"
dslcolor = "silver"

function knightAI:attackwindow()
WindowCreate (atkwin, 640, 325, 175, 200, 6, 2, ColourNameToRGB("black"))
WindowShow (atkwin, true)
WindowFont (atkwin, "a","Trebuchet MS", 12, true, false, false, false)
WindowFont (atkwin, "f","Trebuchet MS", 10, true, false, false, false)
WindowText (atkwin, "f","Attacks:", 4, 0, 0, 0, ColourNameToRGB ("lightgreen"), false)
WindowText (atkwin, "a","DSL", 4, 13, 0, 0, ColourNameToRGB (dslcolor), false)
WindowText (atkwin, "a","SSL", 6.5, 30, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","IMPALE", 4, 47, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","HELLSIGHT/ARC", 40, 13, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","DISEMBOWEL", 40, 30, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "f", "Spells:", 5, 67, 0, 0, ColourNameToRGB ("lightgreen"), false)
WindowText (atkwin, "a","ENGAGE", 4, 80, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","PIETY", 75, 80, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","HEAL", 4, 97, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","REVIT", 55, 97, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","DEMONS", 4, 114, 0, 0, ColourNameToRGB ("silver"), false)
WindowRectOp(atkwin, 1, 3, 15, 32, 32, ColourNameToRGB("blue"))
WindowAddHotspot(atkwin, "dsl", 3, 15, 32, 32, "", "", "", "", "knightAI.modatk", "", 1, 0)

end



function knightAI:modatk()
Note("hotspot working")
end
Top

Posted by Mendacitas   (10 posts)  Bio
Date Reply #10 on Fri 06 Aug 2010 01:29 PM (UTC)
Message

atkwin = "knightattacks"
dslcolor = "silver"

function knightAI:attackwindow()
WindowCreate (atkwin, 640, 325, 175, 200, 6, 2, ColourNameToRGB("black"))
WindowShow (atkwin, true)
WindowFont (atkwin, "a","Trebuchet MS", 12, true, false, false, false)
WindowFont (atkwin, "f","Trebuchet MS", 10, true, false, false, false)
WindowText (atkwin, "f","Attacks:", 4, 0, 0, 0, ColourNameToRGB ("lightgreen"), false)
WindowText (atkwin, "a","DSL", 4, 13, 0, 0, ColourNameToRGB (dslcolor), false)
WindowText (atkwin, "a","SSL", 6.5, 30, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","IMPALE", 4, 47, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","HELLSIGHT/ARC", 40, 13, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","DISEMBOWEL", 40, 30, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "f", "Spells:", 5, 67, 0, 0, ColourNameToRGB ("lightgreen"), false)
WindowText (atkwin, "a","ENGAGE", 4, 80, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","PIETY", 75, 80, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","HEAL", 4, 97, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","REVIT", 55, 97, 0, 0, ColourNameToRGB ("silver"), false)
WindowText (atkwin, "a","DEMONS", 4, 114, 0, 0, ColourNameToRGB ("silver"), false)
WindowRectOp(atkwin, 1, 3, 15, 32, 32, ColourNameToRGB("blue"))
WindowAddHotspot(atkwin, "dsl", 3, 15, 32, 32, "", "", "", "", "knightAI.modatk", "", 1, 0)

end



function knightAI:modatk()
Note("hotspot working")
end
Top

Posted by Worstje   Netherlands  (899 posts)  Bio
Date Reply #11 on Fri 06 Aug 2010 01:52 PM (UTC)
Message
Been talking to Mendacitas on AIM, and the issue was that he wasn't doing it in a plugin, getting 30035 as the WindowAddHotspot error code.
Top

Posted by Twisol   USA  (2,257 posts)  Bio
Date Reply #12 on Fri 06 Aug 2010 05:13 PM (UTC)
Message
Worstje said:

Been talking to Mendacitas on AIM, and the issue was that he wasn't doing it in a plugin, getting 30035 as the WindowAddHotspot error code.


Wasn't that changed? I swear that was changed. =/

'Soludra' on Achaea

Blog: http://jonathan.com/
GitHub: http://github.com/Twisol
Top

Posted by Larkin   (278 posts)  Bio
Date Reply #13 on Fri 06 Aug 2010 08:32 PM (UTC)
Message
Yeah, I was 99% sure that we could do hotspots without plugins for the last few versions, but I haven't tried them yet myself.
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #14 on Fri 06 Aug 2010 09:07 PM (UTC)
Message
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.

    For example:

    
    check (  WindowRectOp(atkwin, 1, 3, 15, 32, 32, ColourNameToRGB("blue")) )
    


    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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


58,944 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.