aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/Scripting.cs
diff options
context:
space:
mode:
authorpfg <[email protected]>2017-03-12 09:45:11 -0700
committerpfg <[email protected]>2017-03-12 09:45:11 -0700
commit5ee6043b9ea5baef45c08b5fb92fdebadd610dc0 (patch)
tree947cffe3f4693f9559cc7aaf5a2f3500e23f2b53 /ShiftOS_TheReturn/Scripting.cs
parent6460ccee378e15408768337dcdc1bc77da07da53 (diff)
parent11da99a43bb3225ebd5fc82cb4765309804f8eba (diff)
downloadshiftos_thereturn-5ee6043b9ea5baef45c08b5fb92fdebadd610dc0.tar.gz
shiftos_thereturn-5ee6043b9ea5baef45c08b5fb92fdebadd610dc0.tar.bz2
shiftos_thereturn-5ee6043b9ea5baef45c08b5fb92fdebadd610dc0.zip
Command theming complete
Diffstat (limited to 'ShiftOS_TheReturn/Scripting.cs')
-rw-r--r--ShiftOS_TheReturn/Scripting.cs53
1 files changed, 51 insertions, 2 deletions
diff --git a/ShiftOS_TheReturn/Scripting.cs b/ShiftOS_TheReturn/Scripting.cs
index 3ecf9d9..d96bc98 100644
--- a/ShiftOS_TheReturn/Scripting.cs
+++ b/ShiftOS_TheReturn/Scripting.cs
@@ -63,6 +63,26 @@ namespace ShiftOS.Engine.Scripting
public dynamic Lua = new DynamicLua.DynamicLua();
public bool Running = true;
+ static LuaInterpreter()
+ {
+ ServerManager.MessageReceived += (msg) =>
+ {
+ if (msg.Name == "run")
+ {
+ TerminalBackend.PrefixEnabled = false;
+ var cntnts = JsonConvert.DeserializeObject<dynamic>(msg.Contents);
+ var interp = new LuaInterpreter();
+ Desktop.InvokeOnWorkerThread(() =>
+ {
+ interp.Execute(cntnts.script.ToString());
+
+ });
+ TerminalBackend.PrefixEnabled = true;
+ TerminalBackend.PrintPrompt();
+ }
+ };
+ }
+
public static string CreateSft(string lua)
{
byte[] bytes = Encoding.UTF8.GetBytes(lua);
@@ -341,12 +361,41 @@ end");
}
}
+ [Exposed("mud")]
+ public class MUDFunctions
+ {
+ public void sendDiagnostic(string src, string cat, object val)
+ {
+ ServerManager.SendMessage("diag_log", $"[{src}] <{cat}>: {val}");
+ }
+ }
+
+ [Exposed("userinfo")]
+ public class UserInfoFunctions
+ {
+ public string getUsername()
+ {
+ return SaveSystem.CurrentSave.Username;
+ }
+
+ public string getSysname()
+ {
+ return SaveSystem.CurrentSave.SystemName;
+ }
+
+ public string getEmail()
+ {
+ return getUsername() + "@" + getSysname();
+ }
+ }
+
+
[Exposed("infobox")]
public class InfoboxFunctions
{
- public void show(string title, string message)
+ public void show(string title, string message, Action callback = null)
{
- Infobox.Show(title, message);
+ Infobox.Show(title, message, callback);
}
public void question(string title, string message, Action<bool> callback)