From d717e41902282403b5186d333717e6a2d2ed72d7 Mon Sep 17 00:00:00 2001 From: Sven Eberhardt Date: Wed, 6 Jul 2016 01:04:45 -0400 Subject: [PATCH] Add user actions to SpinWheel up and down events --- .../StoneDoor.ocd/SpinWheel.ocd/Script.c | 15 +++++++++++++++ .../StoneDoor.ocd/SpinWheel.ocd/StringTblDE.txt | 2 ++ .../StoneDoor.ocd/SpinWheel.ocd/StringTblUS.txt | 2 ++ 3 files changed, 19 insertions(+) diff --git a/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/Script.c b/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/Script.c index c27cb66ba..d90b4e726 100644 --- a/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/Script.c +++ b/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/Script.c @@ -28,6 +28,8 @@ public func ControlUp(object clonk) SetAction("SpinLeft"); Sound("Structures::StoneGate::Chain"); } + // Action last; it may delete the door/clonk/etc. + UserAction->EvaluateAction(up_action, this, clonk); } public func ControlDown(object clonk) @@ -45,12 +47,22 @@ public func ControlDown(object clonk) SetAction("SpinRight"); Sound("Structures::StoneGate::Chain"); } + // Action last; it may delete the door/clonk/etc. + UserAction->EvaluateAction(down_action, this, clonk); } public func SaveScenarioObject(props) { if (!inherited(props, ...)) return false; if (targetdoor) props->AddCall("Target", this, "SetStoneDoor", targetdoor); + if (up_action || down_action) props->AddCall("Action", this, "SetActions", up_action, down_action); + return true; +} + +public func SetActions(new_up_action, new_down_action) +{ + up_action = new_up_action; + down_action = new_down_action; return true; } @@ -97,11 +109,14 @@ local EditCursorCommands = ["ControlUp()", "ControlDown()", "ConnectNearestDoor( local Plane = 200; local Components = {Wood = 3, Metal = 1}; local EditorProp_targetdoor = { Name="$Target$", Type="object", Filter="IsSwitchTarget" }; +local up_action, down_action; // Custom editor-selected actions on switch handling func Definition(def) { SetProperty("PictureTransformation", Trans_Mul(Trans_Scale(800), Trans_Translate(0,0,0),Trans_Rotate(-20,1,0,0),Trans_Rotate(-30,0,1,0)), def); SetProperty("MeshTransformation", Trans_Rotate(-13,0,1,0), def); + def.EditorProp_up_action = new UserAction.Prop { Name="$UpAction$" }; + def.EditorProp_down_action = new UserAction.Prop { Name="$DownAction$" }; } diff --git a/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/StringTblDE.txt b/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/StringTblDE.txt index 04b9b9669..d85b1cca9 100644 --- a/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/StringTblDE.txt +++ b/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/StringTblDE.txt @@ -1,3 +1,5 @@ Name=Winde Description=Öffne oder schließe die verbundene Burgtür mit [Hoch] oder [Runter]. Target=Ziel +UpAction=Aktion 'Hoch' +DownAction=Aktion 'Runter' diff --git a/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/StringTblUS.txt b/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/StringTblUS.txt index 7ecca13a9..380037bbd 100644 --- a/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/StringTblUS.txt +++ b/planet/Objects.ocd/Structures.ocd/StoneDoor.ocd/SpinWheel.ocd/StringTblUS.txt @@ -1,3 +1,5 @@ Name=Spin Wheel Description=Open and close connected castle door with [Up] and [Down] respectively. Target=Target +UpAction='Up' action +DownAction='Down' action