OpenSim Scripting Languages: LSL and OSSL | Justincc's ...
OpenSim Scripting Languages: LSL and OSSL | Justincc's ...
OpenSim Scripting Languages: LSL and OSSL | Justincc's ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>OpenSim</strong> <strong>Scripting</strong> <strong>Languages</strong>: <strong>LSL</strong> <strong>and</strong> <strong>OSSL</strong> | <strong>Justincc's</strong> <strong>OpenSim</strong>ulat...http://justincc.org/blog/2008/10/24/opensim-scripting-languages-lsl-<strong>and</strong>-...2 of 8 6/30/2012 9:48 PMAugust 2010July 2010June 2010May 2010April 2010March 2010February 2010January 2010December 2009November 2009October 2009September 2009August 2009July 2009June 2009May 2009April 2009March 2009February 2009January 2009December 2008November 2008October 2008September 2008August 2008July 2008June 2008May 2008April 2008<strong>OpenSim</strong> <strong>Scripting</strong> <strong>Languages</strong>: <strong>LSL</strong> <strong>and</strong><strong>OSSL</strong>October 24, 2008By justinccIntroductionDespite our long term desire to see <strong>OpenSim</strong> become a general virtual environmentplatform, implementing all the functions in the Linden <strong>Scripting</strong> Language (<strong>LSL</strong>) for theSecond Life environment has become one of our de facto aims. This is veryunderst<strong>and</strong>able for two reasons1. There is a large stock of Second Life scripts already written in <strong>LSL</strong>. The moreaccurately our implementation of <strong>LSL</strong>, the easier it is to reuse that existing code.2. The syntax <strong>and</strong> ll functions of <strong>LSL</strong> effectively constitute a language specification.This allows lots of different open source contributors to work in ‘bazaar‘ fashion.Many different people can contribute patches that implement ll functionspiecemeal, with no need to co-ordinate their efforts with other open sourcecontributors.However, <strong>LSL</strong> is imperfect. Leaving aside any questions about the inconsistency ofLinden Lab’s ll function implementations or the deficiencies of the language itself, there
<strong>OpenSim</strong> <strong>Scripting</strong> <strong>Languages</strong>: <strong>LSL</strong> <strong>and</strong> <strong>OSSL</strong> | <strong>Justincc's</strong> <strong>OpenSim</strong>ulat...http://justincc.org/blog/2008/10/24/opensim-scripting-languages-lsl-<strong>and</strong>-...3 of 8 6/30/2012 9:48 PMis also a lot of missing functionality. For instance, in <strong>LSL</strong> one cannot teleport an agent(instead various imperfect workarounds have to be used). Neither can one write data tonotecards, or find out information about avatar group roles.<strong>OpenSim</strong>ulator <strong>Scripting</strong> Language (<strong>OSSL</strong>)How could the problem of missing functionality be addressed? If we leave aside theprospect of using completely different languages with their own functionimplementations (C#, Python, etc.), one way to do it is to extend <strong>LSL</strong> by adding extrafunctions that <strong>OpenSim</strong> underst<strong>and</strong>s. This is what the <strong>OpenSim</strong>ulator <strong>Scripting</strong>Language (<strong>OSSL</strong>) is. It is effectively all of <strong>LSL</strong> plus extra functions that start with an osprefix. os functions can be used in a script in exactly the same way as ll functions areused. Examples of os functions areosTeleportAgent() allows you to teleport an agent to another position <strong>and</strong> region.osSetDynamicTextureURL() allows you to display an external or dynamicallygenerated image inworld (as used in this inworld webpage display script or myown ‘graffiti board’ script that displays text on a single texture in-world.osParseJSON() allows you to parse JSON within a script. This isn’t such a goodexample as the HashTable return type probably makes it unusable currently in <strong>LSL</strong>scripts (the example here is a script in compiled C#). However, I think it could beextended to return a data structure that could be used in <strong>LSL</strong>.How to implement an <strong>OSSL</strong> functionImplementing an <strong>OSSL</strong> function is a little fiddly – you need to make changes in 3 places.First, let’s do the actual implementation itself. Just as there exists an <strong>LSL</strong>_Api class inthe <strong>OpenSim</strong>.Region.ScriptEngine.Shared.Api package that implements all the <strong>LSL</strong>functions, so there is an <strong>OSSL</strong>_Api class that implements <strong>OSSL</strong> functions. Toimplement a new function, one would add a method with the same name in<strong>OSSL</strong>_Api.cs. For examplepublic string osMyFunction(){// We'll talk about this in the next sectionCheckThreatLevel(ThreatLevel.None, "osMyFunction");// Let stats know that a script line has been executedm_host.AddScriptLPS(1);}return "Hello World!";The method signature for this implementation needs to be added to the interfaceIOOSL_Api in <strong>OpenSim</strong>.Region.ScriptEngine.Shared (Api/Interface directory)string osMyFunction();Finally, a method to call the function via this interface must be added to theScriptBaseClass (which underlies all <strong>LSL</strong> <strong>and</strong> <strong>OSSL</strong> scripts) in the <strong>OSSL</strong>_Stub.cs file inpackage <strong>OpenSim</strong>.Region.ScriptEngine.Shared.Api.Runtime.public string osMyFunction(){return m_<strong>OSSL</strong>_Functions.osMyFunction();}Then it’s a case of recompiling <strong>OpenSim</strong> <strong>and</strong> restarting the region server. Before yourestart, make sure thatAllowOSFunctions = trueis set in your <strong>OpenSim</strong>.ini. If this isn’t set then no os function will run no matter whatthreat level is set (as discussed below).Once you’ve restarted <strong>OpenSim</strong>, you can invoke osMyFunction() in an in-world scriptdefault{state_entry(){llSay(0, osMyFunction());}}
<strong>OpenSim</strong> <strong>Scripting</strong> <strong>Languages</strong>: <strong>LSL</strong> <strong>and</strong> <strong>OSSL</strong> | <strong>Justincc's</strong> <strong>OpenSim</strong>ulat...http://justincc.org/blog/2008/10/24/opensim-scripting-languages-lsl-<strong>and</strong>-...5 of 8 6/30/2012 9:48 PM5.justincc on January 23, 2009 at 3:56 pm<strong>OSSL</strong>_Api.cs is actually in the source code at <strong>OpenSim</strong>/Region/ScriptEngine/Shared/Api/Implementation/<strong>OSSL</strong>_Api.csAs you pointed out to me by e-mail, this is a list of functions at http://opensimulator.org/wiki/<strong>OSSL</strong>_Implemented6.Ai Austin on January 23, 2009 at 9:40 pmAh, thanks Justin. You blog here also says you can individually enable/dispableosFunctions… is that mutually separate to setting the threat level, <strong>and</strong> where can you doit – is it in opensim.ini?If I want to say allow 3 specific osFunctions <strong>and</strong> no others, wehatever their threat level,how is that done?7.justincc on January 25, 2009 at 5:59 pmYes, I see this isn’t documented very well – there isn’t even anything in<strong>OpenSim</strong>.ini.example for this. There might be something on the wiki but I don’t knowwhere. A link would be appreciated if you can find one.From reading the code, it looks like a setting in <strong>OpenSim</strong>.ini in the [XEngine] or[ScriptEngine.DotNetEngine] sections such asAllow_osTeleportAgent = truewould allow it for everybody no matter what threat level threshold was set (<strong>and</strong> as long asthe general AllowOSFunctions switch is true).On the other h<strong>and</strong>, it looks like one can also supply a list of UUIDs for users so that onlyscripts owned by that user can execute that function. For instance,Allow_osTeleportAgent = 36bff189-1a29-41dd-aeaa-81139148ec08would allow only scripts owned by the user denoted by uuid 36bff189-1a29-41ddaeaa-81139148ec08to execute osTeleportAgent().8.Ai Austin on January 25, 2009 at 10:48 pmThanks, I will test with that.Can yo tell if the default for AllowOSFunctions is false as I suspect? If so we should getthe opensim.ini.example file amended… it current states the default is true. Can youcheck <strong>and</strong> make that change to get everything in sync as a developper Justin?Also, it would be great to get the osSetDynamicTextureData full function set documentedon the Wiki, <strong>and</strong> the 2 examples in the distrtibution lined explicity to the Wiki page so allthe xanmplesa are available to a wilki broswer.9.Ai Austin on January 26, 2009 at 11:22 amI found that the list of osSetDynamic TextureData functions is available athttp://opensimulator.org/wiki/<strong>OSSL</strong>_TextureDrawingThough te 3example is a C# one which I am not sure how to compile as I haveDotNetEngione enabed.I added the function list as a link inhttp://opensimulator.org/wiki/<strong>OSSL</strong>_Implemented
<strong>OpenSim</strong> <strong>Scripting</strong> <strong>Languages</strong>: <strong>LSL</strong> <strong>and</strong> <strong>OSSL</strong> | <strong>Justincc's</strong> <strong>OpenSim</strong>ulat...http://justincc.org/blog/2008/10/24/opensim-scripting-languages-lsl-<strong>and</strong>-...6 of 8 6/30/2012 9:48 PMThe Opensim Wiki is difficult to fund one way round.10.justincc on January 30, 2009 at 9:09 pmI correct the information in <strong>OpenSim</strong>.ini.example about AllowOSFunctions in r8184.Filling out the functions I’m afraid I will have to leave to somebody else, since I have toprioritize my (always) limited timeYou might be somewhat disturbed to know that while looking for the os functions page inthe wiki, I came across another one athttp://opensimulator.org/wiki/<strong>LSL</strong>_osFunctionsThis should really be amalgamated withhttp://opensimulator.org/wiki/<strong>OSSL</strong>_Implemented11.justincc on January 30, 2009 at 10:04 pmOops my mistake. The stuff on http://opensimulator.org/wiki/<strong>LSL</strong>_osFunctions is largelysuggestions for functions, not actually implemented ones.12.Nolo on February 7, 2009 at 8:23 pmI felt compelled to second the notion of Ai @ #8.“Also, it would be great to get the osSetDynamicTextureData full function setdocumented on the Wiki, <strong>and</strong> the 2 examples in the distrtibution lined explicity to theWiki page so all the xanmplesa are available to a wilki broswer.”I underst<strong>and</strong> that it’s difficult to ask for such things <strong>and</strong> to do so leans toward optimism,but ANY help in the area of documentation would greatly serve /everybody’s/ cause todate. Calling all units – rapid fire reporting needed on site! I tend to border on theinsane though…13.justincc on February 8, 2009 at 6:53 pm@Nolo. Oh, I do agree, proper documentation would be very nice. Unfortunately, itseems that my fellow developers don’t always agree with me – hopefully this is an area inwhich we will improve as <strong>OpenSim</strong> matures.Actually, I believe that osSetDynamicTextureData is only a thin wrapper around a .NETlibrary function for drawing lines, text, etc. dynamically on a surface. So if one were tohunt that down in the .NET SDK documentation that might provide all the informationthat you need.14.Stefanie on June 3, 2010 at 4:40 pmthanks for providing this description, but how to implement events in <strong>OSSL</strong>?15.justincc on June 14, 2010 at 11:13 pmHi Stefanie. Unfortunately, I suspect that there’s no easy way to provide custom events in<strong>OSSL</strong> at this time without changing a lot of core <strong>OpenSim</strong> code.16.David on August 10, 2010 at 8:34 pm
<strong>OpenSim</strong> <strong>Scripting</strong> <strong>Languages</strong>: <strong>LSL</strong> <strong>and</strong> <strong>OSSL</strong> | <strong>Justincc's</strong> <strong>OpenSim</strong>ulat...http://justincc.org/blog/2008/10/24/opensim-scripting-languages-lsl-<strong>and</strong>-...7 of 8 6/30/2012 9:48 PMGreat!!! Worked just fine. Recompiled with VS# 2008 Express, I’m testing my ownosFunctions on my St<strong>and</strong>alone region an all it´s ok!!Thanks17.AdelleF on October 22, 2010 at 11:45 pm18.Thanks for this Justin, it was a great help in my getting started with programming<strong>OpenSim</strong><strong>OpenSim</strong>ulator <strong>Scripting</strong> Language (OOSL) <strong>and</strong> Linden <strong>Scripting</strong> Language (<strong>LSL</strong>) « TheEducational Technologist on September 6, 2011 at 12:19 am[...] http://justincc.org/blog/2008/10/24/opensim-scripting-languages-lsl-<strong>and</strong>-ossl/ SimOn A Stick [...]Leave a ReplyYour email address will not be published. Required fields are marked *Name *Email *WebsiteABOUT MEHi, I'm Justin Clark-Casey, an <strong>OpenSim</strong> coredeveloper <strong>and</strong>professional softwareengineer.On the Linden Lab gridI go by the name ofLulworth Beaumont. Onother grids I'm just plainold Justin Clark-Casey.I'm currently working asa freelance consultantspecializing in<strong>OpenSim</strong>ulator <strong>and</strong>related technologies. Ifyou're interested inlearning more thenplease read the Hire Mepage.I've also written a paperon distributed virtualenvironments, whichexamines how virtualworlds could becomemore like the web,rather than individualsilos of users <strong>and</strong>content.
<strong>OpenSim</strong> <strong>Scripting</strong> <strong>Languages</strong>: <strong>LSL</strong> <strong>and</strong> <strong>OSSL</strong> | <strong>Justincc's</strong> <strong>OpenSim</strong>ulat...http://justincc.org/blog/2008/10/24/opensim-scripting-languages-lsl-<strong>and</strong>-...8 of 8 6/30/2012 9:48 PMI often attend the<strong>OpenSim</strong> Office Hourson a Tuesday on WrightPlaza at OSgrid.orgMetaLog inEntries RSSComments RSSWordPress.orgBlogroll@jusincc onGitHub@justincc onLinked In@justincc onTwitterBlueWall's blogDiva Canto's blogEner Hax's blogHypergridBusinessKitelyMOSES<strong>OpenSim</strong>ulatorOSgridScienceSimCopyright © 2012 <strong>Justincc's</strong> <strong>OpenSim</strong>ulator blog. All Rights Reserved.Magazine Basic theme designed by Themes by bavotasan.com.Powered by WordPress.