[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Miniwindows
. . -> [Subject]  Hotspot problem - stack overflow
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Hotspot problem - stack overflow

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


Pages: 1 2  

Posted by Mendacitas   (10 posts)  [Biography] 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>
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] 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.
[Go to top] top

Posted by Mendacitas   (10 posts)  [Biography] 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.
[Go to top] top

Posted by Mendacitas   (10 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] top

Posted by Mendacitas   (10 posts)  [Biography] 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
[Go to top] top

Posted by Mendacitas   (10 posts)  [Biography] 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
[Go to top] top

Posted by Worstje   Netherlands  (899 posts)  [Biography] 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.
[Go to top] top

Posted by Twisol   USA  (2,257 posts)  [Biography] 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
[Go to top] top

Posted by Larkin   (278 posts)  [Biography] 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.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] 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
[Go to top] 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.


11,077 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] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]