private bool Less(List <string> args, Textbox originTextbox) { float n1 = 0f; float n2 = 0f; bool success = float.TryParse(originTextbox.ParseSection(args[0]), out n1) && float.TryParse(originTextbox.ParseSection(args[1]), out n2); if (!success) { return(false); } return(n1 < n2); }
public override string PerformAction(string actionString, Textbox originTextbox) { List <string> args = ExtractArgs(actionString, condition); if (args.Count != 2) { Debug.Log("INVALID ADD VARIABLE COMMAND, Need 2 Args <ADD FLOAT FLOAT> got: " + args.Count); return(""); } float n1 = 0f; float n2 = 0f; bool success = float.TryParse(originTextbox.ParseSection(args[0]), out n1) && float.TryParse(originTextbox.ParseSection(args[1]), out n2); if (!success) { return("ERROR"); } if (condition == "+") { return((add(n1, n2)).ToString()); } else if (condition == "-") { return((subtract(n1, n2)).ToString()); } else if (condition == "*") { return((multiply(n1, n2)).ToString()); } else if (condition == "/") { return((divide(n1, n2)).ToString()); } else if (condition == "%") { return((modulo(n1, n2)).ToString()); } return(""); }
public override string PerformAction(string actionString, Textbox originTextbox) { List <string> args = ExtractArgs(actionString, "IF"); if (args.Count < 2 || args.Count > 3) { Debug.Log("INVALID SET VARIABLE COMMAND, Need 2-3 Args <IF CONDITION THENACTION OPTIONALELSE> got: " + args.Count + "arguments."); return(""); } string cond = originTextbox.ParseSection(args[0]); if (cond == "T") { return(originTextbox.ParseSection(args[1])); } else if (args.Count == 3) { return(originTextbox.ParseSection(args[2])); } else { return(""); } }
public override string PerformAction(string actionString, Textbox originTextbox) { List <string> args = ExtractArgs(actionString, "VARCHK"); if (args.Count != 3) { Debug.Log("INVALID SET VARIABLE COMMAND, Need 3 or 4 Args <IF VARIABLE EQUALTOVAL THENACTION ELSE> got: " + args.Count + "arguments."); return(""); } string s = SaveObjManager.PublicVars().GetString(args [0]); if (s.Length > 0 || s != args[1]) { return(originTextbox.ParseSection(args[2])); } else if (args.Count == 4) { return(originTextbox.ParseSection(args[3])); } else { return(""); } }
public override string PerformAction(string actionString, Textbox originTextbox) { List <string> args = ExtractArgs(actionString, condition); if (args.Count < 2) { if (condition == "ITEMEQUIP") { Debug.Log("INVALID ITEM VARIABLE COMMAND, Need 2 or 3 Args <" + condition + " USER ITEMNAME SLOTNAME> got: " + args.Count); } else { Debug.Log("INVALID ITEM VARIABLE COMMAND, Need 2 or 3 Args <" + condition + " USER ITEMNAME STACKNUMBER> got: " + args.Count); } return(""); } GameObject user = GameObject.Find(originTextbox.ParseSection(args[0])); string itemName = originTextbox.ParseSection(args[1]); if (user == null || user.GetComponent <InventoryHolder>() == null || (GameObject)Resources.Load(itemName) == null) { return(""); } GameObject item = (GameObject)Resources.Load(itemName); if (item.GetComponent <Item>() == null) { return("ERROR Item not found"); } int stack = 1; string slot = ""; if (condition == "ITEMEQUIP") { slot = originTextbox.ParseSection(args[2]); } else { int.TryParse(originTextbox.ParseSection(args[2]), out stack); } if (condition == "ITEMNUM") { return(itemNum(user.GetComponent <InventoryHolder>(), item, stack)); } else if (condition == "ITEMHAS") { return(itemHas(user.GetComponent <InventoryHolder>(), item, stack)); } else if (condition == "ITEMGIVE") { itemGive(user.GetComponent <InventoryHolder>(), item, stack); } else if (condition == "ITEMTAKE") { itemTake(user.GetComponent <InventoryHolder>(), item, stack); } else if (condition == "ITEMEQUIP") { itemEqp(user.GetComponent <InventoryHolder>(), item, slot); } return(""); }