Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

up to 600 buttons on a single prim

Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
09-09-2008 20:45
hi everyone. i had a small brainstorm to simplify things for people today and it turned out quite good.

place this script in a prim and it will texture itself with a grid of 100 spaces.

touch any one of the numbers on any side and it will know and tell you exactly which one you press on the side you pressed it on.

this could easily be modified to handle more then 100 spaces with little effort.

//////////////////////////////////////////////////////
//Multi Touch Sensitive Prim - By Kain Cleaver
//FREE to use Script - All i ask is you credit
//me in your work if you decide to use this
//or major parts of this script in your work
//////////////////////////////////////////////////////
vector touchie;
float lr0 = .00;
float lr1 = .10;
float lr2 = .20;
float lr3 = .30;
float lr4 = .40;
float lr5 = .50;
float lr6 = .60;
float lr7 = .70;
float lr8 = .80;
float lr9 = .90;
float lr10 = 1.0;
float ud0 = .00;
float ud1 = .10;
float ud2 = .20;
float ud3 = .30;
float ud4 = .40;
float ud5 = .50;
float ud6 = .60;
float ud7 = .70;
float ud8 = .80;
float ud9 = .90;
float ud10 = 1.0;
float updown;
float leftright;
integer mark1;
integer mark2;
integer pos;
string side;
det()
{
if (updown > ud0 && updown < ud1){mark2 = 1;}
if (updown > ud1 && updown < ud2){mark2 = 2;}
if (updown > ud2 && updown < ud3){mark2 = 3;}
if (updown > ud3 && updown < ud4){mark2 = 4;}
if (updown > ud4 && updown < ud5){mark2 = 5;}
if (updown > ud5 && updown < ud6){mark2 = 6;}
if (updown > ud6 && updown < ud7){mark2 = 7;}
if (updown > ud7 && updown < ud8){mark2 = 8;}
if (updown > ud8 && updown < ud9){mark2 = 9;}
if (updown > ud9 && updown < ud10){mark2 = 10;}

if (leftright > lr0 && leftright < lr1){mark1 = 0;}
if (leftright > lr1 && leftright < lr2){mark1 = 10;}
if (leftright > lr2 && leftright < lr3){mark1 = 20;}
if (leftright > lr3 && leftright < lr4){mark1 = 30;}
if (leftright > lr4 && leftright < lr5){mark1 = 40;}
if (leftright > lr5 && leftright < lr6){mark1 = 50;}
if (leftright > lr6 && leftright < lr7){mark1 = 60;}
if (leftright > lr7 && leftright < lr8){mark1 = 70;}
if (leftright > lr8 && leftright < lr9){mark1 = 80;}
if (leftright > lr9 && leftright < lr10){mark1 = 90;}

pos = mark1 + mark2;
side = (string)llDetectedTouchFace(0);
llSay(0,"Touched Square : " + (string)pos + " On Side : " + side);
llMessageLinked(0,pos,side,NULL_KEY);
}

default
{
state_entry()
{
llSetTexture("3245bcf1-f721-52ec-2895-ea6d3909c7ed",ALL_SIDES);
}

touch_start(integer total_number)
{

touchie = llDetectedTouchST(0);
if (llDetectedTouchFace(0) == -1){llInstantMessage(llDetectedKey(0),"Incorrect SL Version - Please Update your Second Life Client to Most Recent Version To Take Advantage Of This Touch Interface";);}
else{
leftright = touchie.y;
updown = touchie.x;
det();
}
}
}
//////////////////////////////////////////////////////////////
//End Script
//////////////////////////////////////////////////////////////


The script automaticly link messages the side of the prim
and the number zone that was touched.

i was able to quickly make a 10 button color changer using this
by having the main script define the area touched and what color
it turned to by pressing that range.

if anyone needs the grid jpg for photoshop you can find it here

http://http://members.aol.com/mrcuddlemonstr/100grid.jpg

you can make this into a transparent layer and place your buttons
over the numbers you wish to define.. so if you place a button on
zones 1 2 3 and 4 simply define the link message as such

link_message(integer link_num,integer num, string str, key id)
{
if (num > 0 && num < 5){do action here}
}

hope i made it easy enough to understand. if you have questions feel free
to IM me. Kain Cleaver and ill help as much as i can :)

enjoy , take care and have fun
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
09-09-2008 20:46
Sorry i forgot to mention (as if this wasnt obvious) this script will only work for users on the Beta/Release canidate viewer. (the one that supports mono scripted items and prim side detection)

if you dont have the viewer it will tell you to update your viewer and will not work
Dnali Anabuki
Still Crazy
Join date: 17 Oct 2006
Posts: 1,633
09-10-2008 04:57
Oh this looks very interesting, can't wait to try it. Thanks for posting this.

Oops, linky goes nowhere for me.
_____________________
The price of apathy is to be ruled by evil men--Plato
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
09-10-2008 05:21
I believe one could simplify that to just

CODE


default
{
state_entry()
{
llSetTexture("3245bcf1-f721-52ec-2895-ea6d3909c7ed", ALL_SIDES);
}

touch_start(integer n)
{
integer face = llDetectedTouchFace(0);
if (face == -1) llSay(0, "old client please change blah");
else {
vector pos = llDetectedTouchST(0);
integer square = llFloor(pos.y * 100.0) + llCeil(pos.x * 10.0);
llSay(0,"Touched Square : " + (string)square + " On Side : " + (string)face);
llMessageLinked(0, square, (string)face, NULL_KEY);
}
}
}

