Difference between revisions of "User:Tutti Anatine/snippets"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "''<< Return to Tutti Anatine'' == Degrees to rotation == <lsl> /** * Converts a vector containing xyz-values to a rotation value. * * @param vector A v…")
 
 
Line 1: Line 1:
''<< Return to [[User:Tutti Anatine|Tutti Anatine]]''
''<< Return to [[User:Tutti Anatine|Tutti Anatine]]''
These are some free-to-use snippets I keep for the sake of usefulness.
== Open menu (dialog) ==
<lsl>
integer MENU_CHANNEL = -...;
float TIME_OUT = 60.0;
//----
key avatar;
integer handler_menu;
string menu_current;
/**
* Open a dialog menu with given menu text and buttons.
*
* @param string text The description text that will be shown with the buttons.
* @param list buttons The buttons this menu contains.
* @param string menu A unique identifier for the menu that will be opened.
*/
open_menu(string text, list buttons, string menu) {
  handler_menu = llListen(MENU_CHANNEL, "", avatar, "");
  menu_current = menu;
  llDialog(avatar, text, buttons, MENU_CHANNEL);
  llSetTimerEvent(TIME_OUT);
}
</lsl>


== Degrees to rotation ==
== Degrees to rotation ==

Latest revision as of 12:30, 31 May 2012

<< Return to Tutti Anatine

These are some free-to-use snippets I keep for the sake of usefulness.

Open menu (dialog)

<lsl> integer MENU_CHANNEL = -...; float TIME_OUT = 60.0; //---- key avatar; integer handler_menu; string menu_current;

/**

* Open a dialog menu with given menu text and buttons.
*
* @param string text The description text that will be shown with the buttons.
* @param list buttons The buttons this menu contains.
* @param string menu A unique identifier for the menu that will be opened.
*/

open_menu(string text, list buttons, string menu) {

 handler_menu = llListen(MENU_CHANNEL, "", avatar, "");
 menu_current = menu;
 llDialog(avatar, text, buttons, MENU_CHANNEL);
 llSetTimerEvent(TIME_OUT);

} </lsl>

Degrees to rotation

<lsl> /**

* Converts a vector containing xyz-values to a rotation value.
*
* @param vector A vector containing xyz-rotation values in degrees.
* @return vector The converted rotation value.
*/

rotation degrees_to_rotation(vector rot_in_degrees) {

 vector rot_in_radians = rot_in_degrees * DEG_TO_RAD;
 rotation rot = llEuler2Rot(rot_in_radians);
 return rot;

} </lsl>