Sign in to follow this  
Followers 0
hhh_troll

Logic Help

10 posts in this topic

I am an amateur and need some help formulating the logic.

I need to figure out a more efficient code other than a lengthy nested if then statement

Slot1           If slot 1 to slot 4 is "A" then press "B"
Slot2           If not then remove slot 1 and check if slot 2 to 4 is "A" then press "B"
Slot3           If not then remove slot 2 and check if slot 3 to 4 is "A" then press "B"
Slot4           If not then remove slot 3 and check if slot 4 is "A" then press "B"
                   then return Slot 3 and check if "A" then press "B"
                   then return Slot 2 and check if "A" then press "B"
                   then return Slot 1 and check if "A" then press "B"

Example is 

Slot 1 to Slot 4 is not "A"
remove Slot 1 is still not "A"
remove Slot 2 is "A"
Press B
Return Slot 2 
Check again if slot 2 to 4 is "A" and so forth 

Sorry for the confusing format but any help would be appreciated.

 

Share this post


Link to post
Share on other sites



BUTTON press turns SLOT value to 0

SLOT1    SLOT2    SLOT3    SLOT4        TOTAL    BUTTON        
4             3            2             1                10            
IS "total" <= 5                                
YES    press button and return SLOT1 if missing else return SLOT2 if missing else return SLOT3 if missing                            
No    Remove SLOT1 if SLOT1 is present else remove SLOT2 if SLOT2 is present else remove SLOT3 if SLOT3 is present                            

    SLOT2    SLOT3    SLOT4        TOTAL    BUTTON        
    3            2             1                 6            
IS "total" <= 5                                
YES    press button and return SLOT1 if missing else return SLOT2 if missing else return SLOT3 if missing                            
No    Remove SLOT1 if SLOT1 is present else remove SLOT2 if SLOT2 is present else remove SLOT3 if SLOT3 is present                            

        SLOT3    SLOT4        TOTAL    BUTTON        
        2             1                3            
IS "total" <= 5                                
YES    press button and return SLOT1 if missing else return SLOT2 if missing else return SLOT3 if missing                            
No    Remove SLOT1 if SLOT1 is present else remove SLOT2 if SLOT2 is present else remove SLOT3 if SLOT3 is present                            

    SLOT2    SLOT3    SLOT4        TOTAL    BUTTON        
    3             0            0                 3            
IS "total" <= 5                                
YES    press button and return SLOT1 if missing else return SLOT2 if missing else return SLOT3 if missing                            
No    Remove SLOT1 if SLOT1 is present else remove SLOT2 if SLOT2 is present else remove SLOT3 if SLOT3 is present                            

SLOT1    SLOT2    SLOT3    SLOT4        TOTAL    BUTTON        
4             0            0             0                 4            
IS "total" <= 5                                
YES    press button and return SLOT1 if missing else return SLOT2 if missing else return SLOT3 if missing                            
No    Remove SLOT1 if SLOT1 is present else remove SLOT2 if SLOT2 is present else remove SLOT3 if SLOT3 is present                            

SLOT1    SLOT2    SLOT3    SLOT4        TOTAL    BUTTON        
0             0            0             0                 0            
 

Share this post


Link to post
Share on other sites

I think what you are looking for is a switch, look it up in the help file.

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

"Return SLOT1 if missing"... :huh2: :think:

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

There are 4 slots with variables

There is a Total that displays the total of the 4 variables

There is a button that can be pressed to set the variables to 0 

I need to press the button when the total sums to 5 or less
I can remove the variable in a slot to reduce the total sum but want to put it back after the button is pressed. 

1,2,3,4 as values is a sum of 10 so if I remove the variables one at a time I will end up with SLOT 4 with variable value 4 before I press the button
So when the button is pressed the variable in slot 4 becomes 0 and I want to return the variables removed earlier so it will look like 1,2,3,0 sum of 7

Then it will cycle and remove variables till it is 5 or less in this case it will remove SLOT 1 and 2 and be left with 3,0 and the button will be pressed again
so upon returning the other variables it will be 1,2,0,0 which will be sum 3 and the button will be pressed again to have 0,0,0,0

Share this post


Link to post
Share on other sites

Sounds a whole lot like a slot machine game. Am I close?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Close enough :) I am trying to automate a game. I have been practicing with the simpler mouse clicks and delays. I want to learn and level up to the more complicated stuff. I have been able to apply a few other scripts like Lasker's image search.

Share this post


Link to post
Share on other sites

reported


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

@hhh_troll you seem not to have bothered to read the forum rules. Please do so now, especially the part about game automation, and you will see why this thread is locked.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0