Closed ghost closed 10 years ago
The delta operator $ serves this purpose in lemongate.
if($Variable != 0){print("changed")}
But this only works with number variables
Should work with any variable type
vector V = vec(1, 1, 1)
event think() {
V = V + vec(1, 1, 1)
if ( $V ) {
print( "Changed" + (string) V )
}
}
Changed<Vector3: 2 2 2>
Changed<Vector3: 3 3 3>
Changed<Vector3: 4 4 4>
Changed<Vector3: 5 5 5>
Changed<Vector3: 6 6 6>
Changed<Vector3: 7 7 7>
Changed<Vector3: 8 8 8>
Changed<Vector3: 9 9 9>
Changed<Vector3: 10 10 10>
Changed<Vector3: 11 11 11>
Changed<Vector3: 12 12 12>
Changed<Vector3: 13 13 13>
Changed<Vector3: 14 14 14>
Changed<Vector3: 15 15 15>
Changed<Vector3: 16 16 16>
Changed<Vector3: 17 17 17>
Changed<Vector3: 18 18 18>
Changed<Vector3: 19 19 19>
Changed<Vector3: 20 20 20>
what about variable types such as string, table, arrays, entities and etc.?
Doesn't look like those types are supported (string and entity probably should have support though, they do in e2). It works with numbers, vectors and angles for sure though.
Delta shouldn't work with types that doesn't have numbers, and it's original purpose isn't meant to be used as a way to detect variable changes. All delta does is return difference value of current and previous variable state.
sorry i didn't maybe describe it clearly enough, i know delta but i need it in strings etc. and you can make it pretty easily with one static number, but still it's slower than typing changed() :)
Just store the string in another variable, that you will use to compare later...
its ~
if(~Variable){ do stuff }
works with : Strings, Entities, vectors, angles, booleans
Edit: seems it doesn't work with strings, maybe convert to char IDs then count? or do above.
As orzlar stated above, use ~Var to detect change of variable.
probably biggest issue i came across coding lemon gate that there's no changed().