diff options
| author | Markus Mittendrein <git@maxmitti.tk> | 2017-01-02 19:33:41 +0100 |
|---|---|---|
| committer | Markus Mittendrein <git@maxmitti.tk> | 2017-01-05 16:31:26 +0100 |
| commit | fa5403dccd986022b2a849e2078f043c3225348a (patch) | |
| tree | 223fac13363b078720cd6e0d04d6adf53edc5dc9 /Targets.c4d/System.c4g/Towers.c | |
| download | DTSensors.c4d-fa5403dccd986022b2a849e2078f043c3225348a.tar.gz DTSensors.c4d-fa5403dccd986022b2a849e2078f043c3225348a.zip | |
Initial
Diffstat (limited to 'Targets.c4d/System.c4g/Towers.c')
| -rw-r--r-- | Targets.c4d/System.c4g/Towers.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Targets.c4d/System.c4g/Towers.c b/Targets.c4d/System.c4g/Towers.c new file mode 100644 index 0000000..1b66297 --- /dev/null +++ b/Targets.c4d/System.c4g/Towers.c @@ -0,0 +1,48 @@ +#strict 2 +#appendto TWR2 + +func IsRemoteControllable() { return false; } + +func FindGate(bool right) { return FindObject(0, 0, 0, 0, 0, 0, (right && "GateRight") || "GateLeft", this); } + +func SensorCallbacks() +{ + var ret = []; + for(var part in [[false, "$TWR2_LeftGate$", ["LeftGateOpen", "LeftGateClose", "ControlLeft"]], [true, "$TWR2_RightGate$", ["RightGateOpen", "RightGateClose", "ControlRight"]]]) + { + if(FindGate(part[0])) + { + ret[GetLength(ret)] = [Format("$TWR2_GateOpen$", part[1]), part[2][0]]; + ret[GetLength(ret)] = [Format("$TWR2_GateClose$", part[1]), part[2][1]]; + ret[GetLength(ret)] = [Format("$TWR2_GateOpenClose$", part[1]), part[2][2]]; + } + } + return ret; +} + +func LeftGateOpen() { return GateOpen(false); } +func LeftGateClose() { return GateClose(false); } + +func RightGateOpen() { return GateOpen(true); } +func RightGateClose() { return GateClose(true); } + +func GateOpen(bool right) { return GateOpenClose(right, false); } +func GateClose(bool right) { return GateOpenClose(right, true); } + +func GateOpenClose(bool right, bool close) +{ + var gate = FindGate(right); + if(gate) + { + gate->Activate(); + + if(close) + { + gate->Close(); + } + else + { + gate->Open(); + } + } +} |
