Difference between revisions of "Template:Darwin's Scripts"
Jump to navigation
Jump to search
m |
|||
Line 167: | Line 167: | ||
} | } | ||
</lsl></div></div> | </lsl></div></div> | ||
| uv button maker = <div id="box"> | |||
==UV Button Maker== | |||
<div style="padding: 0.5em"> | |||
The following scripts are tools to making your own uv button setup for a texture in a hud or for any multi-button texture. First script is for getting the button coordinates which are used in the second script (detected_button) which returns the button number pressed. | |||
===Get Coordinates=== | |||
<lsl>integer start_face; | |||
vector start_uv; | |||
default | |||
{ | |||
touch_start(integer s) | |||
{ | |||
start_face = llDetectedTouchFace(0); | |||
start_uv = llDetectedTouchUV(0); | |||
start_uv.x += -(integer)start_uv.x - (start_uv.x < 0); | |||
start_uv.y += -(integer)start_uv.y - (start_uv.y < 0); | |||
} | |||
touch(integer s) | |||
{ | |||
if(llDetectedTouchFace(0) == start_face) | |||
{ | |||
vector new_uv = llDetectedTouchUV(0); | |||
new_uv.x -= (integer)new_uv.x - (new_uv.x < 0); | |||
new_uv.y -= (integer)new_uv.y - (new_uv.y < 0); | |||
llSetText((string)start_uv+" | "+(string)new_uv, <1,1,1>, 1); | |||
} | |||
} | |||
touch_end(integer s) | |||
{ | |||
if(llDetectedTouchFace(0) == start_face) | |||
{ | |||
vector end_uv = llDetectedTouchUV(0); | |||
end_uv.x -= (integer)end_uv.x - (end_uv.x < 0); | |||
end_uv.y -= (integer)end_uv.y - (end_uv.y < 0); | |||
llOwnerSay("Button coords: "+(string)start_uv+" | "+(string)end_uv, <1,1,1>, 1); | |||
} | |||
} | |||
}</lsl> | |||
===detected_button()=== | |||
<lsl>//Example coords | |||
list button_coords = [ | |||
<0.617, 0.050, 0.000>, <0.823, 0.141, 0.000>, //Button 0 | |||
<0.399, 0.535, 0.000>, <0.972, 0.764, 0.000>, //Button 1 | |||
<0.152, 0.864, 0.000>, <0.796, 0.940, 0.000>, //Button 2 | |||
<0.047, 0.529, 0.000>, <0.376, 0.576, 0.000> //Button 3 | |||
]; | |||
integer within_square(vector test, vector a, vector b) | |||
{ | |||
vector BLC; | |||
vector TRC; | |||
if(a.x > b.x) | |||
{ | |||
TRC.x = a.x; | |||
BLC.x = b.x; | |||
} | |||
else | |||
{ | |||
TRC.x = b.x; | |||
BLC.x = a.x; | |||
} | |||
if(a.y > b.y) | |||
{ | |||
TRC.y = a.y; | |||
BLC.y = b.y; | |||
} | |||
else | |||
{ | |||
TRC.y = b.y; | |||
BLC.y = a.y; | |||
} | |||
if(test.x <= TRC.x && test.x >= BLC.x && test.y >= BLC.y && test.y <= TRC.y) | |||
return TRUE; | |||
else | |||
return FALSE; | |||
} | |||
integer detected_buttonUV(vector uv) | |||
{ | |||
uv.x -= (integer)uv.x; | |||
uv.y -= (integer)uv.y; | |||
integer i; | |||
for(i=0; i<llGetListLength(button_coords); i=i+2) | |||
{ | |||
if(within_square(uv, llList2Vector(button_coords, i), llList2Vector(button_coords, i+1))) | |||
return i/2; | |||
} | |||
return -1; | |||
} | |||
default | |||
{ | |||
touch_start(integer total_number) | |||
{ | |||
llOwnerSay("Button "+(string)detected_buttonUV(llDetectedTouchUV(0))); | |||
} | |||
}</lsl></div></div> | |||
| Script not found: {{{1}}} | | Script not found: {{{1}}} | ||
}} | }} | ||
Line 179: | Line 286: | ||
* color picker | * color picker | ||
* date difference | * date difference | ||
* uv button maker | |||
</noinclude> | </noinclude> |
Revision as of 16:25, 28 November 2008
Usage
{{Darwin's Scripts|script name}}
Returns lsl scripts
Contents:
- find screen width
- color picker
- date difference
- uv button maker