Changes

Jump to navigation Jump to search
m
no edit summary
{{#seo:
|title=Check if a notecard exists
|title_mode=append
|keywords= firestorm preprocessor, useful script, script snippet, notecard, written, notecard exits, name, names, ossl, lsl, sim, opensim, fire and ice grid, opensimulator, grid, fire, and, ice
|description=A script snippet used to if a notecard exists (has been written). While this should work in Second life because there is no scripted way to write a notecard it is probably not useful in the Second Life.
}}
[[Category: Useful Scripts]]
[[Category: Scripted Tools]]
[[Category: Opensim Script Library]]
[[Category: LSL PreProcessor]]

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.<br>
If you prefer to download the file it is available along with others on my [https://github.com/manwapastorelli/OpenSimLSL 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.

==== Licence ====
<syntaxhighlight lang="ini" 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>

==== Script ====

<syntaxhighlight lang="lsl" line>
/*
Covey Ensure Notecard Is Written method.
========================================
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
of another script. If you need to be sure that a notecard has been written before allowing the rest of your script to run
just call this method.
Caveat!! Calling this method on a notecard which will never exist will leave the script in an never ending loop.
*/

EnsureNotecardWritten(string notecardName)
{ //holds the scrit in a loop untill the card is written
integer notecardWritten = FALSE;
while (!notecardWritten)
{ //if the status is not written come here
if (llGetInventoryType(notecardName) == INVENTORY_NOTECARD) notecardWritten = TRUE; //change to true if its written
} //close while not written
}//close ensure notecard is written.
</syntaxhighlight>

==Syntax Highlighting==

[https://www.mediawiki.org/wiki/Extension:SyntaxHighlight GeShi] syntax highlighting is enabled on this wiki. <be>

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

Navigation menu