Skip to content

Instantly share code, notes, and snippets.

@clairem-sl
Last active September 26, 2022 15:46
Show Gist options
  • Select an option

  • Save clairem-sl/d7d3da6a94f03c0ca666415af5c0f5f5 to your computer and use it in GitHub Desktop.

Select an option

Save clairem-sl/d7d3da6a94f03c0ca666415af5c0f5f5 to your computer and use it in GitHub Desktop.
Get Region Name, Coordinates, and Position
// Get Region Name, Coordinates, and Position
// in a textual format that can be inserted into a notecard to be inserted
// into the "REZ/GFS finder v1.1" HUD as provided in the MAREFI package
//
// MAREFI : https://marketplace.secondlife.com/p/Mainland-Maps-RezZone-LandMarks-FinderHUD-MAREFI/20221306
// This particular script is released into the Public Domain by Claire Morgenthau
// If Public Domain is not applicable in your Jurisdiction,
// then you can use one of the following: WTFPL, CC0, Unlicense, 0BSD, or MIT-0
// Rez a prim, put this script in the prim, then click the prim
// Afterwards just Take the prim so you don't have to do all the above again, just click the prim :)
string FormatDecimal(float number, integer precision) {
float roundingValue = llPow(10, -precision)*0.5;
float rounded;
if (number < 0) rounded = number - roundingValue;
else rounded = number + roundingValue;
// Rounding integer value
if (precision < 1) {
integer intRounding = (integer)llPow(10, -precision);
rounded = (integer)rounded/intRounding*intRounding;
precision = -1; // Don't truncate integer value
}
string strNumber = (string)rounded;
return llGetSubString(strNumber, 0, llSubStringIndex(strNumber, ".") + precision);
}
default {
state_entry() {
llOwnerSay("I . AM . REZZED !");
}
touch_start(integer ana) {
string regName = llGetRegionName();
vector regCorner = llGetRegionCorner();
vector regPos = llGetPos();
string message =
regName + "*<" +
(string)((integer)(regCorner.x)) + "," +
(string)((integer)(regCorner.y)) + "," +
"0>*<" +
FormatDecimal(regPos.x, 5) + "," +
FormatDecimal(regPos.y, 5) + "," +
FormatDecimal(regPos.z, 5) + ">"
;
llOwnerSay(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment