Browse Source

Add error messages when using invalid variable operators

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

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

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

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

@ -56,6 +56,9 @@ namespace Fungus
case CompareOperator.GreaterThanOrEquals: case CompareOperator.GreaterThanOrEquals:
condition = lhs >= rhs; condition = lhs >= rhs;
break; break;
default:
Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
break;
} }
return condition; return condition;
@ -65,7 +68,6 @@ namespace Fungus
{ {
switch (setOperator) switch (setOperator)
{ {
default:
case SetOperator.Assign: case SetOperator.Assign:
Value = value; Value = value;
break; break;
@ -81,6 +83,9 @@ namespace Fungus
case SetOperator.Divide: case SetOperator.Divide:
Value /= value; Value /= value;
break; 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; condition = lhs == rhs;
break; break;
case CompareOperator.NotEquals: case CompareOperator.NotEquals:
default:
condition = lhs != rhs; condition = lhs != rhs;
break; break;
default:
Debug.LogError("The " + compareOperator.ToString() + " comparison operator is not valid.");
break;
} }
return condition; return condition;
@ -42,10 +44,12 @@ namespace Fungus
{ {
switch (setOperator) switch (setOperator)
{ {
default:
case SetOperator.Assign: case SetOperator.Assign:
Value = value; Value = value;
break; break;
default:
Debug.LogError("The " + setOperator.ToString() + " set operator is not valid.");
break;
} }
} }
} }

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

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

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

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

Loading…
Cancel
Save