public static void SetField(string[] args) { if (args.Length != 3) { Log.WriteLine("Expected field name, instance ref (uuid or path), and value"); return; } object instanceRef; ulong id = ulong.MaxValue; if (ulong.TryParse(args[1], out id)) { instanceRef = SceneTree.GetCurrent().GetNode(id); } else { instanceRef = SceneTree.GetCurrent().GetNode(args[1]); } if (instanceRef == null) { Log.WriteError("Could not find node by " + (id == ulong.MaxValue ? "name" : "id") + " '" + args[1] + "'"); return; } string objectName = instanceRef.GetType().Name; objectName = objectName.Remove(0, objectName.LastIndexOf('.') + 1); ObjectDatabase.Global.SetField(objectName, args[0], instanceRef, args[2]); Log.WriteLine(args[1] + "." + args[0] + ": value=" + args[2]); }
public static void GetField(string[] args) { if (args.Length != 2) { Log.WriteError("Expected field name, instance ref (uuid or path)"); return; } object instanceRef; ulong id = ulong.MaxValue; if (ulong.TryParse(args[1], out id)) { instanceRef = SceneTree.GetCurrent().GetNode(id); } else { instanceRef = SceneTree.GetCurrent().GetNode(args[1]); } if (instanceRef == null) { Log.WriteError("Could not find node by " + (id == ulong.MaxValue ? "name" : "id") + " '" + args[1] + "'"); return; } string objectName = instanceRef.GetType().Name; objectName = objectName.Remove(0, objectName.LastIndexOf('.') + 1); object fieldValue = ObjectDatabase.Global.GetField("SceneNode", args[0], instanceRef); string line = args[1] + "." + args[0] + ": value="; if (fieldValue == null) { line += "null"; } else { line += fieldValue.ToString(); } Log.WriteLine(line); }