internal Personality(VM vm, string name, string id) { VM = vm; // These variables MUST always be set: variables["name"] = name_var = new Variable(name); variables["id"] = id_var = new Variable(id) { Readonly = true }; variables["enabled_user"] = enabledUser_var = new Variable(true); variables["birthday"] = new Variable(new VType.Date(DateTime.MinValue)); // readonly age, returns DateTime.Now - BirthDay variables["age"] = new VariableFunc(() => { try { var span = DateTime.Now - ((VType.Date)variables["birthday"].Value).Value; return (float)(new DateTime(1, 1, 1) + span).Year - 1f; } catch (ArgumentOutOfRangeException) { return -1f; } }, null); // ToDo 5: Add mood variables. }
public static void AddTo(VM vm) { vm.AddFunction(restart); vm.AddFunction(random); vm.AddFunction(wait); }
public static void AddTo(VM vm) { // if statements vm.AddFunction(@if); vm.AddFunction(elseif); vm.AddFunction(@else); vm.AddFunction(isSet); vm.AddFunction(@goto); // date time vm.AddFunction(date); vm.AddFunction(time); vm.AddFunction("x", (Context sender, Variable[] args) => { return new Variable(); }); }
public frmSettings(AllSettings settings, VM vm) { this.settings = settings; this.vm = vm; InitializeComponent(); }
internal Controller(VM vm, string id) { VM = vm; Id = VM.KeyClean(id); }
private bool load(frmLoading.StatusDelegate status) { status(0, Strings.Status_Load_Settings); settings = Settings.AllSettings.Load(); if (settings == null) { settings = new Settings.AllSettings(); Thread.Sleep(4000); } status(10, Strings.Status_Creating_VM); vm = new VM(); status(15, Strings.Status_Add_Functions); CoreFunctions.AddTo(vm); Functions.AddTo(vm); status(20, Strings.Status_Load_Scripts); vm.LoadFromDirectory("scripts"); // Load all scripts from scripts folder. status(40, Strings.Status_Load_Personalities); vm.LoadFromDirectory(settings.Personalities.Path); Personality player; if (!vm.TryGetPersonality("player", out player)) player = vm.CreatePersonality("Player"); // Create a personality for testing. Personality persona; if (!vm.TryGetPersonality("Lisa", out persona)) persona = vm.CreatePersonality("Lisa"); status(70, Strings.Status_Validate); vm.Validate(); // ToDo : Move message to strings status(80, "Running setups.."); vm.RunPersonalitySetup(); var controller = vm.CreateController("Main"); controller.Interval = 500; controller.AutoFill = true; controller.AddPersonality(persona); status(90, Strings.Status_Load_UI); bool split = settings.Windows.Split; // show the main windows and get the glitter and chat controls. Glitter glitter; Chat chat; if (split) { var other = new frmSplitOther(); var media = new frmSplitMedia(); settings.Windows.SplitOther.Attach(other); settings.Windows.SplitMedia.Attach(media); addMainForm(other); addMainForm(media); chat = other.Chat; glitter = other.Glitter; } else { var combined = new frmCombined(); settings.Windows.Combined.Attach(combined); addMainForm(combined); chat = combined.Chat; glitter = combined.Glitter; } // assign the output of the controller to go to the chat control. controller.OnOutput = chat.Message; // just dump all chat input to the controller. chat.OnInput = (string text) => { controller.Input(player, text); }; status(100, Strings.Status_Display_UI); return true; }
public Script(VM vm, bool isList, string key, Line[] lines, string[] tags, GroupInfo group, Logger log) : base(key, lines, tags, group, log) { this.vm = vm; List = isList; }
public Variable(VM.Function value) { _value = value; }