diff options
| author | Michael <[email protected]> | 2017-02-02 09:47:23 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-02 09:47:23 -0500 |
| commit | bbe37edb68f9e7535216bff80ba3e6b16cbca398 (patch) | |
| tree | 4382859eda0c253e17966159890f49208a41367f /ShiftOS_TheReturn | |
| parent | d8978b860d950e3ccde3c8beecf8b88bdd4a34a8 (diff) | |
| download | shiftos_thereturn-bbe37edb68f9e7535216bff80ba3e6b16cbca398.tar.gz shiftos_thereturn-bbe37edb68f9e7535216bff80ba3e6b16cbca398.tar.bz2 shiftos_thereturn-bbe37edb68f9e7535216bff80ba3e6b16cbca398.zip | |
Shiftnet, and audio fixes
Diffstat (limited to 'ShiftOS_TheReturn')
| -rw-r--r-- | ShiftOS_TheReturn/AudioManager.cs | 4 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/SaveSystem.cs | 19 | ||||
| -rw-r--r-- | ShiftOS_TheReturn/Scripting.cs | 43 |
3 files changed, 58 insertions, 8 deletions
diff --git a/ShiftOS_TheReturn/AudioManager.cs b/ShiftOS_TheReturn/AudioManager.cs index 4f90d76..d03da4c 100644 --- a/ShiftOS_TheReturn/AudioManager.cs +++ b/ShiftOS_TheReturn/AudioManager.cs @@ -29,6 +29,10 @@ namespace ShiftOS.Engine }; var t = new Thread(() => { + SaveSystem.GameReady += () => + { + _out.Volume = _provider.Volume; + }; Random rnd = new Random(); while(_running == true) { diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 7678bca..4934221 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -101,15 +101,16 @@ namespace ShiftOS.Engine if (defaultConf.ConnectToMud == true) { - try + bool guidReceived = false; + ServerManager.GUIDReceived += (str) => { - bool guidReceived = false; - ServerManager.GUIDReceived += (str) => - { - guidReceived = true; - Console.WriteLine("{CONNECTION_SUCCESSFUL}"); - }; + guidReceived = true; + Console.WriteLine("{CONNECTION_SUCCESSFUL}"); + }; + try + { + ServerManager.Initiate("secondary4162.cloudapp.net", 13370); while(guidReceived == false) { @@ -121,6 +122,10 @@ namespace ShiftOS.Engine Console.WriteLine("{ERROR}: " + ex.Message); Thread.Sleep(3000); ServerManager.StartLANServer(); + while (guidReceived == false) + { + + } } } else diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs index 4d5c1a7..1bb48d5 100644 --- a/ShiftOS_TheReturn/Scripting.cs +++ b/ShiftOS_TheReturn/Scripting.cs @@ -34,6 +34,7 @@ using System.Dynamic; using Newtonsoft.Json; using System.Windows.Forms; using System.Threading; +using System.Net; namespace ShiftOS.Engine.Scripting { @@ -125,6 +126,16 @@ namespace ShiftOS.Engine.Scripting t.IsBackground = true; t.Start(); }); + Lua.includeScript = new Action<string>((file) => + { + if (!Utils.FileExists(file)) + throw new ArgumentException("File does not exist."); + + if (!file.EndsWith(".lua")) + throw new ArgumentException("File is not a lua file."); + + Lua(Utils.ReadAllText(file)); + }); } @@ -142,12 +153,31 @@ namespace ShiftOS.Engine.Scripting public void Execute(string lua) { + try + { Console.WriteLine(""); Lua(lua); Console.WriteLine($"{SaveSystem.CurrentSave.Username}@{SaveSystem.CurrentSave.SystemName}:~$ "); + } + catch (Exception e) + { + Infobox.Show("Script error", $@"Script threw {e.GetType().Name}: + +{e.Message}"); + } } } + [Exposed("net")] + public class NetFunctions + { + public string get(string url) + { + return new WebClient().DownloadString(url); + } + + } + [Exposed("console")] public class ConsoleFunctions { @@ -175,7 +205,18 @@ namespace ShiftOS.Engine.Scripting return TerminalBackend.RunClient(cmd, args); } - + public void addCodepoints(int cp) + { + if (cp > 100 || cp <= 0) + { + throw new Exception("Value 'cp' must be at or below 100, and above 0."); + } + else + { + SaveSystem.CurrentSave.Codepoints += cp; + SaveSystem.SaveGame(); + } + } } |
