-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpumpkin.py
More file actions
74 lines (53 loc) · 1.71 KB
/
pumpkin.py
File metadata and controls
74 lines (53 loc) · 1.71 KB
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
import mover
import misc
import planter
def autoFarm():
if( num_unlocked(Unlocks.Pumpkins) == 0):
return False
if( planter.canAffordEntity(Entities.Pumpkin, misc.getEntityMaxCount()) == False):
return False
if( mover.usedWorldSize != get_world_size() ):
mover.init()
runState = 0
moveForward = True
irrigateLevel = 0
if( num_unlocked(Unlocks.Watering) > 0 ):
irrigateLevel = planter.getIrrigateLevel( misc.getEntityMaxCount() )
mover.moveToPos( mover.getZigZagStartPos() )
while( runState < 4 ):
moveToggled = True
while( moveToggled == True ):
if(runState == 0): #plant pumpkins
entityType = get_entity_type()
if( entityType != Entities.Pumpkin and entityType != None ):
harvest()
if( get_ground_type() != Grounds.Soil):
till()
if( entityType != Entities.Pumpkin):
if( planter.canAffordEntity(Entities.Pumpkin, 1) == False ):
return False
plant(Entities.Pumpkin)
while( irrigateLevel > 0 and get_water() < irrigateLevel and num_items(Items.Water) > 0 ):
use_item(Items.Water)
elif(runState == 1 or runState == 2):
if( get_entity_type() != Entities.Pumpkin ):
plant(Entities.Pumpkin)
runState = 0 #plant pumpkins
elif(runState == 3):
if( can_harvest()):
harvest()
pos = (get_pos_x(), get_pos_y(), moveForward)
moveDirection = mover.zigZagDict[pos]
if( moveDirection == None ):
moveToggled = False
moveForward = not moveForward
if( moveToggled == True ):
move(moveDirection)
#reached end
if(runState == 0): #plant pumpkins
runState = runState+1
elif( runState == 1 or runState == 2 ): #count pumpkins
runState = runState + 1
elif(runState == 3):
runState = 4
return True