aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world
diff options
context:
space:
mode:
authorMW2007-04-03 18:15:11 +0000
committerMW2007-04-03 18:15:11 +0000
commit9b2a4e81722d49ddb6552e279c355e13b8ed2b63 (patch)
tree3ae67590a4a674e967c5ebd943fd05f769a74397 /OpenSim.RegionServer/world
parent* added script prototype intructions (diff)
downloadopensim-SC-9b2a4e81722d49ddb6552e279c355e13b8ed2b63.zip
opensim-SC-9b2a4e81722d49ddb6552e279c355e13b8ed2b63.tar.gz
opensim-SC-9b2a4e81722d49ddb6552e279c355e13b8ed2b63.tar.bz2
opensim-SC-9b2a4e81722d49ddb6552e279c355e13b8ed2b63.tar.xz
Added easier way to add "scripts" to prims: to add Libsa71's test script, create a new note and delete the contents of the created note and then add "<Script>Test</Script>" (without the quotes) , then save that and then drag it from your inventory to the prim you want to add the script to.
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/world/World.cs63
1 files changed, 62 insertions, 1 deletions
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index 6bc485f..408f68d 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -32,18 +32,20 @@ namespace OpenSim.world
32 private int storageCount; 32 private int storageCount;
33 private Dictionary<uint, SimClient> m_clientThreads; 33 private Dictionary<uint, SimClient> m_clientThreads;
34 private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers; 34 private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers;
35 private Dictionary<string, Script> m_scripts;
35 private ulong m_regionHandle; 36 private ulong m_regionHandle;
36 private string m_regionName; 37 private string m_regionName;
37 private InventoryCache _inventoryCache; 38 private InventoryCache _inventoryCache;
38 private AssetCache _assetCache; 39 private AssetCache _assetCache;
39 40
40 public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName) 41 public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName)
41 { 42 {
42 m_clientThreads = clientThreads; 43 m_clientThreads = clientThreads;
43 m_regionHandle = regionHandle; 44 m_regionHandle = regionHandle;
44 m_regionName = regionName; 45 m_regionName = regionName;
45 46
46 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>(); 47 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
48 m_scripts = new Dictionary<string, Script>();
47 49
48 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); 50 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
49 Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); 51 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
@@ -55,6 +57,7 @@ namespace OpenSim.world
55 // Initialise this only after the world has loaded 57 // Initialise this only after the world has loaded
56 // Scripts = new ScriptEngine(this); 58 // Scripts = new ScriptEngine(this);
57 Avatar.LoadAnims(); 59 Avatar.LoadAnims();
60 this.SetDefaultScripts();
58 } 61 }
59 62
60 public void AddScript(Entity entity, Script script) 63 public void AddScript(Entity entity, Script script)
@@ -63,6 +66,37 @@ namespace OpenSim.world
63 m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler); 66 m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler);
64 } 67 }
65 68
69 public void AddScript(Entity entity, string scriptData)
70 {
71 int scriptstart = 0;
72 int scriptend = 0;
73 string substring;
74 scriptstart = scriptData.LastIndexOf("<Script>");
75 scriptend = scriptData.LastIndexOf("</Script>");
76 substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8);
77 substring = substring.Trim();
78 Console.WriteLine("searching for script to add: " + substring);
79 if (this.m_scripts.ContainsKey(substring))
80 {
81 Console.WriteLine("added script");
82 this.AddScript(entity, this.m_scripts[substring]);
83 }
84 /*string delimStr = " ";
85 char[] delimiter = delimStr.ToCharArray();
86 string[] line;
87 line = scriptData.Split(delimiter);
88 if (line.Length > 1)
89 {
90 if (line[0] == "script:")
91 {
92 if (this.m_scripts.ContainsKey(line[1]))
93 {
94 this.AddScript(entity, this.m_scripts[line[1]]);
95 }
96 }
97 }*/
98 }
99
66 public InventoryCache InventoryCache 100 public InventoryCache InventoryCache
67 { 101 {
68 set 102 set
@@ -521,6 +555,33 @@ namespace OpenSim.world
521 return true; 555 return true;
522 } 556 }
523 557
558 public void SetDefaultScripts()
559 {
560 this.m_scripts.Add("Test", new TestScript1());
561 }
562
524 #endregion 563 #endregion
525 } 564 }
565
566 public class TestScript1 : Script
567 {
568 int toggle = 0;
569
570 public TestScript1()
571 : base(LLUUID.Random())
572 {
573 OnFrame += MyOnFrame;
574 }
575
576 private void MyOnFrame(IScriptContext context)
577 {
578 toggle = 2 - toggle;
579
580 LLVector3 pos = context.GetPos();
581
582 pos.X += (toggle - 1);
583
584 context.MoveTo(pos);
585 }
586 }
526} 587}