-
Notifications
You must be signed in to change notification settings - Fork 2
/
CCTV.js
executable file
·779 lines (761 loc) · 22.9 KB
/
CCTV.js
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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
//CCTV Mod V2.2 (Compatible with both 0.9 and 0.10)
//by wilco375
//Don't re-upload this code, nor share or redistribute this mod using the Github link without permission. Instead, use this link: http://adf.ly/tvNt3
var Camera = 180
var Monitor = 510
var ctx = com.mojang.minecraftpe.MainActivity.currentMainActivity.get();
var textsize = 15
var camX, camY, camZ, goToCam, currentX, currentY, currentZ, camera, cameraX, cameraY, cameraZ, air, removed, nameCam, prevCameraX, prevCameraY, prevCameraZ
var cameras = []
var camerasX = []
var camerasY = []
var camerasZ = []
//Define Camera & Monitor
Block.defineBlock(Camera,"CCTV Camera",["piston_inner",0],18,false,0)
Block.setDestroyTime(Camera, 1)
Item.addCraftRecipe(Camera,1,0,[1,3,0,20,1,0,331,2,0,1,3,0])
Item.setCategory(Camera,8,0);
ModPE.setItem(Monitor,"item_frame",0,"CCTV Monitor")
Item.addCraftRecipe(Monitor,1,0,[1,4,0,20,1,0,1,2,0,331,1,0,1,1,0])
Item.setCategory(Monitor,8,0);
//Get all cameras when starting world
function selectLevelHook(){
if(ModPE.readData("cameras"+Level.getWorldDir()) != null && ModPE.readData("cameras"+Level.getWorldDir()) != ""){
cameras = ModPE.readData("cameras"+Level.getWorldDir()).split(",")
camerasX = ModPE.readData("camerasX"+Level.getWorldDir()).split(",")
camerasY = ModPE.readData("camerasY"+Level.getWorldDir()).split(",")
camerasZ = ModPE.readData("camerasZ"+Level.getWorldDir()).split(",")
print("Loaded "+cameras.length+" cameras")
}
}
//Remove camera from list if destroyed
function destroyBlock(x,y,z,side){
blockId = getTile(x,y,z)
if(blockId == Camera){
for(i = 0;i < cameras.length;i++){
if(camerasX[i] == x && camerasY[i] == y && camerasZ[i] == z){
cameras.splice(i,1)
camerasX.splice(i,1)
camerasY.splice(i,1)
camerasZ.splice(i,1)
}
}
}
}
//Save cameras if leaving level
function leaveGame(){
if(camera == 1){
camera = 0
if(air == 1){
setTile(cameraX,cameraY-2,cameraZ,0)
air = 0
}
Entity.setPosition(getPlayerEnt(), currentX,currentY,currentZ)
}
if(cameras != null && cameras != [] && cameras != ""){
ModPE.saveData("cameras"+Level.getWorldDir(),cameras.toString())
ModPE.saveData("camerasX"+Level.getWorldDir(),camerasX.toString())
ModPE.saveData("camerasY"+Level.getWorldDir(),camerasY.toString())
ModPE.saveData("camerasZ"+Level.getWorldDir(),camerasZ.toString())
print("Saved " + cameras.length + " cameras")
cameras = null
camerasX = null
camerasY = null
camerasZ = null
}
}
//Ask to name camera and save it if placed down and prevent the player from placing blocks if in camera and show GUI if using Monitor
function useItem(x,y,z,itemId,blockId,side){
if(itemId == Monitor){
ShowCameraMenu()
}
else if(camera == 1){
preventDefault()
}
else if(itemId == Camera){
if(cameras.length >= 32){
clientMessage("Warning: You cannot see more than 32 cameras in the GUI list. You can still access it by »/cctv show <camera name>« though")}
clientMessage("Please type »/cctv name <camera name>« to give this camera a name")
nameCam = 1
if(side == 0){
camX = x
camY = y-1
camZ = z
}
else if(side == 1){
camX = x
camY = y+1
camZ = z
}
else if(side == 2){
camX = x
camY = y
camZ = z-1
}
else if(side == 3){
camX = x
camY = y
camZ = z+1
}
else if(side == 4){
camX = x-1
camY = y
camZ = z
}
else if(side == 5){
camX = x+1
camY = y
camZ = z
}
}
}
//All the commands:
function procCmd(command){
cmd = command.split(" ")
if(cmd[0] == "cctv"){
//Give the camera a name
if(cmd[1] == "name"){
if(nameCam == 1){
clientMessage("You named the camera " + cmd[2])
if(cameras == null){
cameras = []
camerasX = []
camerasY = []
camerasZ = []
}
cameras.push(cmd[2])
camerasX.push(camX)
camerasY.push(camY)
camerasZ.push(camZ)
}
else{clientMessage("Place down a camera first to name it")}
}
//List all the cameras
else if(cmd[1] == "cameras"){
clientMessage(cameras)
}
//Show a camera
else if(cmd[1] == "show"){
goToCam = null
for(i = 0;i < cameras.length;i++){
if(cameras[i] == cmd[2]){
goToCam = i
break;
}
}
if(goToCam == null){
clientMessage("This camera doesn't exist. Type »/cctv cameras« to get a list of all the cameras")
}
else{
if(camera != 1){
currentX = Player.getX()
currentY = Player.getY()
currentZ = Player.getZ()
cameraX = parseInt(camerasX[goToCam])
cameraY = parseInt(camerasY[goToCam])
cameraZ = parseInt(camerasZ[goToCam])
if(getTile(cameraX,cameraY,cameraZ) == Camera){
if(getTile(cameraX,cameraY-2,cameraZ) == 0){
air = 1
setTile(cameraX,cameraY-2,cameraZ,20)
}
Entity.setPosition(getPlayerEnt(), cameraX,cameraY,cameraZ)
clientMessage("Type »/cctv leave« to leave the camera")
camera = 1
}
else{clientMessage("The block at the location of this camera isn't a camera anymore!")}
}
else{
prevCameraX = cameraX
prevCameraY = cameraY
prevCameraZ = cameraZ
cameraX = parseInt(camerasX[goToCam])
cameraY = parseInt(camerasY[goToCam])
cameraZ = parseInt(camerasZ[goToCam])
if(getTile(cameraX,cameraY,cameraZ) == Camera){
if(air == 1){
setTile(prevCameraX,prevCameraY-2,prevCameraZ,0)
air = 0
}
if(getTile(cameraX,cameraY-2,cameraZ) == 0){
air = 1
setTile(cameraX,cameraY-2,cameraZ,20)
}
Entity.setPosition(getPlayerEnt(), cameraX,cameraY,cameraZ)
}
else{clientMessage("The block at the location of this camera isn't a camera anymore!")}
}
}
}
//Leave the current camera
else if(cmd[1] == "leave"){
if(camera == 1){
camera = 0
if(air == 1){
setTile(cameraX,cameraY-2,cameraZ,0)
air = 0
}
Entity.setPosition(getPlayerEnt(), currentX,currentY,currentZ)
}
else{clientMessage("You're not looking through a camera")}
}
//Remove a camera from the list
else if(cmd[1] == "remove"){
for(i = 0;i < cameras.length;i++){
if(cameras[i] == cmd[2]){
cameras.splice(i,1)
camerasX.splice(i,1)
camerasY.splice(i,1)
camerasZ.splice(i,1)
removed = 1
clientMessage("Successfully removed the camera")
}
}
if(removed != 1) clientMessage("No cameras with this name found")
removed = 0
}
//List all the commands
else if(cmd[1] == "list"){
clientMessage("»/cctv name <camera name>«, used to set the name of a camera once prompted to do so.")
clientMessage("»/cctv cameras«, gives a list of all the cameras")
clientMessage("»/cctv show <camera name>«, used to look through the camera")
clientMessage("»/cctv leave«, leaves the camera you're looking through")
clientMessage("»/cctv remove <camera name>«, a camera should automatically be removed from the list when broken. If not, you can use this command to remove it")
}
}
}
//TP the player back into the camera if he tries to leave
function modTick(){
if(camera == 1){
if(Player.getX() != cameraX+0.5 || Player.getY() > cameraY+1.5 || Player.getY() < cameraY+0.5 || Player.getZ() != cameraZ+0.5){
Entity.setPosition(getPlayerEnt(), cameraX+0.5,cameraY+1,cameraZ+0.5)
}
}
}
//Prevent the player from breaking blocks if he's in a camera
function destroyBlock(){
if(camera == 1){
preventDefault()
}
}
//Show GUI
function ShowCameraMenu(){
ctx.runOnUiThread(new java.lang.Runnable(){
run: function(){
try{
var menu = new android.widget.LinearLayout(ctx);
var scroll = new android.widget.ScrollView(ctx);
menu.setOrientation(android.widget.LinearLayout.VERTICAL);
scroll.addView(menu);
var dialog = new android.app.Dialog(ctx);
dialog.setContentView(scroll);
dialog.setTitle("Cameras");
//Add buttons
if(camera == 1){
var leave = new android.widget.Button(ctx);
leave.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
try{
dialog.dismiss();
camera = 0
if(air == 1){
setTile(cameraX,cameraY-2,cameraZ,0)
air = 0
}
Entity.setPosition(getPlayerEnt(),currentX,currentY,currentZ)
}
catch(e){
clientMessage(e)
}
}
})
leave.setText("Leave this camera")
leave.setTextSize(textsize)
menu.addView(leave);
}
if(cameras[0] != null){
var camera0 = new android.widget.Button(ctx);
camera0.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
try{
dialog.dismiss();
goToCam = 0;
ShowCameraFromList();
}
catch(e){
clientMessage(e)
}
}
})
camera0.setText(cameras[0])
camera0.setTextSize(textsize)
menu.addView(camera0);
}
if(cameras[1] != null){
var camera1 = new android.widget.Button(ctx);
camera1.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 1;
ShowCameraFromList();
}
})
camera1.setText(cameras[1])
camera1.setTextSize(textsize)
menu.addView(camera1);
}
if(cameras[2] != null){
var camera2 = new android.widget.Button(ctx);
camera2.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 2;
ShowCameraFromList();
}
})
camera2.setText(cameras[2])
camera2.setTextSize(textsize)
menu.addView(camera2);
}
if(cameras[3] != null){
var camera3 = new android.widget.Button(ctx);
camera3.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 3;
ShowCameraFromList();
}
})
camera3.setText(cameras[3])
camera3.setTextSize(textsize)
menu.addView(camera3);
}
if(cameras[4] != null){
var camera4 = new android.widget.Button(ctx);
camera4.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 4;
ShowCameraFromList();
}
})
camera4.setText(cameras[4])
camera4.setTextSize(textsize)
menu.addView(camera4);
}
if(cameras[5] != null){
var camera5 = new android.widget.Button(ctx);
camera5.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 5;
ShowCameraFromList();
}
})
camera5.setText(cameras[5])
camera5.setTextSize(textsize)
menu.addView(camera5);
}
if(cameras[6] != null){
var camera6 = new android.widget.Button(ctx);
camera6.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 6;
ShowCameraFromList();
}
})
camera6.setText(cameras[6])
camera6.setTextSize(textsize)
menu.addView(camera6);
}
if(cameras[7] != null){
var camera7 = new android.widget.Button(ctx);
camera7.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 7;
ShowCameraFromList();
}
})
camera7.setText(cameras[7])
camera7.setTextSize(textsize)
menu.addView(camera7);
}
if(cameras[8] != null){
var camera8 = new android.widget.Button(ctx);
camera8.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 8;
ShowCameraFromList();
}
})
camera8.setText(cameras[8])
camera8.setTextSize(textsize)
menu.addView(camera8);
}
if(cameras[9] != null){
var camera9 = new android.widget.Button(ctx);
camera9.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 9;
ShowCameraFromList();
}
})
camera9.setText(cameras[9])
camera9.setTextSize(textsize)
menu.addView(camera9);
}
if(cameras[10] != null){
var camera10 = new android.widget.Button(ctx);
camera10.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 10;
ShowCameraFromList();
}
})
camera10.setText(cameras[10])
camera10.setTextSize(textsize)
menu.addView(camera10);
}
if(cameras[11] != null){
var camera11 = new android.widget.Button(ctx);
camera11.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 11;
ShowCameraFromList();
}
})
camera11.setText(cameras[11])
camera11.setTextSize(textsize)
menu.addView(camera11);
}
if(cameras[12] != null){
var camera12 = new android.widget.Button(ctx);
camera12.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 12;
ShowCameraFromList();
}
})
camera12.setText(cameras[12])
camera12.setTextSize(textsize)
menu.addView(camera12);
}
if(cameras[13] != null){
var camera13 = new android.widget.Button(ctx);
camera13.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 13;
ShowCameraFromList();
}
})
camera13.setText(cameras[13])
camera13.setTextSize(textsize)
menu.addView(camera13);
}
if(cameras[14] != null){
var camera14 = new android.widget.Button(ctx);
camera14.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 14;
ShowCameraFromList();
}
})
camera14.setText(cameras[14])
camera14.setTextSize(textsize)
menu.addView(camera14);
}
if(cameras[15] != null){
var camera15 = new android.widget.Button(ctx);
camera15.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss();
goToCam = 15;
ShowCameraFromList();
}
})
camera15.setText(cameras[15])
camera15.setTextSize(textsize)
menu.addView(camera15);
}
if(cameras[16] != null){
var camera16 = new android.widget.Button(ctx);
camera16.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 16
ShowCameraFromList();
}
})
camera16.setText(cameras[16])
camera16.setTextSize(textsize)
menu.addView(camera16);
}
if(cameras[17] != null){
var camera17 = new android.widget.Button(ctx);
camera17.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 17
ShowCameraFromList();
}
})
camera17.setText(cameras[17])
camera17.setTextSize(textsize)
menu.addView(camera17);
}
if(cameras[18] != null){
var camera18 = new android.widget.Button(ctx);
camera18.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 18
ShowCameraFromList();
}
})
camera18.setText(cameras[18])
camera18.setTextSize(textsize)
menu.addView(camera18);
}
if(cameras[19] != null){
var camera19 = new android.widget.Button(ctx);
camera19.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 19
ShowCameraFromList();
}
})
camera19.setText(cameras[19])
camera19.setTextSize(textsize)
menu.addView(camera19);
}
if(cameras[20] != null){
var camera20 = new android.widget.Button(ctx);
camera20.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 20
ShowCameraFromList();
}
})
camera20.setText(cameras[20])
camera20.setTextSize(textsize)
menu.addView(camera20);
}
if(cameras[21] != null){
var camera21 = new android.widget.Button(ctx);
camera21.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 21
ShowCameraFromList();
}
})
camera21.setText(cameras[21])
camera21.setTextSize(textsize)
menu.addView(camera21);
}
if(cameras[22] != null){
var camera22 = new android.widget.Button(ctx);
camera22.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 22
ShowCameraFromList();
}
})
camera22.setText(cameras[22])
camera22.setTextSize(textsize)
menu.addView(camera22);
}
if(cameras[23] != null){
var camera23 = new android.widget.Button(ctx);
camera23.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 23
ShowCameraFromList();
}
})
camera23.setText(cameras[23])
camera23.setTextSize(textsize)
menu.addView(camera23);
}
if(cameras[24] != null){
var camera24 = new android.widget.Button(ctx);
camera24.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 24
ShowCameraFromList();
}
})
camera24.setText(cameras[24])
camera24.setTextSize(textsize)
menu.addView(camera24);
}
if(cameras[25] != null){
var camera25 = new android.widget.Button(ctx);
camera25.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 25
ShowCameraFromList();
}
})
camera25.setText(cameras[25])
camera25.setTextSize(textsize)
menu.addView(camera25);
}
if(cameras[26] != null){
var camera26 = new android.widget.Button(ctx);
camera26.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 26
ShowCameraFromList();
}
})
camera26.setText(cameras[26])
camera26.setTextSize(textsize)
menu.addView(camera26);
}
if(cameras[27] != null){
var camera27 = new android.widget.Button(ctx);
camera27.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 27
ShowCameraFromList();
}
})
camera27.setText(cameras[27])
camera27.setTextSize(textsize)
menu.addView(camera27);
}
if(cameras[28] != null){
var camera28 = new android.widget.Button(ctx);
camera28.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 28
ShowCameraFromList();
}
})
camera28.setText(cameras[28])
camera28.setTextSize(textsize)
menu.addView(camera28);
}
if(cameras[29] != null){
var camera29 = new android.widget.Button(ctx);
camera29.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 29
ShowCameraFromList();
}
})
camera29.setText(cameras[29])
camera29.setTextSize(textsize)
menu.addView(camera29);
}
if(cameras[30] != null){
var camera30 = new android.widget.Button(ctx);
camera30.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 30
ShowCameraFromList();
}
})
camera30.setText(cameras[30])
camera30.setTextSize(textsize)
menu.addView(camera30);
}
if(cameras[31] != null){
var camera31 = new android.widget.Button(ctx);
camera31.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 31
ShowCameraFromList();
}
})
camera31.setText(cameras[31])
camera31.setTextSize(textsize)
menu.addView(camera31);
}
if(cameras[32] != null){
var camera32 = new android.widget.Button(ctx);
camera32.setOnClickListener(new android.view.View.OnClickListener(){
onClick: function(){
dialog.dismiss()
goToCam = 32
ShowCameraFromList();
}
})
camera32.setText(cameras[32])
camera32.setTextSize(textsize)
menu.addView(camera32);
}
dialog.show()
}
catch (e){
print ("Error: "+e)
}
}
});
}
//Show the camera that's selected from the list
function ShowCameraFromList(){
if(camera != 1){
currentX = Player.getX()
currentY = Player.getY()
currentZ = Player.getZ()
cameraX = parseInt(camerasX[parseInt(goToCam)])
cameraY = parseInt(camerasY[parseInt(goToCam)])
cameraZ = parseInt(camerasZ[parseInt(goToCam)])
if(getTile(cameraX,cameraY,cameraZ) == Camera){
if(getTile(cameraX,cameraY-2,cameraZ) == 0){
air = 1
setTile(cameraX,cameraY-2,cameraZ,20)
}
Entity.setPosition(getPlayerEnt(), cameraX,cameraY,cameraZ)
clientMessage("Type »/cctv leave« to leave the camera")
camera = 1
}
else{
clientMessage("The block at the location of this camera isn't a camera any more!")
//clientMessage("The block at " + cameraX + " " + cameraY + " " + cameraZ + " is " + getTile(cameraX,cameraY,cameraZ) + ", goToCam = " + goToCam + ", camerasX[goToCam] is " + camerasX[goToCam])
}
}
else{
prevCameraX = cameraX
prevCameraY = cameraY
prevCameraZ = cameraZ
cameraX = parseInt(camerasX[goToCam])
cameraY = parseInt(camerasY[goToCam])
cameraZ = parseInt(camerasZ[goToCam])
if(getTile(cameraX,cameraY,cameraZ) == Camera){
if(air == 1){
setTile(prevCameraX,prevCameraY-2,prevCameraZ,0)
air = 0
}
if(getTile(cameraX,cameraY-2,cameraZ) == 0){
air = 1
setTile(cameraX,cameraY-2,cameraZ,20)
}
Entity.setPosition(getPlayerEnt(), cameraX,cameraY,cameraZ)
}
else{clientMessage("The block at the location of this camera isn't a camera anymore!")}
}
}