-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrepeaterlib.txt
78 lines (66 loc) · 1.9 KB
/
repeaterlib.txt
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
@name repeaterlib
@persist RepeaterLib_Repeaters:table
@model models/bull/gates/microcontroller1.mdl
#[ ]#
## E2 Library: RepeaterLib ##
## ##
## Implements easy repeating timers. ##
#[ ]#
if(first()){
###############
##
# repeater( ID:string, Time )
# Creates a new repeating timer and starts it
#
function repeater(ID:string,Time){
RepeaterLib_Repeaters[ID,number] = Time
timer("RepeaterLib_"+ID,Time)
}
###############
##
# repeaterClk( ID:string )
# Use this for repeaters where you'd normally use clk() for timers
#
function number repeaterClk(ID:string){
return clk("RepeaterLib_"+ID)
}
###############
##
# repeaterRemove( ID:string )
# Removes a repeating timer
#
function repeaterRemove(ID:string){
RepeaterLib_Repeaters:remove(ID)
}
###############
##
# repeaterStop( ID:string )
# Stops a repeating timer
#
function repeaterStop(ID:string){
#ifdef stoptimer(string)
stoptimer("RepeaterLib_"+ID)
#else
timer("RepeaterLib_"+ID,inf())
#endif
}
###############
##
# repeaterStart( ID:string )
# Restarts a repeating timer
#
function repeaterStart(ID:string){
timer("RepeaterLib_"+ID,RepeaterLib_Repeaters[ID,number])
}
if(entity():model() == "models/bull/gates/microcontroller1.mdl"){
selfDestruct()
error("This is a library; #include it in something.")
}
}
Keys = RepeaterLib_Repeaters:keys()
foreach(ID,Key:string=Keys){
local Time = RepeaterLib_Repeaters[Key,number]
if(clk("RepeaterLib_"+Key)){
timer("RepeaterLib_"+Key,Time)
}
}