IOSSL_Api.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  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. LSL_Integer osCheckODE();
  231. string osGetPhysicsEngineType();
  232. Object osParseJSONNew(string JSON);
  233. Hashtable osParseJSON(string JSON);
  234. void osMessageObject(key objectUUID,string message);
  235. void osMakeNotecard(string notecardName, LSL_Types.list contents);
  236. string osGetNotecardLine(string name, int line);
  237. string osGetNotecard(string name);
  238. int osGetNumberOfNotecardLines(string name);
  239. string osAvatarName2Key(string firstname, string lastname);
  240. string osKey2Name(string id);
  241. // Grid Info Functions
  242. string osGetGridNick();
  243. string osGetGridName();
  244. string osGetGridLoginURI();
  245. string osGetGridHomeURI();
  246. string osGetGridGatekeeperURI();
  247. string osGetGridCustom(string key);
  248. LSL_String osFormatString(string str, LSL_List strings);
  249. LSL_List osMatchString(string src, string pattern, int start);
  250. LSL_String osReplaceString(string src, string pattern, string replace, int count, int start);
  251. // Information about data loaded into the region
  252. string osLoadedCreationDate();
  253. string osLoadedCreationTime();
  254. string osLoadedCreationID();
  255. LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules);
  256. /// <summary>
  257. /// Identical to llCreateLink() but does not require permission from the owner.
  258. /// </summary>
  259. /// <param name='target'></param>
  260. /// <param name='parent'></param>
  261. void osForceCreateLink(string target, int parent);
  262. /// <summary>
  263. /// Identical to llBreakLink() but does not require permission from the owner.
  264. /// </summary>
  265. /// <param name='linknum'></param>
  266. void osForceBreakLink(int linknum);
  267. /// <summary>
  268. /// Identical to llBreakAllLinks() but does not require permission from the owner.
  269. /// </summary>
  270. void osForceBreakAllLinks();
  271. /// <summary>
  272. /// Check if the given key is an npc
  273. /// </summary>
  274. /// <param name="npc"></param>
  275. /// <returns>TRUE if the key belongs to an npc in the scene. FALSE otherwise.</returns>
  276. LSL_Integer osIsNpc(LSL_Key npc);
  277. key osNpcCreate(string user, string name, vector position, string notecard);
  278. key osNpcCreate(string user, string name, vector position, string notecard, int options);
  279. LSL_Key osNpcSaveAppearance(key npc, string notecard);
  280. void osNpcLoadAppearance(key npc, string notecard);
  281. vector osNpcGetPos(key npc);
  282. void osNpcMoveTo(key npc, vector position);
  283. void osNpcMoveToTarget(key npc, vector target, int options);
  284. /// <summary>
  285. /// Get the owner of the NPC
  286. /// </summary>
  287. /// <param name="npc"></param>
  288. /// <returns>
  289. /// 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.
  290. /// </returns>
  291. LSL_Key osNpcGetOwner(key npc);
  292. rotation osNpcGetRot(key npc);
  293. void osNpcSetRot(LSL_Key npc, rotation rot);
  294. void osNpcStopMoveToTarget(LSL_Key npc);
  295. void osNpcSay(key npc, string message);
  296. void osNpcSay(key npc, int channel, string message);
  297. void osNpcShout(key npc, int channel, string message);
  298. void osNpcSit(key npc, key target, int options);
  299. void osNpcStand(LSL_Key npc);
  300. void osNpcRemove(key npc);
  301. void osNpcPlayAnimation(LSL_Key npc, string animation);
  302. void osNpcStopAnimation(LSL_Key npc, string animation);
  303. void osNpcTouch(LSL_Key npcLSL_Key, LSL_Key object_key, LSL_Integer link_num);
  304. void osNpcWhisper(key npc, int channel, string message);
  305. LSL_Key osOwnerSaveAppearance(string notecard);
  306. LSL_Key osAgentSaveAppearance(key agentId, string notecard);
  307. key osGetMapTexture();
  308. key osGetRegionMapTexture(string regionName);
  309. LSL_List osGetRegionStats();
  310. vector osGetRegionSize();
  311. int osGetSimulatorMemory();
  312. void osKickAvatar(string FirstName,string SurName,string alert);
  313. void osSetSpeed(string UUID, LSL_Float SpeedModifier);
  314. LSL_Float osGetHealth(string avatar);
  315. void osCauseHealing(string avatar, double healing);
  316. void osCauseDamage(string avatar, double damage);
  317. void osForceOtherSit(string avatar);
  318. void osForceOtherSit(string avatar, string target);
  319. LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
  320. void osSetPrimitiveParams(LSL_Key prim, LSL_List rules);
  321. void osSetProjectionParams(bool projection, LSL_Key texture, double fov, double focus, double amb);
  322. void osSetProjectionParams(LSL_Key prim, bool projection, LSL_Key texture, double fov, double focus, double amb);
  323. LSL_List osGetAvatarList();
  324. LSL_String osUnixTimeToTimestamp(long time);
  325. LSL_String osGetInventoryDesc(string item);
  326. LSL_Integer osInviteToGroup(LSL_Key agentId);
  327. LSL_Integer osEjectFromGroup(LSL_Key agentId);
  328. void osSetTerrainTexture(int level, LSL_Key texture);
  329. void osSetTerrainTextureHeight(int corner, double low, double high);
  330. /// <summary>
  331. /// Checks if thing is a UUID.
  332. /// </summary>
  333. /// <param name="thing"></param>
  334. /// <returns>1 if thing is a valid UUID, 0 otherwise</returns>
  335. LSL_Integer osIsUUID(string thing);
  336. /// <summary>
  337. /// Wraps to Math.Min()
  338. /// </summary>
  339. /// <param name="a"></param>
  340. /// <param name="b"></param>
  341. /// <returns></returns>
  342. LSL_Float osMin(double a, double b);
  343. /// <summary>
  344. /// Wraps to Math.max()
  345. /// </summary>
  346. /// <param name="a"></param>
  347. /// <param name="b"></param>
  348. /// <returns></returns>
  349. LSL_Float osMax(double a, double b);
  350. /// <summary>
  351. /// Get the key of the object that rezzed this object.
  352. /// </summary>
  353. /// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns>
  354. LSL_Key osGetRezzingObject();
  355. /// <summary>
  356. /// Sets the response type for an HTTP request/response
  357. /// </summary>
  358. /// <returns></returns>
  359. void osSetContentType(LSL_Key id, string type);
  360. /// <summary>
  361. /// Attempts to drop an attachment to the ground
  362. /// </summary>
  363. void osDropAttachment();
  364. /// <summary>
  365. /// Attempts to drop an attachment to the ground while bypassing the script permissions
  366. /// </summary>
  367. void osForceDropAttachment();
  368. /// <summary>
  369. /// Attempts to drop an attachment at the specified coordinates.
  370. /// </summary>
  371. /// <param name="pos"></param>
  372. /// <param name="rot"></param>
  373. void osDropAttachmentAt(vector pos, rotation rot);
  374. /// <summary>
  375. /// Attempts to drop an attachment at the specified coordinates while bypassing the script permissions
  376. /// </summary>
  377. /// <param name="pos"></param>
  378. /// <param name="rot"></param>
  379. void osForceDropAttachmentAt(vector pos, rotation rot);
  380. /// <summary>
  381. /// Identical to llListen except for a bitfield which indicates which
  382. /// string parameters should be parsed as regex patterns.
  383. /// </summary>
  384. /// <param name="channelID"></param>
  385. /// <param name="name"></param>
  386. /// <param name="ID"></param>
  387. /// <param name="msg"></param>
  388. /// <param name="regexBitfield">
  389. /// OS_LISTEN_REGEX_NAME
  390. /// OS_LISTEN_REGEX_MESSAGE
  391. /// </param>
  392. /// <returns></returns>
  393. LSL_Integer osListenRegex(int channelID, string name, string ID,
  394. string msg, int regexBitfield);
  395. /// <summary>
  396. /// Wraps to bool Regex.IsMatch(string input, string pattern)
  397. /// </summary>
  398. /// <param name="input">string to test for match</param>
  399. /// <param name="regex">string to use as pattern</param>
  400. /// <returns>boolean</returns>
  401. LSL_Integer osRegexIsMatch(string input, string pattern);
  402. }
  403. }