Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
4.9 kB
4
Indexable
import pydirectinput as pydirinpt

import pyautogui as pyauto

import time




def mouse_reset():
    time.sleep(1)
    pydirinpt.moveRel(0,500)
    pydirinpt.moveRel(1000,0)
    pydirinpt.click()
    pydirinpt.moveTo(960,540,1000)
    time.sleep(1)



def train_move(distance, train_orientation = "Regular"):
    SMALL_TRAIN_MOVE_RATIO = 2.5
    if train_orientation != "Regular":
        SMALL_TRAIN_MOVE_RATIO = 2
    if distance > 0:
        pydirinpt.keyDown('w')
        time.sleep(distance/SMALL_TRAIN_MOVE_RATIO)
        pydirinpt.keyUp('w')
        time.sleep(0.2)
    elif distance < 0: 
        pydirinpt.keyDown('s')
        time.sleep(abs(distance/SMALL_TRAIN_MOVE_RATIO))
        pydirinpt.keyUp('s')
        time.sleep(0.2)

def train_emabark():
    pydirinpt.keyDown('q')
    time.sleep(0.1)
    pydirinpt.keyUp('q')

def close_menu():
    pydirinpt.press('e',duration=0.2)

def open_context_menu(position = 0):
    time.sleep(0.2)
    pydirinpt.keyDown('shift')
    pydirinpt.keyDown('e')
    time.sleep(0.2)
    pydirinpt.keyUp('shift')
    pydirinpt.keyUp('e')
    pydirinpt.moveTo(1060,528-(position*21),duration=0.5)
    time.sleep(0.2)
    pydirinpt.click()

def fast_pull( qty = 1, building = "STAT_HARV"):
    if building == "STAT_HARV":
        pydirinpt.click(1190,220,qty,0.5)
    if building == "MAT_FAC":
        pydirinpt.click(1183,225,qty,0.5)

def fast_pull_all( qty = 1, building = "STAT_HARV"):
    if building == "STAT_HARV":
        print("This has not yet been implimented")
        pydirinpt.click(1190,220,qty,0.5)

    if building == "MAT_FAC":
        select_cart(0)
        pydirinpt.click(1183,225,qty,0.5)
        select_cart(1)
        pydirinpt.click(1183,225,qty,0.5)
        select_cart(2)
        pydirinpt.click(1183,225,qty,0.5)
        select_cart(3)
        pydirinpt.click(1183,225,qty,0.5)


def select_cart( cart = 0):
    pydirinpt.click(395+(26*cart),450,duration=0.5)

def submit_cart(cart = 0):
    select_cart(cart)
    pydirinpt.rightClick(395,500,duration=0.2)
    pydirinpt.moveRel(10,95,duration=0.2)
    pydirinpt.click()

def Shuffle_INV(Source_menu_pos = 0, Destination_menu_pos = 0):
    open_context_menu(Source_menu_pos)
    fast_pull_all(26,"MAT_FAC")
    close_menu()

    open_context_menu(Destination_menu_pos)
    submit_all()
    close_menu()

def submit_all():
    for x in range (4):
        submit_cart(x)


def Error_Detect_Menuopen():
    error = 0

    debugimg = pyauto.screenshot()
    pix = pyauto.screenshot().getpixel((1830,87)) 
    white = (255,255,255)

    if pix != white:
        error = 1
    
    return error

def Macro_fastpull_mines(inv_location_1 = 0,inv_location_2= 1,inv_location_3 = 2):

    open_context_menu(inv_location_1)
    select_cart(0)
    fast_pull(26)
    close_menu()

    open_context_menu(inv_location_2)
    select_cart(1)
    fast_pull(26)
    close_menu()


    open_context_menu(inv_location_3)
    select_cart(2)
    fast_pull(26)
    close_menu()

def Macro_submit_matfac(contextmenu = [0]):
        
        for location in contextmenu:
            open_context_menu(location)
            submit_all()
            close_menu()
        
        


def Example():
    #train_move(24)
    #time.sleep(7)

    time.sleep(2)
    open_context_menu(3)
    select_cart(0)
    fast_pull(28)
    close_menu()

    open_context_menu(4)
    select_cart(1)
    fast_pull(28)
    close_menu()

    open_context_menu(5)
    select_cart(2)
    fast_pull(28)
    close_menu()

    open_context_menu(0)
    submit_all()
    close_menu()

    open_context_menu(1)
    submit_all()
    close_menu()

    open_context_menu(2)
    submit_all()
    close_menu()




def Stumble():
    print("Field harvest loop start")

    train_move(-10)
    Macro_fastpull_mines(0,1,2)

    
    train_move(-40)
    time.sleep(2)


    Macro_submit_matfac(([0,1,2,3]))

    if Error_Detect_Menuopen():
        print("Exiting, menu error")
    
    train_move(45)
    time.sleep(2)

def Sweetheart():
    print("Field 2 harvest loop start")

    Macro_fastpull_mines(0,1,2)

    
    train_move(-38)
    time.sleep(2)


    Macro_submit_matfac(([0,1,2,3,4,5,6,7,8]))

    if Error_Detect_Menuopen():
        print("Exiting, menu error")
    
    train_move(45)
    time.sleep(2)

def Sweethearth_shuffle():
    #Fucntions required
    #check scrap remaining in iventory
    #check scrap in small train
    #exit conditions
    #checking nodes remaining at field
    #anti afk
    

    print("Placeholder)")

def Sweethearth_loadscrap():
    print("placeholder")



def test1():
    print(Error_Detect_Menuopen())




time.sleep(10)
Sweetheart()
Leave a Comment