IOSSL_Api.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using OpenSim.Region.ScriptEngine.Interfaces;
  30. using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  31. using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
  32. using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
  33. using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
  34. using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  35. using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  36. using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
  37. using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  38. namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
  39. {
  40. /// <summary>
  41. /// To permit region owners to enable the extended scripting functionality
  42. /// of OSSL, without allowing malicious scripts to access potentially
  43. /// troublesome functions, each OSSL function is assigned a threat level,
  44. /// and access to the functions is granted or denied based on a default
  45. /// threshold set in OpenSim.ini (which can be overridden for individual
  46. /// functions on a case-by-case basis)
  47. /// </summary>
  48. public enum ThreatLevel
  49. {
  50. // Not documented, presumably means permanently disabled ?
  51. NoAccess = -1,
  52. /// <summary>
  53. /// Function is no threat at all. It doesn't constitute a threat to
  54. /// either users or the system and has no known side effects.
  55. /// </summary>
  56. None = 0,
  57. /// <summary>
  58. /// Abuse of this command can cause a nuisance to the region operator,
  59. /// such as log message spew.
  60. /// </summary>
  61. Nuisance = 1,
  62. /// <summary>
  63. /// Extreme levels of abuse of this function can cause impaired
  64. /// functioning of the region, or very gullible users can be tricked
  65. /// into experiencing harmless effects.
  66. /// </summary>
  67. VeryLow = 2,
  68. /// <summary>
  69. /// Intentional abuse can cause crashes or malfunction under certain
  70. /// circumstances, which can be easily rectified; or certain users can
  71. /// be tricked into certain situations in an avoidable manner.
  72. /// </summary>
  73. Low = 3,
  74. /// <summary>
  75. /// Intentional abuse can cause denial of service and crashes with
  76. /// potential of data or state loss; or trusting users can be tricked
  77. /// into embarrassing or uncomfortable situations.
  78. /// </summary>
  79. Moderate = 4,
  80. /// <summary>
  81. /// Casual abuse can cause impaired functionality or temporary denial
  82. /// of service conditions. Intentional abuse can easily cause crashes
  83. /// with potential data loss, or can be used to trick experienced and
  84. /// cautious users into unwanted situations, or changes global data
  85. /// permanently and without undo ability.
  86. /// </summary>
  87. High = 5,
  88. /// <summary>
  89. /// Even normal use may, depending on the number of instances, or
  90. /// frequency of use, result in severe service impairment or crash
  91. /// with loss of data, or can be used to cause unwanted or harmful
  92. /// effects on users without giving the user a means to avoid it.
  93. /// </summary>
  94. VeryHigh = 6,
  95. /// <summary>
  96. /// Even casual use is a danger to region stability, or function allows
  97. /// console or OS command execution, or function allows taking money
  98. /// without consent, or allows deletion or modification of user data,
  99. /// or allows the compromise of sensitive data by design.
  100. /// </summary>
  101. Severe = 7
  102. };
  103. public interface IOSSL_Api
  104. {
  105. void CheckThreatLevel(ThreatLevel level, string function);
  106. //OpenSim functions
  107. string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams, int timer);
  108. string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
  109. int timer, int alpha);
  110. string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams,
  111. bool blend, int disp, int timer, int alpha, int face);
  112. string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams, int timer);
  113. string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
  114. int timer, int alpha);
  115. string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams,
  116. bool blend, int disp, int timer, int alpha, int face);
  117. LSL_Float osGetTerrainHeight(int x, int y);
  118. LSL_Float osTerrainGetHeight(int x, int y); // Deprecated
  119. LSL_Integer osSetTerrainHeight(int x, int y, double val);
  120. LSL_Integer osTerrainSetHeight(int x, int y, double val); //Deprecated
  121. void osTerrainFlush();
  122. int osRegionRestart(double seconds);
  123. void osRegionNotice(string msg);
  124. bool osConsoleCommand(string Command);
  125. void osSetParcelMediaURL(string url);
  126. void osSetPrimFloatOnWater(int floatYN);
  127. void osSetParcelSIPAddress(string SIPAddress);
  128. // Avatar Info Commands
  129. string osGetAgentIP(string agent);
  130. LSL_List osGetAgents();
  131. // Teleport commands
  132. void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  133. void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  134. void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  135. void osTeleportOwner(string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  136. void osTeleportOwner(int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  137. void osTeleportOwner(LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
  138. // Animation commands
  139. void osAvatarPlayAnimation(string avatar, string animation);
  140. void osAvatarStopAnimation(string avatar, string animation);
  141. #region Attachment commands
  142. /// <summary>
  143. /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
  144. /// </summary>
  145. /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
  146. void osForceAttachToAvatar(int attachment);
  147. /// <summary>
  148. /// Attach an inventory item in the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
  149. /// </summary>
  150. /// <remarks>
  151. /// Nothing happens if the owner is not in the region.
  152. /// </remarks>
  153. /// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param>
  154. /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
  155. void osForceAttachToAvatarFromInventory(string itemName, int attachment);
  156. /// <summary>
  157. /// Attach an inventory item in the object containing this script to any avatar in the region without asking for PERMISSION_ATTACH
  158. /// </summary>
  159. /// <remarks>
  160. /// Nothing happens if the avatar is not in the region.
  161. /// </remarks>
  162. /// <param name='rawAvatarId'>The UUID of the avatar to which to attach. Nothing happens if this is not a UUID</para>
  163. /// <param name='itemName'>The name of the item. If this is not found then a warning is said to the owner</param>
  164. /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
  165. void osForceAttachToOtherAvatarFromInventory(string rawAvatarId, string itemName, int attachmentPoint);
  166. /// <summary>
  167. /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
  168. /// </summary>
  169. /// <remarks>Nothing happens if the object is not attached.</remarks>
  170. void osForceDetachFromAvatar();
  171. /// <summary>
  172. /// Returns a strided list of the specified attachment points and the number of attachments on those points.
  173. /// </summary>
  174. /// <param name="avatar">avatar UUID</param>
  175. /// <param name="attachmentPoints">list of ATTACH_* constants</param>
  176. /// <returns></returns>
  177. LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints);
  178. /// <summary>
  179. /// Sends a specified message to the specified avatar's attachments on
  180. /// the specified attachment points.
  181. /// </summary>
  182. /// <remarks>
  183. /// Behaves as osMessageObject(), without the sending script needing to know the attachment keys in advance.
  184. /// </remarks>
  185. /// <param name="avatar">avatar UUID</param>
  186. /// <param name="message">message string</param>
  187. /// <param name="attachmentPoints">list of ATTACH_* constants, or -1 for all attachments. If -1 is specified and OS_ATTACH_MSG_INVERT_POINTS is present in flags, no action is taken.</param>
  188. /// <param name="flags">flags further constraining the attachments to deliver the message to.</param>
  189. void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags);
  190. #endregion
  191. //texture draw functions
  192. string osMovePen(string drawList, int x, int y);
  193. string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
  194. string osDrawLine(string drawList, int endX, int endY);
  195. string osDrawText(string drawList, string text);
  196. string osDrawEllipse(string drawList, int width, int height);
  197. string osDrawRectangle(string drawList, int width, int height);
  198. string osDrawFilledRectangle(string drawList, int width, int height);
  199. string osDrawPolygon(string drawList, LSL_List x, LSL_List y);
  200. string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y);
  201. string osSetFontName(string drawList, string fontName);
  202. string osSetFontSize(string drawList, int fontSize);
  203. string osSetPenSize(string drawList, int penSize);
  204. string osSetPenColor(string drawList, string color);
  205. string osSetPenColour(string drawList, string colour); // Deprecated
  206. string osSetPenCap(string drawList, string direction, string type);
  207. string osDrawImage(string drawList, int width, int height, string imageUrl);
  208. vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize);
  209. void osSetStateEvents(int events);
  210. double osList2Double(LSL_Types.list src, int index);
  211. void osSetRegionWaterHeight(double height);
  212. void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour);
  213. void osSetEstateSunSettings(bool sunFixed, double sunHour);
  214. double osGetCurrentSunHour();
  215. double osGetSunParam(string param);
  216. double osSunGetParam(string param); // Deprecated
  217. void osSetSunParam(string param, double value);
  218. void osSunSetParam(string param, double value); // Deprecated
  219. // Wind Module Functions
  220. string osWindActiveModelPluginName();
  221. void osSetWindParam(string plugin, string param, LSL_Float value);
  222. LSL_Float osGetWindParam(string plugin, string param);
  223. // Parcel commands
  224. void osParcelJoin(vector pos1, vector pos2);
  225. void osParcelSubdivide(vector pos1, vector pos2);
  226. void osSetParcelDetails(vector pos, LSL_List rules);
  227. void osParcelSetDetails(vector pos, LSL_List rules); // Deprecated
  228. string osGetScriptEngineName();
  229. string osGetSimulatorVersion();
  230. Object osParseJSONNew(string JSON);
  231. Hashtable osParseJSON(string JSON);
  232. void osMessageObject(key objectUUID,string message);
  233. void osMakeNotecard(string notecardName, LSL_Types.list contents);
  234. string osGetNotecardLine(string name, int line);
  235. string osGetNotecard(string name);
  236. int osGetNumberOfNotecardLines(string name);
  237. string osAvatarName2Key(string firstname, string lastname);
  238. string osKey2Name(string id);
  239. // Grid Info Functions
  240. string osGetGridNick();
  241. string osGetGridName();
  242. string osGetGridLoginURI();
  243. string osGetGridHomeURI();
  244. string osGetGridGatekeeperURI();
  245. string osGetGridCustom(string key);
  246. LSL_String osFormatString(string str, LSL_List strings);
  247. LSL_List osMatchString(string src, string pattern, int start);
  248. LSL_String osReplaceString(string src, string pattern, string replace, int count, int start);
  249. // Information about data loaded into the region
  250. string osLoadedCreationDate();
  251. string osLoadedCreationTime();
  252. string osLoadedCreationID();
  253. LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
  254. /// <summary>
  255. /// Check if the given key is an npc
  256. /// </summary>
  257. /// <param name="npc"></param>
  258. /// <returns>TRUE if the key belongs to an npc in the scene. FALSE otherwise.</returns>
  259. LSL_Integer osIsNpc(LSL_Key npc);
  260. key osNpcCreate(string user, string name, vector position, string notecard);
  261. key osNpcCreate(string user, string name, vector position, string notecard, int options);
  262. LSL_Key osNpcSaveAppearance(key npc, string notecard);
  263. void osNpcLoadAppearance(key npc, string notecard);
  264. vector osNpcGetPos(key npc);
  265. void osNpcMoveTo(key npc, vector position);
  266. void osNpcMoveToTarget(key npc, vector target, int options);
  267. /// <summary>
  268. /// Get the owner of the NPC
  269. /// </summary>
  270. /// <param name="npc"></param>
  271. /// <returns>
  272. /// The owner of the NPC for an owned NPC. The NPC's agent id for an unowned NPC. UUID.Zero if the key is not an npc.
  273. /// </returns>
  274. LSL_Key osNpcGetOwner(key npc);
  275. rotation osNpcGetRot(key npc);
  276. void osNpcSetRot(LSL_Key npc, rotation rot);
  277. void osNpcStopMoveToTarget(LSL_Key npc);
  278. void osNpcSay(key npc, string message);
  279. void osNpcSay(key npc, int channel, string message);
  280. void osNpcShout(key npc, int channel, string message);
  281. void osNpcSit(key npc, key target, int options);
  282. void osNpcStand(LSL_Key npc);
  283. void osNpcRemove(key npc);
  284. void osNpcPlayAnimation(LSL_Key npc, string animation);
  285. void osNpcStopAnimation(LSL_Key npc, string animation);
  286. void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
  287. void osNpcWhisper(key npc, int channel, string message);
  288. LSL_Key osOwnerSaveAppearance(string notecard);
  289. LSL_Key osAgentSaveAppearance(key agentId, string notecard);
  290. key osGetMapTexture();
  291. key osGetRegionMapTexture(string regionName);
  292. LSL_List osGetRegionStats();
  293. int osGetSimulatorMemory();
  294. void osKickAvatar(string FirstName,string SurName,string alert);
  295. void osSetSpeed(string UUID, LSL_Float SpeedModifier);
  296. LSL_Float osGetHealth(string avatar);
  297. void osCauseHealing(string avatar, double healing);
  298. void osCauseDamage(string avatar, double damage);
  299. LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
  300. void osSetPrimitiveParams(LSL_Key prim, LSL_List rules);
  301. void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb);
  302. void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb);
  303. LSL_List osGetAvatarList();
  304. LSL_String osUnixTimeToTimestamp(long time);
  305. LSL_String osGetInventoryDesc(string item);
  306. LSL_Integer osInviteToGroup(LSL_Key agentId);
  307. LSL_Integer osEjectFromGroup(LSL_Key agentId);
  308. void osSetTerrainTexture(int level, LSL_Key texture);
  309. void osSetTerrainTextureHeight(int corner, double low, double high);
  310. /// <summary>
  311. /// Checks if thing is a UUID.
  312. /// </summary>
  313. /// <param name="thing"></param>
  314. /// <returns>1 if thing is a valid UUID, 0 otherwise</returns>
  315. LSL_Integer osIsUUID(string thing);
  316. /// <summary>
  317. /// Wraps to Math.Min()
  318. /// </summary>
  319. /// <param name="a"></param>
  320. /// <param name="b"></param>
  321. /// <returns></returns>
  322. LSL_Float osMin(double a, double b);
  323. /// <summary>
  324. /// Wraps to Math.max()
  325. /// </summary>
  326. /// <param name="a"></param>
  327. /// <param name="b"></param>
  328. /// <returns></returns>
  329. LSL_Float osMax(double a, double b);
  330. /// <summary>
  331. /// Get the key of the object that rezzed this object.
  332. /// </summary>
  333. /// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns>
  334. LSL_Key osGetRezzingObject();
  335. /// <summary>
  336. /// Sets the response type for an HTTP request/response
  337. /// </summary>
  338. /// <returns></returns>
  339. void osSetContentType(LSL_Key id, string type);
  340. /// <summary>
  341. /// Attempts to drop an attachment to the ground
  342. /// </summary>
  343. void osDropAttachment();
  344. /// <summary>
  345. /// Attempts to drop an attachment to the ground while bypassing the script permissions
  346. /// </summary>
  347. void osForceDropAttachment();
  348. /// <summary>
  349. /// Attempts to drop an attachment at the specified coordinates.
  350. /// </summary>
  351. /// <param name="pos"></param>
  352. /// <param name="rot"></param>
  353. void osDropAttachmentAt(vector pos, rotation rot);
  354. /// <summary>
  355. /// Attempts to drop an attachment at the specified coordinates while bypassing the script permissions
  356. /// </summary>
  357. /// <param name="pos"></param>
  358. /// <param name="rot"></param>
  359. void osForceDropAttachmentAt(vector pos, rotation rot);
  360. /// <summary>
  361. /// Identical to llListen except for a bitfield which indicates which
  362. /// string parameters should be parsed as regex patterns.
  363. /// </summary>
  364. /// <param name="channelID"></param>
  365. /// <param name="name"></param>
  366. /// <param name="ID"></param>
  367. /// <param name="msg"></param>
  368. /// <param name="regexBitfield">
  369. /// OS_LISTEN_REGEX_NAME
  370. /// OS_LISTEN_REGEX_MESSAGE
  371. /// </param>
  372. /// <returns></returns>
  373. LSL_Integer osListenRegex(int channelID, string name, string ID,
  374. string msg, int regexBitfield);
  375. /// <summary>
  376. /// Wraps to bool Regex.IsMatch(string input, string pattern)
  377. /// </summary>
  378. /// <param name="input">string to test for match</param>
  379. /// <param name="regex">string to use as pattern</param>
  380. /// <returns>boolean</returns>
  381. LSL_Integer osRegexIsMatch(string input, string pattern);
  382. }
  383. }