OSSL Proposals

From OpenSimulator

Jump to: navigation, search

What is OSSL?


This is a page dedicated to OpenSim's very own home brew custom scripting language Known as "Open Sim Scripting Language"

Please see OSSL Standards for proposed naming schema

  • Please post your osFunction along with a brief description of what it would be for, or do and an example of it.
  • Make sure it begins with os NOT ll.
  • And remember, almost anything within reason can be posted here as an idea, who knows, maybe a variation of your request can be possible.
  • If a function could implemented in standard LSL, there is no reason to make an OS function. LSL code and function code executes at the same speed in OpenSimulator.
  • Post your proposal to the opensim-dev mailing list so that it can be discussed to see if there is any interest. Please indicate if you are willing to implement it yourself - such proposals have a much better chance of succeeding!

OSSL Proposal Table

osFunction Description Example Usage Signed
key osSetHTTPURL(string url); Sets the prim to a private HTTP:// url for use by this script. The http_request() event would be

triggered & the prim would serve as a "prim-server" for the private HTTP:// url. Also Returns a key that is the handle used for identifying the result in the http_request event.

string private_url = "http://thisprivatedomain.com/index.php"
    http_request(key request_id, string method, string body)
    if(method == "POST")
    osHTTPResponse(request_id,200,"Your $_POST was successful");
    else if(method == "GET")
    osHTTPResponse(request_id,200,"Wait for the server to handle your request");
Apollo Juez
list osGetRegionAgentKeys(); C# Code:
public LSL_List osGetRegionAgentKeys()
           CheckThreatLevel(ThreatLevel.None, "osGetRegionAgentKeys");
           LSL_List result = new LSL_List();
           foreach (ScenePresence avatar in World.GetAvatars())
           return result;

Returns a list of keys for every agent in the region

list keys=osGetRegionAgentKeys(); 
integer i;
integer l=llGetListLength(keys); 
string names; for(i=0;i<l;i++) 
   { key id=llList2Key(keys,i); 
      string add=llKey2Name(id); 
      integer dist=llVecDist(llGetPos(),llList2Vector(llGetObjectDetails(id,[OBJECT_POS]),0)));
   } llSetText(names,<1,1,1>,1.0);
Joshua Driver
[NEW] various os functions including osDerezObject(), osMessageAgentAttachment(), ... see User:Athlon_Maurer for full source code tested on local opensimulator 0.6.9 (some of them doesnt seem to work on 0.7.x) Athlon Maurer
string osBin(string char); To convert a char into its binary value. Will only convert 1 char at a time. string bin_a = osBin("A"); // bin_a = "01000001"; Athlon Maurer (please send me a notecard into secondlife, if that are too much ideas xD, this hint can be deleted by an opensimulator admin, if neccesary xD)
string osHex(integer number); To convert a number into its hexadecimal value. string str_ff = osHex(255); // str_ff = "FF"; Athlon Maurer
integer osAsc(string char); To convert a char into its ascii index. Will only convert 1 char at a time. integer asc_a = osAsc("A"); // asc_a = 65; Athlon Maurer
void osScanRegionRemove(); Remove an osScanRegionRepeat(). [ nearly the same as llSensorRemove() ] osScanRegionRemove(); Athlon Maurer
void osScanRegion(string name, key id, integer type); Scan the whole region where the script task object is in regardless where it is positioned. Triggers sensor() or no_sensor(). osScanRegion("", "", AGENT); Athlon Maurer
void osScanRegionRepeat(string name, key id, integer type, float rate); Scan the whole region where the script task object is in regardless where it is positioned with rate. Triggers sensor() or no_sensor(). osScanRegionRepeat("", "", AGENT, 15.0); Athlon Maurer
key osGetRegionMapTexture(string RegionName) return the map texture uuid for the region named by RegionName. llSetTexture(osGetRegionMapTexture("OpenSimulator Test"), ALL_SIDES);

<math> create a php file which is public <?php


