Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

The one prim Keypad

Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
08-12-2008 13:49
(Warning this only works on the Beta (Aditi) Grid, as of this posting, because it relies on Server version 1.24, coming *soon* ™ to a simulator near you)

Here is a simple one line function to use llDetectedTouchST()and return an integer value that would correspond to a key code on a keyboard matrix. I hope that it will simplify making one prim keypads.

CODE

//
//Very Keynes - August 2008
//Beta Grid only as of posting
//
// returns an interger value corresponding to a key matrix, nubered from left to
// right and from top to bottom, when the prim face is touched, in the format ccr,
// therefor a Hexgrid (4x4) will have the following key codes:
//
// 0 10 20 30
// 1 11 21 31
// 2 12 22 32
// 3 13 23 33
//

integer cols = 4; // set to number of columns in matrix
integer rows = 4; // Set to number of rows in matrix

integer keypad(vector loc)
{return 10 * llFloor(loc.x * cols) + (rows - llFloor(loc.y * rows) - 1);}

default
{
touch_start(integer total_number)
{
llOwnerSay((string)keypad(llDetectedTouchST(0)));
}
}


p.s. It is not by accident that it returns the key code in the format used by Hewlett-Packard in their older calculators.
Cypher Ragu
[Mad Scientist]
Join date: 6 Jul 2008
Posts: 174
08-26-2008 20:06
Oooh... interesting.

Thanks for posting this :)
Tegg Bode
FrootLoop Roo Overlord
Join date: 12 Jan 2007
Posts: 5,707
08-26-2008 23:43
From: Very Keynes
(p.s. It is not by accident that it returns the key code in the format used by Hewlett-Packard in their older calculators.

Are you suggesting the developers team calculators are behind the times or that they pulled one apart to work out how to do this ? :)
_____________________
Level 38 Builder [Roo Clan]

Free Waterside & Roadside Vehicle Rez Platform, Desire (88, 17, 107)

Avatars & Roadside Seaview shops and vendorspace for rent, $2.00/prim/week, Desire (175,48,107)
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
08-27-2008 01:30
From: Tegg Bode
Are you suggesting the developers team calculators are behind the times or that they pulled one apart to work out how to do this ? :)

Not at all :), Rather that My favorite calculators are still the old HP's and that I pulled one apart to do this :).
Seriously, I disassembled the ROM so that I could make an emulator. And am still considering using its BCD Math functions in place of the built in Ansi float.
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
08-27-2008 04:36
Be warned that only people running the corresponding new viewer will able to take advantage of this. You may want to add a feature whereby invalid touch values result in a dialogue coming up instead for people on 1.19 or even older viewers?

[edit]I don't mean the OP since the script is just an example, but anyone intending to take advantage of this.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)