// Scale on Click // Created by Water Rogers for IBM/Opensource // Purpose // -------------------------------------------------------------- // This is a basic example of how you can change the size of an // object when you click on it. This also show's you how to change // a texture's offset when the size changes. // Requirements // -------------------------------------------------------------- // A single prim is all that is necessary for this example. // Usage // -------------------------------------------------------------- // CLick on the script and 1 meter will be multiplied to each side // up until 10 meters, after that... it will go back to 1x1x1. // GLOBALS // -------------------------------------------------------------- vector g_BaseSize = <1.0, 1.0, 1.0>; // The initial size of the object vector g_BaseOffset = <-0.450, 0.550, 0>; // The initial offset of the texture vector g_MaxSize = <10.0, 10.0, 10.0>; // The max size of the object // FUNCTIONS // -------------------------------------------------------------- init() { // This is the initial state of the object. We set the size // and the Texture offset to the base settings. Note that you // edit or call the elements of a vector by calling the respective // x, y, or z components. llSetScale(g_BaseSize); llOffsetTexture(g_BaseOffset.x, g_BaseOffset.y, ALL_SIDES); } // EVENTS // -------------------------------------------------------------- default { state_entry() { // Call the initial state of the object. init(); } on_rez(integer start_param) { // The object was just rezzed, so set the initial state of the // object. init(); } touch_start(integer total_number) { // The object has been touched, so we add a meter to the scale // add .1 to the texture offset, or return to the inital state if // the object is at it's max size. vector scale = llGetScale(); vector offset = llGetTextureOffset(0); if(scale != g_MaxSize) { llSetScale(scale + <1, 1, 1>); llOffsetTexture(offset.x + 0.100, offset.y, ALL_SIDES); } else { init(); } } }