Add user action evaluator: Distance between positions

qteditor
Sven Eberhardt 2016-07-30 23:49:45 -04:00
parent 108f447b2b
commit de699080dc
3 changed files with 16 additions and 0 deletions

View File

@ -195,6 +195,10 @@ func Definition(def)
Min = new Evaluator.Integer { Name="$Min$", EditorHelp="$RandomMinHelp$" },
Max = new Evaluator.Integer { Name="$Max$", EditorHelp="$RandomMaxHelp$" }
} } );
AddEvaluator("Integer", nil, "$Distance$", "$DistanceHelp$", "distance", [def, def.EvalInt_Distance], { }, { Type="proplist", Display="d({{PositionA}}..{{PositionB}})", EditorProps = {
PositionA = new Evaluator.Position { Name="$PositionA$", EditorHelp="$PositionAHelp$" },
PositionB = new Evaluator.Position { Name="$PositionB$", EditorHelp="$PositionBHelp$" }
} } );
AddEvaluator("Integer", nil, "$Variable$", "$VariableHelp$", "integer_variable", [def, def.EvalVariable, C4V_Int], { VariableName={Function="string_constant",Value=""} }, variable_delegate);
// String evaluators
AddEvaluator("String", nil, ["$Constant$", ""], "$ConstantHelp$", "string_constant", [def, def.EvalConstant], { Value="" }, { Type="string", Name="$Value$" });
@ -800,6 +804,14 @@ private func EvalOffsetDiff(proplist props, proplist context)
return [pB[0]-pA[0], pB[1]-pA[1]];
}
private func EvalInt_Distance(proplist props, proplist context)
{
var pA = EvaluatePosition(props.PositionA, context);
var pB = EvaluatePosition(props.PositionB, context);
return Distance(pA[0], pA[1], pB[0], pB[1]);
}
/* Context instance */

View File

@ -188,3 +188,5 @@ VariableNameHelp=Name der Variable. Gross- und Kleinschreibung ist relevant, das
SetVariableValueHelp=Wert, der der Variablen zugewiesen wird. Wird ein Objekt zugewiesen das spaeter entfernt wird, setzt sich die Variable automatisch auf 0.
Variable=Variable
VariableHelp=Benutzerdefinierte Variable, in die zuvor mit der Aktion 'Variable setzen' ein Wert gespeichert wurde. Werte sollten beim Abruf den gleichen Datentyp (zum Beispiel Zahl oder Text) besitzen wie zur Zeit der Speicherung.
Distance=Entfernung
DistanceHelp=Berechnet die Entfernung zwischen zwei Punkten A und B.

View File

@ -188,3 +188,5 @@ VariableNameHelp=Name of the variable. Case sensitive, i.e. foo and Foo are dist
VariableValueHelp=Value to assign to this variable. If an object is assigned and later removed, all variables pointing to this object will be emptied.
Variable=Variable
VariableHelp=User-defined variable, into which a value was previously stored using the 'Set variable' action. Values should be queried using the same data type (e.g. Integer or Text) as they were stored.
Distance=Distance
DistanceHelp=Calculates the distance between two positions A and B.