Difference between revisions of "User talk:Prajna Vella"
Prajna Vella (talk | contribs) |
Prajna Vella (talk | contribs) |
||
Line 1: | Line 1: | ||
Please excuse the mess, I am just having a play here to get used to wiki editing, so that I might be able to present useful information (particularly with regard to LSL scripting and sculpties) in a clear and convenient manner. | Please excuse the mess, I am just having a play here to get used to wiki editing, so that I might be able to present useful information (particularly with regard to LSL scripting and sculpties) in a clear and convenient manner. | ||
[[User:Prajna Vella|Prajna Vella]] 12:34, 4 May 2009 (UTC) | [[User:Prajna Vella|Prajna Vella]] 12:34, 4 May 2009 (UTC) | ||
Here is a short script to test the LSL layout: | |||
<lsl> | |||
// Give object contents in a folder to AV on touch - by Prajna Vella | |||
string version = "1.0"; // the script version number | |||
string folder = "Ephemera - Gifts"; // the name of the folder we will give to the AV that touches the object | |||
string title = "Gifts"; // the floating title for the giver object | |||
list contents; // the list of items we will put in the folder | |||
// get the list of the items we will give | |||
getList() { | |||
// how many items are there in the contents? | |||
integer item = llGetInventoryNumber(INVENTORY_ALL); | |||
// we find out the name of this script here so we only have to do it once | |||
string thisScript = llGetScriptName(); | |||
// this efficiently refers to the current item and will loop until we have reached item 0 | |||
while (item) { | |||
// this line gets the item name but first decrements the item counter | |||
// it is very efficient and takes care of the fact itemes are numbered starting with 0 | |||
string thisItem = llGetInventoryName(INVENTORY_ALL, --n); | |||
// we need to check we don't give a copy of this script | |||
if (thisItem != thisScript) | |||
contents += thisItem; | |||
} | |||
} | |||
// we do this as a user defined function so it can be called from both state_entry() and changed() events | |||
config() { | |||
// tell the owner what is happening and get the list of items to give | |||
llOwnerSay("Configuring..."); | |||
getList(); | |||
llOwnerSay("Version " + version); | |||
llOwnerSay("Ready to give folder " + folder); | |||
llOwnerSay("Containing: " + llList2CSV(contents)); | |||
// set the floating text on the giver | |||
llSetText(title, <1.0,1.0,1.0>, 1.0); | |||
} | |||
default | |||
{ | |||
// when the script starts running | |||
state_entry() { | |||
config(); | |||
} | |||
// when someone touches the object | |||
touch_start(integer count) { | |||
// count is how many people touched the object | |||
while (count) { | |||
// we find out the UUID key of the AV that touched | |||
key id = llDetectedKey(--n); | |||
// and give them the folder | |||
llGiveInventoryList(id, folder, contents); | |||
} | |||
} | |||
// when the contents of the object is changed | |||
changed(integer change) { | |||
if (change && CHANGED_INVENTORY) | |||
// we get the list of items again | |||
config(); | |||
} | |||
} | |||
</lsl> |
Revision as of 05:31, 4 May 2009
Please excuse the mess, I am just having a play here to get used to wiki editing, so that I might be able to present useful information (particularly with regard to LSL scripting and sculpties) in a clear and convenient manner. Prajna Vella 12:34, 4 May 2009 (UTC)
Here is a short script to test the LSL layout:
<lsl> // Give object contents in a folder to AV on touch - by Prajna Vella string version = "1.0"; // the script version number string folder = "Ephemera - Gifts"; // the name of the folder we will give to the AV that touches the object string title = "Gifts"; // the floating title for the giver object list contents; // the list of items we will put in the folder
// get the list of the items we will give getList() { // how many items are there in the contents? integer item = llGetInventoryNumber(INVENTORY_ALL); // we find out the name of this script here so we only have to do it once string thisScript = llGetScriptName(); // this efficiently refers to the current item and will loop until we have reached item 0 while (item) { // this line gets the item name but first decrements the item counter // it is very efficient and takes care of the fact itemes are numbered starting with 0 string thisItem = llGetInventoryName(INVENTORY_ALL, --n); // we need to check we don't give a copy of this script if (thisItem != thisScript) contents += thisItem; } }
// we do this as a user defined function so it can be called from both state_entry() and changed() events config() { // tell the owner what is happening and get the list of items to give llOwnerSay("Configuring..."); getList(); llOwnerSay("Version " + version); llOwnerSay("Ready to give folder " + folder); llOwnerSay("Containing: " + llList2CSV(contents)); // set the floating text on the giver llSetText(title, <1.0,1.0,1.0>, 1.0); }
default { // when the script starts running state_entry() { config(); }
// when someone touches the object touch_start(integer count) { // count is how many people touched the object while (count) { // we find out the UUID key of the AV that touched key id = llDetectedKey(--n); // and give them the folder llGiveInventoryList(id, folder, contents); } }
// when the contents of the object is changed changed(integer change) { if (change && CHANGED_INVENTORY) // we get the list of items again config(); } } </lsl>