public static void SetInteger(NWN2ScriptVarTable variables, string name, int value) { try { variables.GetVariable(name).ValueInt = value; variables.GetVariable(name).VariableType = NWN2ScriptVariableType.Int; } catch { NWN2ScriptVariable var = new NWN2ScriptVariable(name, value); var.VariableType = NWN2ScriptVariableType.Int; variables.Add(var); } }
public static void SetFloat(NWN2ScriptVarTable variables, string name, float value) { try { variables.GetVariable(name).ValueFloat = value; variables.GetVariable(name).VariableType = NWN2ScriptVariableType.Float; } catch { NWN2ScriptVariable var = new NWN2ScriptVariable(name, value); var.VariableType = NWN2ScriptVariableType.Float; variables.Add(var); } }
// // Integer // #region Integer public static int GetInteger(NWN2ScriptVarTable variables, string name) { try { return variables.GetVariable(name).ValueInt; } catch { return 0; } }
// // Float // #region Float public static float GetFloat(NWN2ScriptVarTable variables, string name) { try { return variables.GetVariable(name).ValueFloat; } catch { return 0.0f; } }
// // String // #region String public static string GetString(NWN2ScriptVarTable variables, string name) { try { return variables.GetVariable(name).ValueString; } catch { return ""; } }
public static void DeleteStringArray(NWN2ScriptVarTable variables, string name) { try { for (uint i = 1; i < uint.MaxValue; i++) { NWN2ScriptVariable var = variables.GetVariable(name.Replace("*", i.ToString())); if (var.VariableType == NWN2ScriptVariableType.None) break; variables.Remove(var); } } catch { } }
public static void SetString(NWN2ScriptVarTable variables, string name, string value) { try { variables.GetVariable(name).ValueString = value; variables.GetVariable(name).VariableType = NWN2ScriptVariableType.String; } catch { NWN2ScriptVariable var = new NWN2ScriptVariable(name, value); var.VariableType = NWN2ScriptVariableType.String; variables.Add(var); } }