Jump to content

if/then issue with a Variable.


Recommended Posts

So I have a simple array and function and an ifthen routine.

Dim $var[2] = ['1153', '559']

Trainer($var[0], $var[1], 1)

Func FirstFunc($arm1, $arm2, $Other)

    If $arm2 = 558 or 662 or 766 Then
        MouseClick("Left", 1241, 744, 1, 10)
        TrayTip('What', 'Err Test' & $arm2, 3)
    else
        MouseClick("Left", 1241, 530, 1, 10)
        TrayTip('What', 'NORM', 3)
    EndIf
endfunc

When I run this, my traytip tells me that the value of $arm2 is 559. This is correct, however, ir order for the traytip to even trigger, the value needed to be either 558, 662 or 766. What gives? Why isnt the 'else' values triggering instead?

Edited by Bigglesw0rth
Link to comment
Share on other sites

Global $var[2] = [1153, 558]
FirstFunc($var[0], $var[1], 1)

$var[1] = 662
FirstFunc($var[0], $var[1], 1)

$var[1] = 766
FirstFunc($var[0], $var[1], 1)

$var[1] = 599
FirstFunc($var[0], $var[1], 1)

Func FirstFunc($arm1, $arm2, $Other)
    If ($arm2 = 558) Or ($arm2 = 662) Or ($arm2 = 766) Then
        MouseClick("Left", 1241, 744, 1, 10)
        TrayTip("What", "Err Test" & $arm2, 3, 3)
        Sleep(1000) ; had to do this to make it stick, you may not have to
    Else
        MouseClick("Left", 1241, 530, 1, 10)
        TrayTip("What", "NORM", 3)
        Sleep(1000) ; had to do this to make it stick, you may not have to
    EndIf
EndFunc   ;==>FirstFunc

Edited by LaCastiglione
Link to comment
Share on other sites

Replace the line with:

If $arm2 = 558 or $arm2 = 662 or $arm2 = 766 Then

Your code wasn't enough to play with, so I did my own testing and leaving out the "$arm2 =" messed up the functionality. I am a bit puzzled by the results otherwise. But this should work for you.

#include <ByteMe.au3>

Link to comment
Share on other sites

Is this the game bot again?

Dim $Warrior[2] = ['1153', '559']

Trainer($Warrior[0], $Warrior[1], 1)

Func Trainer($arm1, $arm2, $Citynumber)

    If $arm2 = 558 or 662 or 766 Then
        MouseClick("Left", 1241, 744, 1, 10)
        TrayTip('What', 'Alt Troops' & $arm2, 3)
    else
        MouseClick("Left", 1241, 530, 1, 10)
        TrayTip('What', 'NORM', 3)
    EndIf
endfunc

...

Do not discuss any of the following:

Automating games or game servers. See below for more details.

...

Are you stupid or just ignorant ? Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

Maffe811, I did not catch that this was a thread reopening a closed topic. I looked at Bigglesw0rth's history and I can see why he started this one. It was something that PsaltyDS said:

You could have easily created a demo that didn't use tags like "warrior" and "trainer", but you didn't.

So, from that comment, his logical progression would be to change the code to not include such words.

Anyways, I'm outta here. I got stuff to do...

#include <ByteMe.au3>

Link to comment
Share on other sites

Yup!

Thought i give everyone a headsup.

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

  • Developers

@Bigglesw0rth, lets stop thin now....

@Maffe811, just report it and don't go into a discussion pls, this only leads to escalations we don't need.

thanks

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...