Check if a notecard has been written

From Fire And Ice Grid
Jump to navigation Jump to search


This is a short LSL script snippet which will work in Opensimulator. The script checks a to see if a notecard name exists. Can be useful in many situations, especially if a notecard must be written before the rest of the script can processes.
If you prefer to download the file it is available along with others on my GitHub Page. This is a useful script to have in your LSL preprocessor folder.

Using The Script

The functionality for this script is contained in the method (sometimes known as a user-defined function or UDF) at the top. Everything inside state_entry is there purely to demonstrate how the function might be used.

Script On Github

LSL And OSSL Script Library On GitHub

Licence

 1 BSD 3-Clause License
 2 Copyright (c) 2020, Sara Payne
 3 All rights reserved.
 4 Redistribution and use in source and binary forms, with or without
 5 modification, are permitted provided that the following conditions are met:
 6 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 7 2. Redistributions in binary form must reproduce the above copyright notice,
 8    this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 9 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.
10 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
11 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
14 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
15 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
16 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
17 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
18 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
19 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Script

 1 /*
 2 Covey Ensure Notecard Is Written method. 
 3 ========================================
 4 This is not a full script, as such i have not added the whole thing, it is intended to be used as a method in the middle
 5 of another script. If you need to be sure that a notecard has been written before allowing the rest of your script to run
 6 just call this method. 
 7 Caveat!! Calling this method on a notecard which will never exist will leave the script in an never ending loop. 
 8 */
 9 
10 EnsureNotecardWritten(string notecardName)
11 {   //holds the scrit in a loop untill the card is written
12     integer notecardWritten = FALSE;
13     while (!notecardWritten)
14     {   //if the status is not written come here
15         if (llGetInventoryType(notecardName) == INVENTORY_NOTECARD) notecardWritten = TRUE; //change to true if its written
16     }  //close while not written 
17 }//close ensure notecard is written.

Syntax Highlighting

GeShi syntax highlighting is enabled on this wiki. <be>

When using the tabs described in the link, change the language part to "lsl". Eg.
syntaxhighlight lang="lsl" line
inside angled brackets <>