I would like a simple HUD button to open this street map, and show the player's location if possible. Any suggestions???

Mos Eisley Street Map copy by TatooineRP SWRP, on Flickr
Code: Select all
float INTERVAL = 20.0;
default
{
state_entry()
{
llSetTexture("map256",4);
llSetTimerEvent(INTERVAL);
integer face = 3;
string CommandList = "";
CommandList = osMovePen( CommandList, 0, 0 );
CommandList = osSetPenColor( CommandList, "Black" );
CommandList = osDrawFilledRectangle( CommandList, 250, 62 );
osSetDynamicTextureDataBlendFace("", "vector", CommandList, "width:256,height:256,Alpha:0", FALSE, 2, 0, 255, face);
}
timer()
{
integer face = 4;
llSetTexture("map256",4);
string CommandList = "";
vector avatar = llGetPos();
CommandList = osSetPenSize( CommandList, 3 );
CommandList = osSetPenColor( CommandList, "Red" );
CommandList = osMovePen( CommandList, llRound(avatar.x), 256 - llRound(avatar.y) );
CommandList = osDrawFilledEllipse( CommandList, 10, 10 );
CommandList = osMovePen( CommandList, 242, 5 );
CommandList = osSetPenColor( CommandList, "Black" );
CommandList = osDrawRectangle( CommandList, 10, 10 );
osSetDynamicTextureDataBlendFace("", "vector", CommandList, "width:256,height:256,Alpha:0", TRUE, 2, 0, 255, face);
}
touch_start(integer n)
{
vector pos = llDetectedTouchST(0);
integer face = 4;
if (llDetectedTouchFace(0) == 4)
{
if ((pos.x > 0.95) && (pos.y > 0.95))
{
rotation rot90X = llAxisAngle2Rot(<0, 0, 1>, 90.0*DEG_TO_RAD);
llSetRot(rot90X);
llSetTimerEvent(0.0);
}
else
{
//nothing at present but could be info and/or tp?
}
}
else
{
llSetRot(ZERO_ROTATION);
llSetTimerEvent(INTERVAL);
}
}
}
Ilan Tochner wrote: ↑Sun May 08, 2022 1:01 pmHi Graham,
Scripts that create dynamic textures are one of the more common causes for avoidable sim server load. Using them too often can easily cause sims to become very laggy. People add signs that each update themselves once every few seconds, or worse without any delay, and each such update takes up communication threads that then slow down much more important sim updates. Having a script that automatically updates a sign every few seconds when no one is viewing it is very wasteful in terms of server capacity. You don't need many such signs to easily cause your world to have high CPU usage even when there are just a few avatars inside it. My recommendation is to avoid scripts that create dynamic textures in a loop.
Code: Select all
vector BOUNDS = <454.86401, 366.99899, 21.54020>;//position of bounding 256x256 m rectangle for map (approximated blow)
float INTERVAL = 20.0;
updateAvatar()
{
string CommandList = "";
vector avatar = llGetPos();
avatar.x = avatar.x - (455-128);//derived from BOUNDS
avatar.y = avatar.y - (367-128);
vector p = llList2Vector(llGetLinkPrimitiveParams(LINK_ROOT, [PRIM_POS_LOCAL]), 0);
llSetLinkPrimitiveParamsFast(LINK_ALL_CHILDREN, [PRIM_POS_LOCAL, <0, 0.25-(0.5*(avatar.x/256.0)), 0.25-(0.5*((256-avatar.y)/256.0))>]);
}
default
{
state_entry()
{
llSetTexture("map256",4);//set via script but could be manually textured
//these steps need to be done manually if not owner/estate manager; in that case remove the code below
//paint the close/hide box at top right
integer face = 4;
string CommandList = "";
CommandList = osSetPenSize( CommandList, 3 );
CommandList = osMovePen( CommandList, 242, 5 );
CommandList = osSetPenColor( CommandList, "Black" );
CommandList = osDrawRectangle( CommandList, 10, 10 );
osSetDynamicTextureDataBlendFace("", "vector", CommandList, "width:256,height:256,Alpha:0", TRUE, 2, 0, 255, face);
//paint the side view part-alpha
face = 3;
CommandList = "";
CommandList = osMovePen( CommandList, 0, 0 );
CommandList = osSetPenColor( CommandList, "Black" );
CommandList = osDrawFilledRectangle( CommandList, 250, 20 );
osSetDynamicTextureDataBlendFace("", "vector", CommandList, "width:256,height:256,Alpha:0", FALSE, 2, 0, 255, face);
//don't remove the next line(s)
llSetTimerEvent(INTERVAL);
}
timer()
{
updateAvatar();
}
touch_start(integer n)
{
vector pos = llDetectedTouchST(0);
if (llDetectedTouchFace(0) == 4)
{
if ((pos.x > 0.95) && (pos.y > 0.95))//hide map
{
llSetLinkAlpha(LINK_ALL_CHILDREN, 0.0, ALL_SIDES);//hide marker
rotation rot90X = llAxisAngle2Rot(<0, 0, 1>, 90.0*DEG_TO_RAD);
llSetRot(rot90X);
llSetTimerEvent(0.0);
}
else//teleporting
{
pos.x = (256*pos.x) + (455 - 128);
pos.y = (256*pos.y) + (367 - 128);
osTeleportOwner(pos, ZERO_VECTOR);
updateAvatar();
}
}
else//unhide map
{
llSetRot(ZERO_ROTATION);
llSetLinkAlpha(LINK_ALL_CHILDREN, 1.0, ALL_SIDES);//unhide marker
llSetTimerEvent(INTERVAL);
}
}
}