_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Lance Corrimal
I don't do stupid.
Join date: 9 Jun 2006
Posts: 877
09-10-2008 06:32
From: Ordinal Malaprop
I believe one could simplify that to just

CODE

integer square = llFloor(pos.y * 100.0) + llFloor(pos.x * 10.0);




only if you have a grid that is 10 by 10 squares ;)
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-10-2008 07:01
From: Dnali Anabuki
Oh this looks very interesting, can't wait to try it. Thanks for posting this.

Oops, linky goes nowhere for me.




they had the http on there twice
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
09-10-2008 09:17
From: Lance Corrimal
only if you have a grid that is 10 by 10 squares ;)

Well, er, this is what this one is surely?

(I made a slight correction there to use llCeil for the x-position, by the way.)
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!

http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal

http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
Sessi Snoodle
Registered User
Join date: 17 Jul 2008
Posts: 1
09-10-2008 22:45
the only negitive with trying your version is that it wasnt accurate with the boxes and strangely it was from 0 to 108 the grid would have to be remade to pinpoint your spots.
Fenix Eldritch
Mostly harmless
Join date: 30 Jan 2005
Posts: 201
09-19-2008 06:51
Forgive me Ordinal, but I believe there's a slight problem with your code. It took me a while to figure it out...

CODE

integer square = (llFloor(pos.y * 10.0))*10 + llCeil(pos.x * 10.0);

The trap was llFloor(pos.y*100) would give 10 sub divisions per box, incrementing as you went further up. Instead, multiply pos.y by 10, but then multiply the value returned by the llFloor() function value by 10 again to get the 10-90 range desired.
DreamsCatcher Colman
Registered User
Join date: 23 Apr 2007
Posts: 3
You can also use llDetectedTouchST(0) instead
09-30-2008 03:19
To have as many buttons as a click can reach, the size you want for each button, multiple sizes and all in the same side of a prim you can use llDetectedTouchST(0) with mapped coordinates for X and Y instead, and this means you first create whatever texture with whatever buttons and then you script based on the coordinates where your buttons are.

Cheers,

Dreams.
hurly Burleigh
Registered User
Join date: 19 Sep 2005
Posts: 167
09-30-2008 08:00
Ok a question from a Builder who is a NON Scripter :)

Reading the thread it appears that you can create say a vendor that does not need seperate prims for forward/backwards etc ?

Will this affect the amount of lag caused?

If not it seems to be a great leap forward in saving prims:)

I hope all the bugs are ironed out before it makes it to the main grid though.lol
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
09-30-2008 13:15
From: hurly Burleigh
Ok a question from a Builder who is a NON Scripter :)

Reading the thread it appears that you can create say a vendor that does not need seperate prims for forward/backwards etc ?

Will this affect the amount of lag caused?
It should very slightly reduce the lag because there are fewer prims that have to be downloaded to viewers. The difference in script computation is at most miniscule (God only knows what goes on behind the scenes to propagate touches to the root prim).

Most vendor lag, though, is due to texture downloading, not scripts, so it's really not going to be a big deal anyway.

For vendors, however, I'd suggest the related llDetectedTouchFace(). There's still just one texture per face, and product picture textures are difficult enough for users to manage. There are lots of possibilities, but I'd imagine using a 5-frontal-face "preview" prim (a la XYText) on each side of a main selection photo prim, plus maybe a 3-face "back/info/fwd" controls prim on the bottom, for a total of 4 prims. Three prims would do for 8 instead of 10 preview panes. Or just a single 3- or 5-faced prim, perhaps combining selection with scrolling forward and back.

[Edit: Actually, three prims could do 10 preview panes just fine, with some constraints on the layout of the prims, using faces of the main selection prim for forward and back. Really, there are tons of options here.]
Seshat Czeret
Registered User
Join date: 26 May 2008
Posts: 152
10-01-2008 04:25
Yes, hurly. It will become a huge saving in prims, once enough of our clients are using the updated viewer.

I'm seriously considering one-prim displays for multiple colours of an object: so there's a big picture of the most eye-catching colour in the centre, and it's surrounded by smaller pictures of the other colours around the sides.

And it's all on one prim.


But I won't use it for a vendor until (a) enough of our customers are using the updated viewer, and (b) it's been tested with non-money-based apps to my satisfaction.
_____________________
My blog: http://seshat-czeret.blogspot.com/
My shop: http://slurl.com/secondlife/Achlya/199/185/102
hurly Burleigh
Registered User
Join date: 19 Sep 2005
Posts: 167
10-01-2008 10:28
Thanks for the replies:)
At least it looks like a step in the right direction.

Another application i thought of was an inworld web browser but different sites have unique layouts for their hot buttons
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
11-20-2008 07:38
heyas;

is there a.. wiki-like explanation entry of these new functions anywhere? like... how do i 'paint' a custom interface and figure out where the 'buttons' are? how do the coordinates work? from 0-100%? heh, or better yet, how do i arrange my interface to use coordinates well?

tips, tutorials...?

thanks guys!
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Wouter Hobble
Registered User
Join date: 25 Mar 2008
Posts: 21
11-20-2008 07:50
From: Bloodsong Termagant
heyas;

is there a.. wiki-like explanation entry of these new functions anywhere? like... how do i 'paint' a custom interface and figure out where the 'buttons' are? how do the coordinates work? from 0-100%? heh, or better yet, how do i arrange my interface to use coordinates well?

tips, tutorials...?

thanks guys!

http://wiki.secondlife.com/wiki/Category:LSL_Functions

Look for the "NEW" button next to the big list at the top.