Browse Source

Add error messages when using invalid variable operators

master
Jorge Ramirez 7 years ago
parent
commit
f23e5f192a
  1. 20
      Assets/Fungus/Scripts/VariableTypes/BooleanVariable.cs
  2. 43
      Assets/Fungus/Scripts/VariableTypes/FloatVariable.cs
  3. 8
      Assets/Fungus/Scripts/VariableTypes/GameObjectVariable.cs
  4. 43
      Assets/Fungus/Scripts/VariableTypes/IntegerVariable.cs
  5. 20
      Assets/Fungus/Scripts/VariableTypes/StringVariable.cs

20
Assets/Fungus/Scripts/VariableTypes/BooleanVariable.cs

@ -25,13 +25,15 @@ namespace Fungus
switch (compareOperator)
{
case CompareOperator.Equals:
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
default:
condition = lhs != rhs;
break;
case CompareOperator.Equals:
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
condition = lhs != rhs;
break;
default:
Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
break;
}
return condition;
@ -41,13 +43,15 @@ namespace Fungus
{
switch (setOperator)
{
default:
case SetOperator.Assign:
Value = value;
break;
case SetOperator.Negate:
Value = !value;
break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;
}
}
}

43
Assets/Fungus/Scripts/VariableTypes/FloatVariable.cs

@ -38,24 +38,27 @@ namespace Fungus
switch (compareOperator)
{
case CompareOperator.Equals:
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
condition = lhs != rhs;
break;
case CompareOperator.LessThan:
condition = lhs < rhs;
break;
case CompareOperator.GreaterThan:
condition = lhs > rhs;
break;
case CompareOperator.LessThanOrEquals:
condition = lhs <= rhs;
break;
case CompareOperator.GreaterThanOrEquals:
condition = lhs >= rhs;
break;
case CompareOperator.Equals:
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
condition = lhs != rhs;
break;
case CompareOperator.LessThan:
condition = lhs < rhs;
break;
case CompareOperator.GreaterThan:
condition = lhs > rhs;
break;
case CompareOperator.LessThanOrEquals:
condition = lhs <= rhs;
break;
case CompareOperator.GreaterThanOrEquals:
condition = lhs >= rhs;
break;
default:
Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
break;
}
return condition;
@ -65,7 +68,6 @@ namespace Fungus
{
switch (setOperator)
{
default:
case SetOperator.Assign:
Value = value;
break;
@ -81,6 +83,9 @@ namespace Fungus
case SetOperator.Divide:
Value /= value;
break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;
}
}
}

8
Assets/Fungus/Scripts/VariableTypes/GameObjectVariable.cs

@ -30,9 +30,11 @@ namespace Fungus
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
default:
condition = lhs != rhs;
break;
default:
Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
break;
}
return condition;
@ -42,10 +44,12 @@ namespace Fungus
{
switch (setOperator)
{
default:
case SetOperator.Assign:
Value = value;
break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;
}
}
}

43
Assets/Fungus/Scripts/VariableTypes/IntegerVariable.cs

@ -38,24 +38,27 @@ namespace Fungus
switch (compareOperator)
{
case CompareOperator.Equals:
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
condition = lhs != rhs;
break;
case CompareOperator.LessThan:
condition = lhs < rhs;
break;
case CompareOperator.GreaterThan:
condition = lhs > rhs;
break;
case CompareOperator.LessThanOrEquals:
condition = lhs <= rhs;
break;
case CompareOperator.GreaterThanOrEquals:
condition = lhs >= rhs;
break;
case CompareOperator.Equals:
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
condition = lhs != rhs;
break;
case CompareOperator.LessThan:
condition = lhs < rhs;
break;
case CompareOperator.GreaterThan:
condition = lhs > rhs;
break;
case CompareOperator.LessThanOrEquals:
condition = lhs <= rhs;
break;
case CompareOperator.GreaterThanOrEquals:
condition = lhs >= rhs;
break;
default:
Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
break;
}
return condition;
@ -65,7 +68,6 @@ namespace Fungus
{
switch (setOperator)
{
default:
case SetOperator.Assign:
Value = value;
break;
@ -81,6 +83,9 @@ namespace Fungus
case SetOperator.Divide:
Value /= value;
break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;
}
}
}

20
Assets/Fungus/Scripts/VariableTypes/StringVariable.cs

@ -25,13 +25,15 @@ namespace Fungus
switch (compareOperator)
{
case CompareOperator.Equals:
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
default:
condition = lhs != rhs;
break;
case CompareOperator.Equals:
condition = lhs == rhs;
break;
case CompareOperator.NotEquals:
condition = lhs != rhs;
break;
default:
Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
break;
}
return condition;
@ -41,10 +43,12 @@ namespace Fungus
{
switch (setOperator)
{
default:
case SetOperator.Assign:
Value = value;
break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;
}
}
}

Loading…
Cancel
Save