From 35c071c3df89ea3b8b0a99d59892bcb8bff33f93 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sun, 13 Feb 2022 22:52:06 +0100 Subject: Enable Knights Targets with #appendto nowarn --- Targets.c4d/Knights.c4d/System.c4g/Script.c | 73 ++++++++++++++++++++++ .../Knights.c4d_disabled/System.c4g/Script.c | 73 ---------------------- 2 files changed, 73 insertions(+), 73 deletions(-) create mode 100644 Targets.c4d/Knights.c4d/System.c4g/Script.c delete mode 100644 Targets.c4d/Knights.c4d_disabled/System.c4g/Script.c (limited to 'Targets.c4d') diff --git a/Targets.c4d/Knights.c4d/System.c4g/Script.c b/Targets.c4d/Knights.c4d/System.c4g/Script.c new file mode 100644 index 0000000..e9a8e69 --- /dev/null +++ b/Targets.c4d/Knights.c4d/System.c4g/Script.c @@ -0,0 +1,73 @@ +#strict 2 +#appendto CPT2 nowarn + +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[] = [Format("$TWR2_GateOpen$", part[1]), part[2][0]]; + ret[] = [Format("$TWR2_GateClose$", part[1]), part[2][1]]; + ret[] = [Format("$TWR2_GateOpenClose$", part[1]), part[2][2]]; + } + } + + if((GetID() == CPT3 || GetID() == CPT4) && this->FindDrawbridge()) + { + ret[] = ["$TWR2_DrawBridgeUp$", "ControlUp"]; + ret[] = ["$TWR2_DrawBridgeDown$", "ControlDownSingle"]; + ret[] = ["$TWR2_DrawBridgeUpDown$", "ToggleDrawBridge"]; + } + + 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(); + } + } +} + +func ToggleDrawBridge() +{ + var bridge = this->FindDrawbridge(); + if(bridge) + { + if(bridge->IsUp()) + { + return bridge->ControlDown(); + } + else + { + return bridge->ControlUp(); + } + } +} + diff --git a/Targets.c4d/Knights.c4d_disabled/System.c4g/Script.c b/Targets.c4d/Knights.c4d_disabled/System.c4g/Script.c deleted file mode 100644 index 07e1505..0000000 --- a/Targets.c4d/Knights.c4d_disabled/System.c4g/Script.c +++ /dev/null @@ -1,73 +0,0 @@ -#strict 2 -#appendto CPT2 - -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[] = [Format("$TWR2_GateOpen$", part[1]), part[2][0]]; - ret[] = [Format("$TWR2_GateClose$", part[1]), part[2][1]]; - ret[] = [Format("$TWR2_GateOpenClose$", part[1]), part[2][2]]; - } - } - - if((GetID() == CPT3 || GetID() == CPT4) && this->FindDrawbridge()) - { - ret[] = ["$TWR2_DrawBridgeUp$", "ControlUp"]; - ret[] = ["$TWR2_DrawBridgeDown$", "ControlDownSingle"]; - ret[] = ["$TWR2_DrawBridgeUpDown$", "ToggleDrawBridge"]; - } - - 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(); - } - } -} - -func ToggleDrawBridge() -{ - var bridge = this->FindDrawbridge(); - if(bridge) - { - if(bridge->IsUp()) - { - return bridge->ControlDown(); - } - else - { - return bridge->ControlUp(); - } - } -} - -- cgit v1.2.3-54-g00ecf