-
Notifications
You must be signed in to change notification settings - Fork 1
/
tanah1.gd
327 lines (289 loc) · 9.69 KB
/
tanah1.gd
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
extends Button
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var status = "Tanah"
var animation_jagung
var siraman = 0
var siram = true
var air
var sakit = false
var jumSakit = 0
var pupuk = true
# Called when the node enters the scene tree for the first time.
func _ready():
animation_jagung = get_child(0)
air = 100.0
status = "Tanah"
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if air < 0:
air = 0
if air == 0:
status = "Tanah"
change_status(status)
siraman = 0
air = 100
sakit = false
get_node("HamaTimer").stop()
get_node("AirTimer").stop()
if air <= 75 && air >= 65:
if status == "Jagung Kecil Normal NPu":
status = "Jagung Kecil Kering NW"
if status == "Jagung Sedang Normal NPu":
status = "Jagung Sedang Kering NW"
siram = true
change_status(status)
elif air <= 55 && air >= 45:
if status == "Jagung Sedang Kering NPu":
status = "Jagung Sedang Layu NW"
siram = true
change_status(status)
elif air <= 35 && air >= 25:
if status == "Jagung Sedang Layu NPu":
status = "Tanah"
siraman = 0
air = 100
sakit = false
get_node("HamaTimer").stop()
get_node("AirTimer").stop()
change_status(status)
if sakit == true:
if status == "Jagung Kecil Normal" || status == "Jagung Kecil Normal Basah" || status == "Jagung Kecil Normal NW":
status = "Jagung Kecil Normal NPe"
if status == "Jagung Sedang Normal" || status == "Jagung Sedang Normal Basah" || status == "Jagung Sedang Normal NW":
status = "Jagung Sedang Normal NPe"
if status == "Jagung Kecil Kering" || status == "Jagung Kecil Kering Basah" || status == "Jagung Kecil Kering NW":
status = "Jagung Kecil Kering NPe"
if status == "Jagung Sedang Kering" || status == "Jagung Sedang Kering Basah" || status == "Jagung Sedang Kering NW":
status = "Jagung Sedang Kering NPe"
if status == "Jagung Kecil Layu" || status == "Jagung Kecil Layu Basah" || status == "Jagung Kecil Layu NW":
status = "Jagung Kecil Layu NPe"
if status == "Jagung Sedang Layu" || status == "Jagung Sedang Layu Basah" || status == "Jagung Sedang Layu NW":
status = "Jagung Sedang Layu NPe"
change_status(status)
if air <= 30:
if status == "Jagung Kecil Kering NW":
status = "Jagung Kecil Layu NW"
change_status(status)
elif status == "Jagung Sedang Kering NW":
status = "Jagung Sedang Layu NW"
change_status(status)
elif status == "Jagung Kecil Kering NPe":
status = "Jagung Kecil Layu NPe"
change_status(status)
elif status == "Jagung Sedang Kering NPe":
status = "Jagung Sedang Layu NPe"
change_status(status)
elif air <= 50:
if status == "Jagung Kecil Normal NW":
status = "Jagung Kecil Kering NW"
change_status(status)
elif status == "Jagung Sedang Normal NW":
status = "Jagung Sedang Kering NW"
change_status(status)
elif status == "Jagung Sedang Normal NPe":
status = "Jagung Sedang Kering NPe"
change_status(status)
elif status == "Jagung Kecil Normal NPe":
status = "Jagung Kecil Kering NPe"
change_status(status)
if siraman == 2:
status = "Jagung Kecil Normal NPu"
pupuk = true
change_status(status)
siram = false
siraman = 3
elif siraman == 5:
if status == "Jagung Kecil Normal Basah":
status = "Jagung Sedang Normal NPu"
if status == "Jagung Kecil Kering Basah":
status = "Jagung Sedang Kering NPu"
if status == "Jagung Kecil Layu Basah":
status = "Jagung Sedang Layu NPu"
change_status(status)
pupuk = true
siram = false
siraman = 6
elif siraman == 8:
if status == "Jagung Sedang Normal Basah":
status = "Jagung Besar Normal"
if status == "Jagung Sedang Kering Basah":
status = "Jagung Besar Kering"
if status == "Jagung Sedang Layu Basah":
status = "Jagung Besar Layu"
change_status(status)
siraman = 0
get_node("AirTimer").stop()
get_node("AirBar").value = air
if air == 70 && (status == "Jagung Kecil Normal" || status == "Jagung Kecil Normal Basah" || status == "Jagung Sedang Normal" || status == "Jagung Sedang Normal Basah" || status == "Benih" || status == "Benih Basah"):
get_node("TumbuhTimer").start(0)
if air == 50 && (status == "Jagung Kecil Kering" || status == "Jagung Kecil Kering Basah" || status == "Jagung Sedang Kering" || status == "Jagung Sedang Kering Basah"):
get_node("TumbuhTimer").start(0)
if air == 30 && (status == "Jagung Kecil Layu" || status == "Jagung Kecil Layu Basah" || status == "Jagung Sedang Layu" || status == "Jagung Sedang Layu Basah"):
get_node("TumbuhTimer").start(0)
pass
func _on_tanah1_pressed():
if status == "Tanah":
if GlobalVar.benih == true:
GlobalVar.jumBenih -= 1
get_node("AirTimer").start(1)
status = "Benih"
change_status(status)
siram = false
if status == "Benih":
if GlobalVar.siraman == true && siram == true:
status = "Benih Basah"
tumbuh(status)
elif status == "Benih NW":
if GlobalVar.siraman == true && siram == true:
status = "Benih Basah"
tumbuh(status)
if sakit == true && GlobalVar.pestisida == true:
sakit = false
GlobalVar.jumPestisida -=1
if status == "Jagung Kecil Normal NPe":
status = "Jagung Kecil Normal"
elif status == "Jagung Sedang Normal NPe":
status = "Jagung Sedang Normal"
elif status == "Jagung Kecil Kering NPe":
status = "Jagung Kecil Kering"
elif status == "Jagung Sedang Kering NPe":
status = "Jagung Sedang Kering"
elif status == "Jagung Kecil Layu NPe":
status = "Jagung Kecil Layu"
elif status == "Jagung Sedang Layu NPe":
status = "Jagung Sedang Layu"
get_node("TumbuhTimer").start(0)
change_status(status)
if pupuk == true && GlobalVar.pupuk == true:
pupuk = false
GlobalVar.jumPupuk -=1
if status == "Jagung Kecil Normal NPu":
status = "Jagung Kecil Normal"
elif status == "Jagung Sedang Normal NPu":
status = "Jagung Sedang Normal"
elif status == "Jagung Sedang Kering NPu":
status = "Jagung Sedang Kering"
elif status == "Jagung Sedang Layu NPu":
status = "Jagung Sedang Layu"
change_status(status)
if status == "Jagung Kecil Normal":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Kecil Normal Basah"
tumbuh(status)
elif status == "Jagung Kecil Normal NW":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Kecil Normal Basah"
tumbuh(status)
if status == "Jagung Kecil Kering":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Kecil Kering Basah"
tumbuh(status)
elif status == "Jagung Kecil Kering NW":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Kecil Kering Basah"
tumbuh(status)
if status == "Jagung Kecil Layu":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Kecil Layu Basah"
tumbuh(status)
elif status == "Jagung Kecil Layu NW":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Kecil Layu Basah"
tumbuh(status)
if status == "Jagung Sedang Normal":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Sedang Normal Basah"
tumbuh(status)
elif status == "Jagung Sedang Normal NW":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Sedang Normal Basah"
tumbuh(status)
if status == "Jagung Sedang Kering":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Sedang Kering Basah"
tumbuh(status)
elif status == "Jagung Sedang Kering NW":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Sedang Kering Basah"
tumbuh(status)
if status == "Jagung Sedang Layu":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Sedang Layu Basah"
tumbuh(status)
elif status == "Jagung Sedang Layu NW":
if GlobalVar.siraman == true && siram == true:
sakit()
status = "Jagung Sedang Layu Basah"
tumbuh(status)
if status == "Jagung Besar Normal":
if GlobalVar.sabit == true:
GlobalVar.money += 300
get_node("HamaTimer").stop()
status = "Tanah"
change_status(status)
if status == "Jagung Besar Kering":
if GlobalVar.sabit == true:
GlobalVar.money += 200
get_node("HamaTimer").stop()
status = "Tanah"
change_status(status)
if status == "Jagung Besar Layu":
if GlobalVar.sabit == true:
GlobalVar.money += 100
get_node("HamaTimer").stop()
status = "Tanah"
change_status(status)
pass # Replace with function body.
func change_status(status):
animation_jagung.play(status)
func tumbuh(status):
air = 100
change_status(status)
siraman += 1
siram = false
func _on_TumbuhTimer_timeout():
if status == "Benih" || status == "Benih Basah":
status = "Benih NW"
if status == "Jagung Kecil Normal" || status == "Jagung Kecil Normal Basah":
status = "Jagung Kecil Normal NW"
if status == "Jagung Sedang Normal" || status == "Jagung Sedang Normal Basah":
status = "Jagung Sedang Normal NW"
if status == "Jagung Kecil Kering" || status == "Jagung Kecil Kering Basah":
status = "Jagung Kecil Kering NW"
if status == "Jagung Sedang Kering" || status == "Jagung Sedang Kering Basah":
status = "Jagung Sedang Kering NW"
if status == "Jagung Kecil Layu" || status == "Jagung Kecil Layu Basah":
status = "Jagung Kecil Layu NW"
if status == "Jagung Sedang Layu" || status == "Jagung Sedang Layu Basah":
status = "Jagung Sedang Layu NW"
change_status(status)
siram = true
pass # Replace with function body.
func _on_AirTimer_timeout():
if sakit:
air -=5
else :
air -=2
pass # Replace with function body.
func _on_HamaTimer_timeout():
sakit = true
jumSakit +=1
pass # Replace with function body.
func sakit():
if jumSakit <= 2:
var t = rand_range(0,100)
get_node("HamaTimer").start(t)