IOSSL_Api.cs 21 KB

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