-
Notifications
You must be signed in to change notification settings - Fork 35
/
multishot.js
79 lines (67 loc) · 1.64 KB
/
multishot.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
//timers are stored as [id, ticksRemaining, functionPointer, repeating
//(-1 for no repeating, ticks for repeating)] inside the following array.
var time_timers = [];
var time_nextId = 0;
//timerlib_setTimeout(func, ticks):
//after the specified number of in-game ticks, run the function.
//one tick is equal to 1/20th of a second.
//this is different from browser JavaScript, which takes in milliseconds instead.
//returns a timer ID you can use to cancel the timer.
function setTimeout(func, ticks) {
var id = time_nextId++;
time_timers.push([id, ticks, func, -1]);
return id;
}
function setInterval(func, ticks) {
var id = time_nextId++;
time_timers.push([id, ticks, func, ticks]);
return id;
}
//clear a timeout that was previously set with setTimeout.
//pass in the returned ID.
function clearTimeout(id) {
for (var i = time_timers.length - 1; i >= 0; --i) {
var t = time_timers[i];
if (t[0] == id) {
time_timers.splice(i, 1);
break;
}
}
}
function clearInterval(id) {
clearTimeout(id);
}
function time_runTimers() {
for (var i = time_timers.length - 1; i >= 0; --i) {
var t = time_timers[i];
t[1]--;
if (t[1] == 0) {
t[2]();
if (t[3] == -1) {
time_timers.splice(i, 1);
} else {
t[1] = t[3];
}
}
}
}
//end copy and paste here
function modTick() {
//you must call time_runTimers();
time_runTimers();
}
var shots = 0;
function takeScreenshotRepeatedly() {
if (shots > 0) {
ModPE.takeScreenshot("shots");
shots--;
if (shots > 0) {
setTimeout(takeScreenshotRepeatedly, 10);
//once every second for 20 times
}
}
}
function useItem(x, y, z, i, b, s) {
shots = 20;
takeScreenshotRepeatedly();
}