Jump to content
Sign in to follow this  
adz89

Tray Menu

Recommended Posts

adz89

Right then this is part of my Tribal Wars bot, but its to do with the menu,

I've got this code:

While 1=1
    $msg = TrayGetMsg()
    If $msg = $defensiveitem Then
        IniWrite(@ProgramFilesDir & "\ARSoft\TribalwarsAI\setup.ini", "AI Settings", "stance", "Defensive")
        $stance = "Defensive"
        MsgBox(0, "Success", "Stance changed to "& $stance)
    ElseIf $msg = $balanceditem Then
        IniWrite(@ProgramFilesDir & "\ARSoft\TribalwarsAI\setup.ini", "AI Settings", "stance", "All Rounder")
        $stance = "All Rounder"
        MsgBox(0, "Success", "Stance changed to "& $stance)
    ElseIf $msg = $resourceitem Then
        IniWrite(@ProgramFilesDir & "\ARSoft\TribalwarsAI\setup.ini", "AI Settings", "stance", "Resources")
        $stance = "Resources"
        MsgBox(0, "Success", "Stance changed to "& $stance)
    ElseIf $msg = $showstanceitem Then
        ToolTip("Current Stance is "& $stance)
    ElseIf $msg = $runsetupitem Then
        $msg2 = MsgBox(4, "WARNING", "This will delete the set-up file on your computer, this will allow you to completely re-write all the settings, do you want to continue?")
        If $msg2 = 6 Then
            FileDelete(@ProgramFilesDir & "\ARSoft\TribalwarsAI\setup.ini")
        EndIf
    Else
        runbuildings()
        rununits()
        
    EndIf
WEnd

Which basically keeps my script running, and I thought I'd would stop when I click the icon, and then carry on... But it doesn't always respond to my menu clicks on the icon, and when I manage to get it to respond the program terminates, not what I wanted at all!

Can anyone help me?


Self confessed noob...

Share this post


Link to post
Share on other sites
Valuater

Change it... I always use on-event for my Tray Icon Menu... always!

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites
adz89

Change it... I always use on-event for my Tray Icon Menu... always!

8)

How do you mean?

Would I take it out of my while loop altogether?


Self confessed noob...

Share this post


Link to post
Share on other sites
Valuater

How do you mean?

Would I take it out of my while loop altogether?

More like...

Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)

$defensiveitem = TrayCreateItem("Defensive")
TrayItemSetOnEvent(-1, "_Defensive")

$balanceditem = TrayCreateItem("All Rounders")
TrayItemSetOnEvent(-1, "_Rounders")
TrayCreateItem("")

While 1
    Sleep(100)

    runbuildings() ; place these two functions inside this loop if possible, that way your icon tray will act immediately
    rununits()
WEnd

; ---- Functions -----

Func _Defensive()
    IniWrite(@ProgramFilesDir & "\ARSoft\TribalwarsAI\setup.ini", "AI Settings", "stance", "Defensive")
    $stance = "Defensive"
    MsgBox(0, "Success", "Stance changed to " & $stance)
EndFunc   ;==>_Defensive

Func _Rounders()
    IniWrite(@ProgramFilesDir & "\ARSoft\TribalwarsAI\setup.ini", "AI Settings", "stance", "All Rounder")
    $stance = "All Rounder"
    MsgBox(0, "Success", "Stance changed to " & $stance)
EndFunc   ;==>_Rounders

EDIT "place these two functions inside this loop if possible, that way your icon tray will act immediately"

means.... place the code inside the loop and remove them from "functions" if possible

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.