- Forums
- :
- Creation Forum
- :
- LSL Library
- :
- Basic Target Scanner HUD
- Start Article
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Basic Target Scanner HUD
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-30-2012 11:28 AM - edited 12-07-2012 07:45 PM
This single prim HUD is just a button that scrolls through nearby players names, photos and user key.
Drop it in a prim and touch the prim and you are set to go. Modify it to suit your particular use in another Hud, weapon, or whatever you want.
<3
Ackley
// Basic Target Scanner HUD
// by Ackley Bing
//
// Drop this in a prim and touch
key HUDtarget;
integer HUDattachpoint=ATTACH_HUD_CENTER_1;
integer senseindex;
key photoReq;
TargetInfo(key id)
{
llSetText(llToLower(llGetDisplayName(id))+"\n"+(st ring)id, <0.0, 1.0, 0.0>, 1.0);
if ( id!=NULL_KEY )
{
photoReq=llHTTPRequest("http://world.secondlife.com/resident/" + (string)id, [], "");
llOwnerSay("Current Target: secondlife:///app/agent/" + (string)id + "/inspect " + (string)id );
}
else
{
llSetTexture("8dcd4a48-2d37-4909-9f78-f7a9eb4ef903 ", 0);
llOwnerSay("No Target");
}
}
default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_TAKE_CONTROLS | PERMISSION_ATTACH);
}
attach(key id)
{
if (id)
{
llSetScale(<0.1, 0.15, 0.1>);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, PRIM_HOLE_DEFAULT, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <2.0, 0.5, 1.0>, <0.0, 0.0, 0.0>, PRIM_ROT_LOCAL, <0.000000, -0.707107, 0.000000, 0.707107>, PRIM_COLOR, 0, <1.0,1.0,1.0>, 1.0, PRIM_COLOR, 1, <0.0,1.0,0.0>, 1.0, PRIM_COLOR, 3, <0.0,1.0,0.0>, 1.0, PRIM_COLOR, 2, <1.0,1.0,1.0>, 0.0, PRIM_COLOR, 4, <1.0,1.0,1.0>, 0.0]);
llRotateTexture(270.0*DEG_TO_RAD,0);
HUDattachpoint=llGetAttached();
senseindex=0;
llSensor("", "", AGENT, 128, TWO_PI);
}
}
on_rez(integer param)
{
if ( !llGetAttached() ) llRequestPermissions(llGetOwner(),PERMISSION_ATTAC H|PERMISSION_TAKE_CONTROLS);
}
touch_start(integer tsn)
{
if ( !llGetAttached() ) llRequestPermissions(llGetOwner(),PERMISSION_ATTAC H|PERMISSION_TAKE_CONTROLS);
senseindex=senseindex+(llDetectedTouchFace(0)==1)- (llDetectedTouchFace(0)==3);
llSensor("", "", AGENT, 128, TWO_PI);
}
sensor(integer num)
{
senseindex=((senseindex<0)*(num-1))+((senseindex>= 0)*(senseindex*(senseindex!=num)));
HUDtarget=llDetectedKey(senseindex);
TargetInfo(HUDtarget);
}
no_sensor()
{
senseindex=0;
HUDtarget=NULL_KEY;
TargetInfo(HUDtarget);
}
http_response(key request_id, integer status, list metadata, string body)
{
if( request_id == photoReq )
{
string photoID;
integer StartIndex=llSubStringIndex(body,"<title>");
integer EndIndex=llSubStringIndex(body,"</title>");
if( StartIndex!=-1)
{
integer tempIndex=llSubStringIndex(body,"imageid")+18;
if(tempIndex>17)photoID=llGetSubString(body,tempIn dex,tempIndex+35);
}
if ( photoID==NULL_KEY || photoID=="" ) photoID="8dcd4a48-2d37-4909-9f78-f7a9eb4ef903";
llSetTexture(photoID, 0);
}
}
run_time_permissions(integer perms)
{
if ( perms & PERMISSION_ATTACH ) llAttachToAvatar(HUDattachpoint);
if ( perms & PERMISSION_TAKE_CONTROLS ) llTakeControls(CONTROL_BACK, FALSE, TRUE);
}
}
Re: Basic Target Scanner HUD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Ackley Bing - view message
11-30-2012 12:43 PM
I suspect that your on_rez event will toss a script error if !llGetAttached() is TRUE. You haven't requested PERMISSION_ATTACH at that point, so it would be safer to write
if (!llGetAttached()) { llRequestPermissions(llGetOwner(),PERMISSION_ATTACH|PERMISSION_TAKE_CONTROLS); }
The same thing is likely to be true of the touch_start event too, because there's nothing that forces the script to reset and enter at state_entry when your HUD is rezzed. Fortunately, the HUD will be attached by the time you can touch it, though, so that's a moot point so long as you request permissions as it's rezzed.
Re: Basic Target Scanner HUD
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Reply to Rolig Loon - view message
11-30-2012 01:04 PM
Thanks again! You people are like the script forum Heroes of SL. I Learns you from U many many moons now!
.... edited post to put in working order. It WAS the bits!! Oh & It IS best to avoid ALL imaginable errors if possible! ![]()
![]()
Ackley

