Changes

Jump to navigation Jump to search
Created page with "==== Licence ==== <syntaxhighlight lang="" line> BSD 3-Clause License Copyright (c) 2020, Sara Payne All rights reserved. Redistribution and use in source and binary forms, wi..."
==== Licence ====
<syntaxhighlight lang="" line>
BSD 3-Clause License
Copyright (c) 2020, Sara Payne
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</syntaxhighlight>

<syntaxhighlight lang="lsl" line>
vector landing;
vector lookAt;
string gridUri;
string regionName;
string destination;

integer mainMenuChannel; //global integer for menu channel
integer mainMenuChannelListen;//clobal control integer for turning menu listen on and off

SetUpListeners()
{//sets the coms channel and the random menu channel then turns the listeners on.
mainMenuChannel = (integer)(llFrand(-1000000000.0) - 1000000000.0); //generates random main menu channel
mainMenuChannelListen = llListen(mainMenuChannel, "", NULL_KEY, "");//sets up main menu listen integer
llListenControl (mainMenuChannelListen, FALSE); //turns off listeners for main menu channel
}//close set up listeners

string CleanUpString(string inputString)
{
string cleanString = llStringTrim( llToLower(inputString), STRING_TRIM );
return cleanString;
}

ReadConfigCards(string notecardName)
{ //Reads the named config card if it exists
if (llGetInventoryType(notecardName) == INVENTORY_NOTECARD)
{ //only come here if the name notecard actually exists, otherwise give the user an error
integer notecardLength = osGetNumberOfNotecardLines(notecardName); //gets the length of the notecard
integer index; //defines the index for the next line
for (index = 0; index < notecardLength; ++index)
{ //loops through the notecard line by line
string currentLine = osGetNotecardLine(notecardName,index); //contents of the current line exactly as it is in the notecard
string firstChar = llGetSubString(currentLine, 0,0); //gets the first character of this line
integer equalsIndex = llSubStringIndex(currentLine, "="); //gets the position of hte equals sign on this line if it exists
if (currentLine != "" && firstChar != "#" && equalsIndex != -1 )
{ //only come here if the line has content, it does not start with # and it contains an equal sign
string instruction = llGetSubString (currentLine, 0, equalsIndex-1); //everything before the equals sign
string data = llGetSubString(currentLine, equalsIndex+1, -1); //everything after the equals sign
instruction = CleanUpString (instruction); //sends the instruvtion to the cleanup method to remove white space and turn to lower case
data = CleanUpString (data); //sends the data to the cleanup method to remove white space and turn to lower case
ProcessInstructionLine(instruction, data); //sends the instruction and the data to the Process instruction method
}//close if the line is valid
else
{
if ( (currentLine != "") && (firstChar != "#") && (equalsIndex == -1))
{
llOwnerSay("Line number: " + (string)index + " is malformed. It is not blank, and does not begin with a #, yet it contains no equals sign.");

}
}
}
}//close if the notecard exists
else
{ //the named notecard does not exist, send an error to the user.
llOwnerSay ("The notecard called " + notecardName + " is missing, please address this");
}//close error the notecard does not exist
}//close read config card.

DeliverInfo(key aviUUID)
{
list inventoryItems;
integer inventoryNumber = llGetInventoryNumber(INVENTORY_ALL);
integer index;
for (index = 0; index < inventoryNumber; ++index )
{
string itemName = llGetInventoryName(INVENTORY_ALL, index);
if (itemName != llGetScriptName())
{
if (llGetInventoryPermMask(itemName, MASK_OWNER) & PERM_COPY)
{
inventoryItems += itemName;
}
else
{
llSay(0, "Unable to copy the item named '" + itemName + "'.");
}
}
}
if (inventoryItems == [] ) llSay(0, "No copiable items found, sorry.");
else llGiveInventoryList(aviUUID, llGetObjectName(), inventoryItems); // 3.0 seconds delay
llResetScript();
}

ProcessInstructionLine(string instruction, string data)
{
if (instruction == "landing")
{
landing = (vector)data;
}
else if (instruction == "lookat")
{
lookAt = (vector)data;
}
else if (instruction == "griduri")
{
gridUri = (data);
}
else if (instruction == "regoin")
{
regionName = (data);
}
destination = gridUri + "/" + regionName;
}

Teleport(key aviUUID)
{
if (destination == "" || destination == "/")
{
llOwnerSay("Debug:Teleport: No Desination");
osTeleportAgent(aviUUID, landing, lookAt);
}
else
{
llOwnerSay("Debug:Teleport: Desitination Set");
osTeleportAgent(aviUUID, destination, landing, lookAt);
}
llRegionSayTo(aviUUID, 0, "Teleporting you to : " + destination);
}

default
{
changed (integer change)
{
if (change & (CHANGED_OWNER | CHANGED_INVENTORY | CHANGED_OWNER | CHANGED_REGION_START))
{
llResetScript();
}
}

on_rez(integer start_param)
{
llResetScript();
}

state_entry()
{
SetUpListeners();
ReadConfigCards("Location");
}

touch_start(integer count)
{ //someones touched the prim
llListenControl (mainMenuChannelListen, TRUE);
list buttons = ["Teleport", "GetInfo"];
llDialog(llDetectedKey(0), "Please select from the following options", buttons, mainMenuChannel);
llSetTimerEvent(30);
}// close touch start

listen(integer channel, string name, key id, string message)
{//listens on the set channels, then depending on the heard channel sends the message for processing.
if (channel == mainMenuChannel)
{
llOwnerSay(message);
if (message == "Teleport") Teleport(id);
else if (message == "GetInfo") DeliverInfo(id);
}
}//close listen

timer()
{
llWhisper(PUBLIC_CHANNEL, "sorry the menu timed out, please click again");
llResetScript();
}

}// close state default
</syntaxhighlight>

Navigation menu