Option to make RegEx component only send a signal when it receives a signal (not continuously according to the last received signal), added FalseOutput property to RegEx component. Closes #846, Closes #911
This commit is contained in:
@@ -5,23 +5,25 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
class RegExFindComponent : ItemComponent
|
||||
{
|
||||
private string output;
|
||||
|
||||
private string expression;
|
||||
|
||||
private string receivedSignal;
|
||||
private string previousReceivedSignal;
|
||||
|
||||
bool previousResult;
|
||||
private bool previousResult;
|
||||
|
||||
private Regex regex;
|
||||
|
||||
private bool nonContinuousOutputSent;
|
||||
|
||||
[InGameEditable, Serialize("1", true)]
|
||||
public string Output
|
||||
{
|
||||
get { return output; }
|
||||
set { output = value; }
|
||||
}
|
||||
public string Output { get; set; }
|
||||
|
||||
[InGameEditable, Serialize("0", true)]
|
||||
public string FalseOutput { get; set; }
|
||||
|
||||
[Serialize(true, true), InGameEditable(ToolTip = "Should the component keep sending the output even after it stops receiving a signal, or only send an output when it receives a signal.")]
|
||||
public bool ContinuousOutput { get; set; }
|
||||
|
||||
[InGameEditable, Serialize("", true)]
|
||||
public string Expression
|
||||
@@ -73,8 +75,15 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
item.SendSignal(0, previousResult ? output : "0", "signal_out", null);
|
||||
if (ContinuousOutput)
|
||||
{
|
||||
item.SendSignal(0, previousResult ? Output : FalseOutput, "signal_out", null);
|
||||
}
|
||||
else if (!nonContinuousOutputSent)
|
||||
{
|
||||
item.SendSignal(0, previousResult ? Output : FalseOutput, "signal_out", null);
|
||||
nonContinuousOutputSent = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item source, Character sender, float power = 0.0f)
|
||||
@@ -85,7 +94,7 @@ namespace Barotrauma.Items.Components
|
||||
receivedSignal = signal;
|
||||
break;
|
||||
case "set_output":
|
||||
output = signal;
|
||||
Output = signal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user