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) switch (compareOperator)
{ {
case CompareOperator.Equals: case CompareOperator.Equals:
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;
} }
} }
} }

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

@ -38,24 +38,27 @@ namespace Fungus
switch (compareOperator) switch (compareOperator)
{ {
case CompareOperator.Equals: case CompareOperator.Equals:
condition = lhs == rhs; condition = lhs == rhs;
break; break;
case CompareOperator.NotEquals: case CompareOperator.NotEquals:
condition = lhs != rhs; condition = lhs != rhs;
break; break;
case CompareOperator.LessThan: case CompareOperator.LessThan:
condition = lhs < rhs; condition = lhs < rhs;
break; break;
case CompareOperator.GreaterThan: case CompareOperator.GreaterThan:
condition = lhs > rhs; condition = lhs > rhs;
break; break;
case CompareOperator.LessThanOrEquals: case CompareOperator.LessThanOrEquals:
condition = lhs <= rhs; condition = lhs <= rhs;
break; break;
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;
} }
} }
} }

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

@ -38,24 +38,27 @@ namespace Fungus
switch (compareOperator) switch (compareOperator)
{ {
case CompareOperator.Equals: case CompareOperator.Equals:
condition = lhs == rhs; condition = lhs == rhs;
break; break;
case CompareOperator.NotEquals: case CompareOperator.NotEquals:
condition = lhs != rhs; condition = lhs != rhs;
break; break;
case CompareOperator.LessThan: case CompareOperator.LessThan:
condition = lhs < rhs; condition = lhs < rhs;
break; break;
case CompareOperator.GreaterThan: case CompareOperator.GreaterThan:
condition = lhs > rhs; condition = lhs > rhs;
break; break;
case CompareOperator.LessThanOrEquals: case CompareOperator.LessThanOrEquals:
condition = lhs <= rhs; condition = lhs <= rhs;
break; break;
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;
} }
} }
} }

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

@ -25,13 +25,15 @@ namespace Fungus
switch (compareOperator) switch (compareOperator)
{ {
case CompareOperator.Equals: case CompareOperator.Equals:
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