// ===================================================================== // Notecard Giver // skimi3d script library // https://grid.skimi3d.com/scripts/notecard-giver // // Touch it and it hands over the notecards in its Contents. The sign // by the door that gives you the rules, the info board at the landing // point, the pack of instructions beside a build. // // Plain LSL. // ===================================================================== // --------------------------------------------------------------------- // Settings // --------------------------------------------------------------------- // Which notecard to give, by name. Left empty it gives EVERY notecard // in its Contents at once, as a folder. string NOTECARD = ""; // Floating words above it, so people know it is worth touching. Leave // empty for no label. string LABEL = "Touch for the house rules"; vector LABEL_COLOUR = <1.0, 1.0, 1.0>; // What it says to whoever touched it. Empty says nothing. string THANKS = "On its way. Look in your Inventory, under Notecards."; // Who may take one. 0 = everyone, 1 = only the owner, 2 = same group. integer WHO_MAY_TAKE = 0; // --------------------------------------------------------------------- // Everything below here is the machinery // --------------------------------------------------------------------- integer mayTake(key who) { if (WHO_MAY_TAKE == 1) return who == llGetOwner(); if (WHO_MAY_TAKE == 2) return llSameGroup(who); return TRUE; } // Every notecard in Contents, by name. list allCards() { list out = []; integer n = llGetInventoryNumber(INVENTORY_NOTECARD); integer i; for (i = 0; i < n; ++i) { out += [llGetInventoryName(INVENTORY_NOTECARD, i)]; } return out; } give(key who) { if (NOTECARD != "") { if (llGetInventoryType(NOTECARD) != INVENTORY_NOTECARD) { llOwnerSay("There is no notecard called \"" + NOTECARD + "\" in my Contents."); llRegionSayTo(who, 0, "Sorry, there is nothing here to give you just now."); return; } llGiveInventory(who, NOTECARD); return; } list cards = allCards(); integer n = llGetListLength(cards); if (n == 0) { llOwnerSay("I have no notecards in my Contents, so there is nothing to give."); llRegionSayTo(who, 0, "Sorry, there is nothing here to give you just now."); return; } // One card goes on its own, so it lands in Notecards where people // look for it. Several go as a folder named after this object, // which is the only way they stay together. if (n == 1) { llGiveInventory(who, llList2String(cards, 0)); return; } llGiveInventoryList(who, llGetObjectName(), cards); } default { state_entry() { llSetText(LABEL, LABEL_COLOUR, 1.0); } touch_start(integer total) { // Everyone who touched, not just the first. A group arriving // together should not have to queue at a sign. integer i; for (i = 0; i < total; ++i) { key who = llDetectedKey(i); if (!mayTake(who)) { llRegionSayTo(who, 0, "This one is not for you, sorry."); } else { give(who); if (THANKS != "") llRegionSayTo(who, 0, THANKS); } } } changed(integer what) { if (what & CHANGED_INVENTORY) llSetText(LABEL, LABEL_COLOUR, 1.0); } on_rez(integer start) { llResetScript(); } }