aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--LuaSL/src/LuaSL_main.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/LuaSL/src/LuaSL_main.c b/LuaSL/src/LuaSL_main.c
index 1056535..d25457d 100644
--- a/LuaSL/src/LuaSL_main.c
+++ b/LuaSL/src/LuaSL_main.c
@@ -313,6 +313,123 @@ void runLuaFile(gameGlobals *game, const char *filename)
313 * There is also an asset UUID (the one printed out on the console at script startup time) that points to the source code in the prim. 313 * There is also an asset UUID (the one printed out on the console at script startup time) that points to the source code in the prim.
314 * Which will be identical to the asset UUID for the multiple copies of the same script. 314 * Which will be identical to the asset UUID for the multiple copies of the same script.
315 * 315 *
316 * script assetID
317 * UUID of the script source in the grids asset database, also the script source in the prim.
318 *
319 * script itemID
320 * UUID of this instance of the running script.
321 * UUID of the scripts binary in the prims inventory.
322 * This is the one used to identify the running script.
323 *
324 * prim uint localID
325 * Some sort of number representing the prim the script is running in.
326 * Events are sometimes sent to this.
327 *
328 * path/filename
329 * An invention of LuaSL, coz we store stuff as files.
330 *
331 * OpenSim says "compile this assetID for this itemID, in this prim uint"
332 * Current infrastructure does not allow easy sending of the script source, but we don't have ROBUST code to get it either.
333 * ROBUST is the way to go though, coz we can sneakily start to suck other stuff, like prim contents across when needed.
334 * Though that sort of thing needs access to the local sim databases to lookup the prim and it's other contents. sigh
335 * I think that new script and notecard contents get new assetIDs anyway, so keeping an eye on assets.create_time or asset_access_time wont help much.
336 *
337 * OpenSim says "start / stop this itemID"
338 * Already catered for.
339 *
340 * What does OpenSim REALLY do?
341 *
342 * Region/Framework/Scenes/Scene.Inventory.cs - CapsUpdateTaskInventoryScriptAsset(IClientAPI remoteClient, UUID itemId, UUID primId, bool isScriptRunning, byte[] data)
343 * remoteClient
344 * itemID - UUID of the script source.
345 * primID - UUID of the prim it is in.
346 * isScriptRunning
347 * data - the script source code.
348 * Called when a user saves the script. itemID stays the same, but we get a new assetID, for the new asset.
349 * Looks up the item in the prim.
350 * AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
351 * AssetService.Store(asset);
352 * stashes the new assetID in the item
353 * updates the item in the prim
354 * if (isScriptRunning)
355 * part.Inventory.RemoveScriptInstance(item.ItemID, false);
356 * part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0);
357 * errors = part.Inventory.GetScriptErrors(item.ItemID);
358 *
359 * CreateScriptInstance() is generally called to start scripts, part.ParentGroup.ResumeScripts(); is usually called after CreateScriptInstance()
360 *
361 * Region/Framework/Scenes/SceneObjectPartInventory.cs - CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
362 * looks up the itemID, then calls the real one -
363 * Region/Framework/Scenes/SceneObjectPartInventory.cs - CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
364 * get the asset from the asset database using the items assetID
365 * restores script state if needed
366 * converts asset.data to a string called script
367 * m_part.ParentGroup.Scene.EventManager.TriggerRezScript(m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
368 * QUIRK - if it's a sim border crossing, TriggerRezScript() gets called with empty script source.
369 *
370 * Region/ScriptEngine/XEngine/XEngine.cs - AddRegion(Scene scene)
371 * m_log.InfoFormat("[XEngine] Initializing scripts in region {0}", scene.RegionInfo.RegionName);
372 * gets the script config info, which is the same damn stuff for each sim. Pffft
373 * Think it relies on the scenes event manager to call OnRezScript() -
374 * m_Scene.EventManager.OnRezScript += OnRezScript;
375 *
376 * Region/Framework/Scenes/EventManager.cs - TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
377 * Loops through Scene.EventManager.OnRezScript calling them.
378 *
379 * Region/ScriptEngine/XEngine/XEngine.cs - OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
380 * Looks at the script source to figure out if it's an XEngine script.
381 * Either queues the script for later, or does it direct.
382 * Region/ScriptEngine/XEngine/XEngine.cs - DoOnRezScript() is passed an array holding -
383 * localID is a uint that represents the containing prim in the current scene
384 * itemID is the UUID of the script in the prims contents
385 * script is the script source code.
386 * startParam is the scripts startParam
387 * postOnRez
388 * stateSource is an integer saying how we where started, used to trigger the appropriate startup events.
389 * uses localID to look up the prim in the scene, then looks inside that for the itemID to find the assetID.
390 * m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
391 * Which is in Region/ScriptEngine/Shared/CodeTools/Compiler.cs
392 * instance = new ScriptInstance(this, part, itemID, assetID, assembly, m_AppDomains[appDomain], part.ParentGroup.RootPart.Name, item.Name, startParam, postOnRez, stateSource, m_MaxScriptQueue);
393 * Region/ScriptEngine/Shared/Instance/ScriptInstance.cs - ScriptInstance(IScriptEngine engine, SceneObjectPart part, UUID itemID, UUID assetID, string assembly, AppDomain dom, string primName, string scriptName, int startParam, bool postOnRez, StateSource stateSource, int maxScriptQueue)
394 * inits all the APIs
395 * loads in any saved state if it can find one
396 * m_log.DebugFormat("[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
397 *
398 * Soooo, when a script is saved -
399 * the new source is saved in the asset database
400 * The script item in the prim gets the new assetID
401 * if the script is running -
402 * remove the old script instance (item.ItemID)
403 * create a new one (item.ItemID)
404 * get the source code from the asset database (item.assetID)
405 * restore script state
406 * TriggerRezOnScript()
407 * Loop through all those that are interested, incuding XEngine.onRezScript()
408 *** check the first line to see if it's an XEngine script
409 * sooner or later passes it to XEngine.DoOnRezScript()
410 * looks up localID to get the prim
411 * looks inside prim to get the script from itemID
412 * gets the assetID from the script item
413 * compiles the script
414 * creates the script instance
415 * loads up the APIs
416 * restores any script state
417 * calls instance.Init() which is Region/ScriptEngine/Shared/Instance/ScriptInstance.cs - Init()
418 * passes the usual startup events to the script.
419 * part.ParentGroup.ResumeScripts()
420 *
421 * At the *** marked point, LuaSL.onRezScript should -
422 * check the first line to see if it's an LuaSL script
423 * looks up localID to get the prim
424 * looks inside prim to get the script from itemID
425 * gets the assetID from the script item
426 * filename encode the sim name, object name, and script name
427 * replace anything less than 0x21, DEL " * / : < > ? \ | + [ ] - , . ( ) $ % # @ from - http://en.wikipedia.org/wiki/Filename plus a few more
428 * THEN reduce to 254 characters
429 * write the script to a file - /script/engine/path/sim_name/objects/object_name/script_name
430 * send the itemID.compile(/script/engine/path/sim_name/objects/object_name/script_name) message to the script engine's socket
431 *
432 *
316 * Object inventory "cache". 433 * Object inventory "cache".
317 * 434 *
318 * This code currently pretends that there is a local file based sim object store available. 435 * This code currently pretends that there is a local file based sim object store available.