-
Notifications
You must be signed in to change notification settings - Fork 0
/
Holocamera.txt
101 lines (73 loc) · 2.24 KB
/
Holocamera.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@name Holocamera
@inputs Rec Play
@persist Holo:array Ent:array X Y Z Pos:table E2:array Time StartTime
#FUNCTIONS
function vector scaledPos(E:entity,Scale) {
return entity():pos()+vec(0,0,10)+((E:pos()-entity():pos())/Scale)
}
function vector unscaledPos(E:entity,Scale) {
return entity():pos()+((E:pos()-entity():pos())*Scale)
}
#FIRST EXECUTION
if(first()) {
X=1
signalSetGroup("camera")
runOnSignal("memory",0,1)
StartTime=realtime()
Time=realtime()
}
interval(10)
#interval(10 - delay between int and fileclk)
#FIND COMMANDS
if(realtime()>(Time+findUpdateRate())) {
if(Find) {
findByClass("gmod_wire_expression2")
findSortByDistance(entity():pos())
if(E2:count()!=findToArray():count()) {E2=findToArray():add(array(entity()))}
Time=realtime()
}
elseif(Ent:count()<1) {
findByClass("prop_physics")
findClipFromClass("gmod_wire_expression2")
if(Ent:count()!=findToArray():count()) {Ent=findToArray()}
Time=realtime()
}
Find = !Find
if(changed(E2:count())) {print("e2:"+E2:count())}
if(changed(Ent:count())) {print("ent:"+Ent[Ent:count(),entity]:id())}
}
#CREATE OBJECT IN HOLO AT INDEX (X)
elseif(!Holo[X,entity]:isValid() & Ent[X,entity]:isValid()) {
Holo[X,entity]=holoCreate(X,scaledPos(Ent[X,entity],10),vec(1,1,1)/10,Ent[X,entity]:angles(),Ent[X,entity]:getColor())
holoModel(X,Ent[X,entity]:model())
holoMaterial(X,Ent[X,entity]:getMaterial())
}
elseif(holoCanCreate()) {X++}
if(holoRemainingSpawns()<1) {
print("reached max" + (X+1):toString())
}
#RECORD POSITIONS
if(Rec){
T = vonDecodeTable(Pos[Y,string])
V = T[T:count(),table][2,vector]
while(Y<Holo:count() && perf()) {
Y++
if(scaledPos(Ent[X,entity],10):distance(V)>10) {
#distance = square root( ((A:x()-B:x())^2)+(A:y()-B:y())^2)+(A:z()-B:z())^2))
#do not define values inside loop unless needed
holoPos(Y,V)
}
}
if(changed(Y) & Y<Holo:count()) {
First = 0
if(!First) {print(Y) First = 1}
#if count > oplimit
#then send signal to group "memory"
#issues:
#doing this wont change count > oplimit, will run more than once.
#will send to any chip with group "memory", multiple chips doing same task
Index = (Holo:count()/ E2:count()):toString()
T2 = T:clone():concat(Index,Y+1,Holo:count()):explode("")
dsSend(E2[Index:toNumber(),entity]:id():toString(),"memory",vonEncode(T))
}
}else{First=1}