-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminingFunctions.py
193 lines (150 loc) · 3.89 KB
/
miningFunctions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# modules
import pyautogui as auto
import pydirectinput as dx
import numpy as np
from PIL import ImageGrab
import cv2
import time
def autoCraft():
# initialize variables
exitX = 348
exitY = 922
# instruct user
print("Go to crafting table and press e, now wait")
time.sleep(3)
# countdown until start
countDownTimer(5)
# move to craft button
auto.moveTo(352, 437)
auto.click()
# move to scroll area
auto.moveTo(1620, 312)
auto.dragTo(1620, 900, button='left')
# move to warhammer, click
auto.moveTo(1326, 615)
auto.click()
# move to craft button
auto.moveTo(1326, 942)
# auto click
craftClicker(88)
# program done, exit screen
print('Done, exiting')
time.sleep(1)
exitScreen(exitX, exitY)
def autoSell(timer):
# initialize variables
colIndex = rowIndex = 1
xStartPos = 1715
yStartPos = 650
shiftIndex = 125
centerX = 950
centerY = 555
exitX = 1770
exitY = 135
# instruct user if chosen manually
if timer == 5:
print("Press i, now wait")
time.sleep(1)
# countdown until start
countDownTimer(timer)
while rowIndex <= 4:
while colIndex <= 11:
# move to first item in row
auto.moveTo(xStartPos, yStartPos)
auto.click()
# move to sell button
auto.moveRel(5, 150)
auto.click()
# switch item count from 1 to 2
changeToTwo(centerX, centerY)
# shift mouse to next item
xStartPos -= shiftIndex
# increment
colIndex += 1
# reset starting index
xStartPos = 1715
# shift row up 1
yStartPos -= shiftIndex
# reset column counter
colIndex = 1
# increment row counter
rowIndex += 1
# Program done, exit screen
print('Done, Exiting')
time.sleep(1)
exitScreen(exitX, exitY)
def changeToTwo(x, y):
# move to input box
auto.moveTo(x, y)
auto.click(x, y)
# delete 1, replace with 2
auto.press('backspace')
auto.press('2')
# move to sell button
auto.moveTo(x, y + 65)
auto.click()
def chooseMiningJob():
dx.press('f4') # open jobs
auto.moveTo(430, 380) # move to jobs
auto.click()
auto.moveTo(730, 300) # move to citizens
auto.click()
auto.moveTo(730, 375) # move to miner
auto.click()
time.sleep(.5)
auto.moveTo(1180, 880) # confirm
auto.click()
time.sleep(1.5)
dx.press('3') # get pick
auto.click()
def countDownTimer(seconds):
# initialize variables
countDown = seconds
# loop until timer is 1
while countDown >= 1:
# print countdown
print('\r' + str(countDown), end='')
# decrement
countDown -= 1
# sleep for timer effect
time.sleep(1)
# tell user program has started
print('\rStart')
def craftClicker(clicks):
# initialize variables
index = 0
while index < clicks:
# click
auto.click()
time.sleep(.15)
# increment
index += 1
# print click number
print('\r' + str(index), end='')
# print endline
print('\n', end='')
def exitAfk():
# exit afk mode
dx.press('y')
auto.press('/')
auto.press('a')
auto.press('f')
auto.press('k')
auto.press('enter')
time.sleep(2)
def exitScreen(x, y):
# move to exit button, click
auto.moveTo(x, y)
auto.click()
def idleUntilAfk():
# initialize time
t = time.localtime()
current_time = time.strftime("%H:%M:%S", t)
# check if current time is server restart time
while current_time != "10:00:00":
# update time
t = time.localtime()
current_time = time.strftime("%H:%M:%S", t)
print('\r' + "Time: " + str(current_time), end='')
continue
print("\nexit at " + current_time)