// mapquery.php by Athlon Maurer (SL, OL, OS) // // hello, ive just started to learn php/mysql and this is one of my first // scripts for opensim. this script returns the texture uuid for a given // region by calling: mapquery.php?region=REGIONNAME // if a region has been found, it returns that regions map texture uuid, // otherwise it returns a null key uuid // mysql connection info is here, please make this more safe

// region name (do not change this)

$region = htmlspecialchars($_GET['region']);

// default uuid (do not change this)

$uuid = '00000000-0000-0000-0000-000000000000';

// your mysql host name (change this)

$dbhost = 'localhost';

// your mysql user name (change this)

$dbuser = 'root';

// your mysql user password (change this)

$dbpass = ;

// your mysql opensim database (change this)

$dbname = 'opensim';

// try to connect

if ($conn = mysql_connect($dbhost, $dbuser, $dbpass)) { // try to select if ($select = mysql_select_db($dbname, $conn)) { $sql = 'SELECT regionName, regionMapTexture FROM regions'; $result = mysql_query($sql); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if ($row['regionName'] == $region) { $uuid = $row['regionMapTexture']; } } // free result mysql_free_result($result); } // close connection mysql_close($conn); } // output echo $uuid;


then llHTTPRequest(</math>

Athlon Maurer (This function is available as of November 12, 2009)
list osGetLinkPrimitiveParams(integer link, list params); Function llSetLinkPrimitiveParams() does exist, but no chance to get params from a prim in a linkset, like llGetPrimitiveParams() and llSetPrimitiveParams(). list linkparams = osGetLinkPrimitiveParams([PRIM_TYPE, PRIM_TEXTURE, ...]); Athlon Maurer (This function is available as of August 09, 2009)
void osDerezObject(key object) Deletes an InWorld-Object specified by object as uuid. Only successful if the object the script is attached to and the object which should be derezzed is owned by the same owner :). Useful if the object to be deleted should be unscripted. osDerezObject("key_of_object"); Athlon Maurer
int osRestartRegion() Restarts the region the script is currently in. The script this is run in has to be owned by the master avatar for that region. Returns 1 if the region is restarting, 0 on failure. osRestartRegion(); gryc (Implemented by AFrisby)
int osWebTexture() Sets the texture from a web-url osWebTexture(string url,integer maptype); AFrisby?
osGroupAdd(key, string Role) Adds user to a group with given role, default role Everyone. Returns 1 if successful 0 if fail. osGroupAdd(87f6e6a0-d884-11dc-95ff-0800200c9a66, "Officer") Nitrus Nori
int osShutdownRegion() Shuts down the region the script is currently in. The script this is run in has to be owned by the master avatar for that region. Returns 1 if the region is going down, 0 on failure. osShutdownRegion(); gryc
void osAttachmentSay(integer channel, string msg) Provide a secure, low lag method of communicating between attachments over the chat channels by only sending messages to objects attached to the same avatar. Would fail (or not be heard) if in a non-attached object. osAttachmentSay(-20, "detatch"); Del M
void osMessageSecure(string message_key, string str, integer num, key id);
secure_message(string message_key, string str, integer num, key id);
Provide a method of sending secure, salt encripted messages sim wide. Messages would only be able to be received by scripts with the matching key in the secure_message method. osMessageSecure("myPassPhrase", "Hello World", 0, NULL_KEY); Del M
void osSetText( vector color, string text [,vector color, string text]); Allow setting of multiple colors on the prim text osSetText(<1,0,0>,"Red", <0,1,0>, "\nGreen", <0,0,1>, "\nBlue"); Del M
osSensor Gets ALL the objects in the specified range not just the first 16 (same as standard) Sal
list lst=osDetectObjectsInSim(key id) given an Agent Key, provide a list of ALL object owned by that agent osDetectObjectsInSim(key id) returning a strided list of [ name, <pos> ] Sal
integer=osDialog([ title, label1, type1, len1, label2, type2, len2].... given title and a listing of fields, builds up a real form where to put structured checked data will return a [ value1, value2, valuen ] corresponding to fields read. Type might be something like (string, text (multiline), integer, float, currency(decimals), options(combobox) Sal
key id=osMakeTextureText(string name,integer width, integer height,[posx1,posy1,font1,color1,size1,text1,posx2,posy2,font2,color2,size2,text2....]) allow for producing a texture on the fly with desired Font content from a selected font selection. Width, Height in pixels 1024x512 to control how big will be the texture will generate a texture with defined text. (Allow some support for at least ISO-8859-1) texture will be created in the object inventory. posx, posy in the range 0-1 to be pixel independent Sal
osMakeNotecard(string name, [ line1, line2, line3, ...]) allow creation of new notecards in current object repository generate a new asset id useful for storing modified configuration Sal
integer handler=osReadNotecardKey(string notecard, string key) allows reading notecards (through dataserver) in format key=value in convenient and efficient way ... Sal
osWriteNotecardKey(string notecard, string key,string value) allows WRITING notecards in format key=value in convenient and efficient way. Might be optimized having a fixed record length "file" so to avoid rewriting of the entire notecard ... Sal
integer handle=osXMLParser(string xml) will activate a listener xmlparser(integer handler,string parent, string field, string value) to easily parse xml without writing php external code Sal
integer osReturnObjects(key owner, integer type); Provide a scriptable method of returning objects from a sim. type would be OBJECT_SCRIPTED, OBJECT_PASSIVE or OBJECT_ALL. Would return a binary Success/Fail, and work inline with land permissions for the script owner. osReturnObjects( target, OBJECT_ALL); Del M
integer osReturnItem(key item); Provide a scriptable method of returning individual objects from a sim. Would return a binary Success/Fail, and work inline with land permissions for the script owner. osReturnItem(uuid); Del M
osSetTimerEvent(integer timer, float rate);
(event) timer(integer timer_num)
Support for multiple timers in a script. osSetTimerEvent(2, 0.5); Del M
osTimerOnce(integer timer, float rate); Allow for a one shot timer event, rather than the normal repeating heartbeat type osTimerOnce(2, 10); Del M
integer osVerifyScripts(); Check to see if all scripts in an object are created by the owner of the script calling the function. Return TRUE if they are, FALSE otherwise, to prevent insertion of alien scripts into an object if (!osVerifyScripts()) { llDie(); } Del M
void osStopOtherAnimations(list animation_exceptions); Provide a method of stopping all animations on an avatar, except those defined in the list osStopOtherAnimations(["my_sitting_anim"]); Del M
void osPutScriptInLinkedSet(string name,integer linknum, integer starting_parm, integer running) Use this to propagate one script to ALL or part of linked set. Useful to have all objects in a linked set sharing a common behaviour Sal
osRezObject(string name, string description, integer permissionmask, list setPrimitiveObjectLikeList) will trigger the object_rez object as usual similar to llRezObject, but without the need of having a prim inside the inventory (which produced a lot of problems in deploying and in sl). Newly created object will have the same owner of current object where script is running. In case list is empty or position not specified, suitable defaults should apply like pos being 1 m higher in the z axis Sal
string osGetOwnerName(); Provide a method of getting the owner name without having to use llKey2Name myName = osGetOwnerName(); Del M
integer osXMPPOpen(string server, string username, string password, string resource); Open an XMPP session to a jabber or other XMPP server, returning a handle to be able to manipulate the connection. Incoming messages to be parsed through a xmpp_message(integer handle, string sender, string service, string message) event. Accounts would have to be set up manually by the scripter, or by some other method, to prevent scripted spamming of a server, and to allow users to set up gateways and other services if needed. handle = osXMPPOpen("jabber.org", "MyObject", "MyPassword", "OpenSim"); Del M
list osXMPPGetRosta(integer handle); Get the rosta from the XMPP server, list in the strided form of [username, presence, resource]; list presence = osXMPPGetRosta(handle); Del M
list osXMPPGetServices(integer handle); Get a list of available services from the XMPP Server. list services = osXMPPGetServices(handle); Del M
integer osXMPPAdd(string username, string service) Add a username to the account rosta. Return boolean success or fail if (osXMPPAdd("Test User", "Yahoo")) { ... } Del M
integer oxXMPPDelete(string username) Remove a username from the account rosta. Return boolean success or fail if (osXMPPDelete("Test User")) { ... } Del M
integer osXMPPGetStatus(string username); Poll the server for the status of a specific username on the rosta - returns would be OFFLINE, BUSY, AWAY and ONLINE if (osXMPPGetStatus("Test User") & ONLINE) { ... } Del M
integer osXMPPSendMessage(integer handle, string message, string target); Send a message via the open XMPP channel, to the specified target. Return boolean success values if (osXMPPSendMessage(handle, "Hello World", osGetOwnerName()) { llOwnerSay("Successfully sent message"); Del M
void osXMPPClose(integer handle); Close the XMPP session osXMPPClose(); Del M
void osRezObjectKey(key object,vector pos,vector vel,rotation rot, int param); Basically llGodLikeRezObject[1] with the features of llRezObject[2] but for everyone to use. Calls object_rez. osRezObjectKey(object_key,llGetPos(),ZERO_VECTOR,llGetRot(),0); Tdub
osRezFromURL(string url, vector pos, vector vel, rotation rot, integer param) - calls on_rez Fetch a fragment of xml from a web server and rez its contents in-world as in 'load-xml'. Off or intergrid object repositories, such as objects stored in SVN via websvn, CMS, etc. osRezFromURL("http://my.objectstore.com/myawesomeprims.xml", <1, 1, 1>, <0, 0, 0>, <0, 0, 0>, 0) Jimbo2120
list osRunCustom(string function, list params) Allow scripts to call external custom routines that are grid-specific without modifying the set of LSL and OSL functions. list results = osRunCustom("function1", [...]) Ezekiel
osSetScriptServer() Create a 'Server' prim that allows for extended scripting capabilities: more memory, higher bandwidth when communicating with external servers, probably some database connectivity, no artificial delays, can receive IMs, etc. Could be limited to one server per prim / parcel or per avatar, could be forced to remain in a fixed position. A server is important for residents that want to set up a virtual business. osSetScriptServer() Ezekiel
integer osRemoteLoadScript(string url, string target) Load a source file in txt format from "URL" and compile it into script "target" in the inventory of the same prim. Requires permission of the object owner (RequestPermission). Returns boolean success value. Replaces an existing script with same name. This function would allow updates to scripted solutions that operate in any grid and sim worldwide, allowing the creator of the solution to distribute code fixes and implement new functions. Since the source code is distributed openly, it can be copied and modified by anyone. A function that would allow for secure code distribution, protecting copyrights and certificates, would also be very interesting but should be far more difficult to implement. integer updatestatus = osRemoteLoadScript("http://www.xyz.com/updates/script1013.txt", "betterscript" ) Ezekiel
integer osSetCustomPrimitiveAttributes(list params) Set some custom persistent primitive attributes, the same way as llSetPrimitiveParams do. The attribute name has to be specified as a string, then the attribute type using a lSL constant. In the example, we set a "magnet" custom attribute as -0.5, supposing a customized physic engine handles this attribute to provide prim attraction. integer osSetCustomPrimitiveAttributes(["magnet", TYPE_FLOAT, -0.5]) Grumly
list osGetCustomPrimitiveAttributes(list paramNames) Return a list values of the specified attributes names, the same way as llGetPrimitiveParams do. list osGetCustomPrimitiveAttributes(["Magnetic"]) Grumly

integer osSyncUUID(key oldUUID, key newUUID); Allows to change the UUID of an avatar or item(requires permission from owner). Suppose a terminal in the LL-grid wants to communicate with an OS-Grid terminal. It can only send messages, if the UUID's of avatars match. An OS-Grid script can get the avatar's LL-UUID by calling the dataserver script. Then it calls osSyncUUID(llDetectedKey(0), keyFromHTTPRequest); . Now the two keys are equal, and avatar-avatar communication between grids can take place! Phrearch

integer osTeleport(string RegionName, int x, int y, int z); Teleports an avatar to a custom region

as : osTeleportAgent(key agentId, string regionName, vector position, vector lookAt);

(this is implemented now - edited April 2009 by Wordfromthe Wise) Phrearch
osSetStatus(integer status, integer value); Improved verion of the LSL function llSetStatus. The function works basically the same way as llSetStatus, except that an extra flag is added named STATUS_PHYSICS_ROOT. When this flag is TRUE, physics would be enabled Only for the root prim in a linked set, while the other prims in the set would behave as phantom. This would be useful for bypassing the 32-prim physics limit for vehicles by using only the root prim as a collision mesh. Pesho
vector osGetBonePos(); When called from an Attachment, retrieves the position of the bone it is attached to, in Region Coordinates. When llGetPos() is called from an attachment, the vector returned is the one of the avatar center, whereas llGetLocalPos() returns the local offset from the bone it is attached to. It would be useful to know where the attachment's location really is in world space. Pesho
string osGetOSLLRelease(); When called return the actual release of OSSL running on the sim. if osGetOSSLRelease() > 1.1 {llSay(0,"good");} Sacha Magne
List osGetServerLib(); When called return a list of all the additional libraries loaded on the server. it will avoid any scripts using a specific library to crash in case of missing libs. List lib=osGetServerLib(); Sacha Magne
osSetAttachmentPoint(integer attachment); When called from an Attachment sets the default attachment point to attachment value. osSetAttachmentPoint(ATTACH_HUD_BOTTOM_RIGHT); Peter
string osMySQLQuery(string query); Used to get informations out of a sql database. Works together with osMySQLConnect(), osMySQLSelectDatabase() and osMySQLClose(). osMySQLQuery("Select name FROM user LIMIT 0,1;"); Peter
string osGetGridName(); When called it return the hostname of the grid server. Useful to find out what grid you are on. string gridHostname = osGetGridHostname(); Patnad
vector osParcelCenterpoint(vector pos); When called it return the vector that represent the center point of the current parcel. Same height as the object running the script but centerpoint for x,y. vector parcel_center = osParcelCenterpoint(llGetPos()); Patnad
integer osSetMapDestination(integer mode, string simname, vector position, vector lookat); Sets a new "beacon" (red pole) without opening the worldmap: mode is for 1 (simname is a standard region name) or 0 (simname is a SLURL). If the code can handle standard sim names and SLURL(s) at the same time, the "mode" flag can be left behind. integer error = osSetMapDestination(TRUE, "cyberlandia", <128.0, 128.0, 0.0>, ZERO_VECTOR);

 If error is FALSE then no errors have occurred setting up the new beacon.  Errors can arise using unknown simnames/SLURL(s), out of ranges vector coords and so on (nearly the same as llSetMapDestination).

Elwe Ewing
osTeleportAgentPerm(key agentId, string regionName, vector position, vector lookAt);

osTeleportAgentPerm(key agentId, vector position, vector lookAt);

Works similarly as the two implemented osTeleportAgent but requires (at least the first time) the PERMISSION_TELEPORT flag set (via llRequestPermissions(key id, PERMISSION_TELEPORT); which should be implemented) and can be used by everyone (or restricted to a member of the group wich the region is deed, maybe with a new "Restrict teleports" Estate flag).
// requests permission to Teleport then do it
 key  avie = NULL_KEY;
       llSay(0, "Touch to be teleported");
   run_time_permissions(integer vBitPermissions)
       if(PERMISSION_TELEPORT &amp; vBitPermissions){
           osTeleportAgentPerm(avie, &lt;128.0,128.0,0.0&gt;,
       } else {
           llSay(0, "You deny teleport permission");
   touch_start(integer num_detected)
       avie = llDetectedKey(0);
           PERMISSION_TELEPORT &#124;
       integer perm = llGetPermissions();
Elwe Ewing
osGetSimulatorStatus(string Simulator) Extended / Enhanced version of llGetSimulatorData.

Purpose: When an avatar is Teleported with osTeleportAgent, there is no check to see if a given simulator is available. If it's down, Agent is Teleported to NULL resulting in Agent being fragged and viewer broken, requiring a relog. This would be especially useful for HyperGrid Teleporting. Returns: integer "0 = DOWN", "1 = UP", "2 = UNKNOWN" Security: Would require some form of Throttle to prevent recurring requests of destination Simulator. Command: osGetSimulatorStatus(string Simulator) Where Simulator = "RegionName", "IPAddress:PortNum", "HostName:PortNum"

// CHecks if simulator is online before teleporting agent -kizmut
 string destination = "Wright Plaza";
       llSay(0, "Touch to be teleported to: "+destination);
   touch_start(integer num_detected)
       llSay(0,llDetectedName(0)+" requesting teleport to: "+destination);
       integer sim_stat = osGetSimulatorStatus(destination);
       if (sim_stat == 2) {
           llSay(0, "Could not teleport to "+destination+": Region status unknown.");
       else if (sim_stat) {
       else {
           llSay(0, "Could not teleport to "+destination+": Region is down");
WhiteStar Magic
osTeleportOwner(string regionName, vector position, vector lookAt); Works similarly as osTeleportAgent but could only teleport the owner of the script itself. Would be very useful for HUD and would not require any authorization. integer error=osTeleportOwner("Snoopies",<100,25,25>,ZERO_VECTOR); Agnes Chalet

integer osHyperGrid(); Detects whether or not the region the person is in is Hypergrid enabled. Could be expanded to any region in the current grid. osHyperGrid() == TRUE Drava
void osTurnAvatar(rotation rot); Turns an avatar about the vertical axis to rotation rot relative to the grid rotation. osTurnAvatar(newrot); // turns the avatar to the new rotation specified by newrot. Valradica
osRezLink(string inventory, vector position, vector velocity, rotation rot, integer param) ; osRezLink would work just like llRezObject but instead of a separate object it would be directly part of the original object's link system. This would be very useful in HUDs and attachments. osRezLink("myobject",llGetPos()+<0.0,0.0,0.5>,ZERO_VECTOR,ZERO_ROTATION,10); Nihlaeth
osSaveObject(); osSaveObject would be used in attachments and HUDs to save changes made while the object was worn. osSaveObject(); Nihlaeth
osPauze(integer); Adds an timer-interruptible wait state. Where sleep holds the entire script, this would function more like a non-operation for the user-set duration. For this to be a real addition, osPauze(integer) should be interruptible by any event. osPauze(5); User:Fritigern
osDieOnAttachment(); osDieOnAttachment()plays the same role as llDie() but on any attachment. Useful in HUDs instead of using the trick of resizing and hiding unwanted primitives, this function simply kills them. This function could be used with the already proposed functions to Rez Directly on Attachments osDieOnAttachment(); Hussein Bakri
osGetTextureLocationTouch(integer number,list UVParameters); osGetTextureLocationTouch() plays the role of the following LSL functions: vector llDetectedTouchPos(integer number) [returns the position touched by the touch event (number) in region coordinates] in other words it tell which touch to examine like the family of llDetected* functions. The other function that is part of the parameters is vector llDetectedTouchFace(integer number) [returns the face of the prim touched by the touch event number] Another function in the UVParameters would be: vector llDetectedTouchUV(integer number)[returns the position touched by touch event number as texture coordinates in the form of ]

vector llDetectedTouchST(integer number) return the surface coordinates of the touch event number llDetectedTouchNormal and llDetectedTouchBinormal get the Normal and binormal vector positions. The function will look like llGetPrimParams(). Usage: every texture becomes a user interface, useful in maps also.

osGetTextureLocationTouch(integer number,list UVParameters);


Hussein Bakri
osBreakLinkOnAttachment(integer alternativeAttachmentPoint); osBreakLinkOnAttachment(integer alternativeAttachmentPoint) plays the same role as llBreakLink() but for attachments only. Not only that when it Breaks the link of a prim and it set the prim to another attachment point. Require attachment permition. Useful to break a link in HUD and create a separate HUD from the initial one. It will override the functionality of osDieAttachement() when alternativeAttachmentPoint = 0 meaning it kill the object. osBreakLinkOnAttachment(integer alternativeAttachmentPoint); Hussein Bakri

See Also

Personal tools
About This Wiki