// Wolf Roleplay example - PET SHOP. Owned by the game's owner. Put a no-modify copy of the pet // object ("Wolf pup", with pet.lsl inside, made by the game's owner) in this prim's inventory. // // Buying: 100 coins, then a pet record on the grid (wolfGamePetCreate) and the pet object. The // object finds its own record the first time it is rezzed (pet.lsl), so the pet's name, age and // hunger stay with the pet - not with one copy of the object. integer PRICE = 100; string PET_OBJECT = "Wolf pup"; integer MENU_CH; integer gMenu; key gBuyer; default { state_entry() { MENU_CH = -4000000 - (integer)llFrand(1000000); llSetText("Pet shop\nWolf pup - " + (string)PRICE + " coins\nTouch to buy", <1, 1, 1>, 1.0); } touch_start(integer n) { key av = llDetectedKey(0); if (!wolfGameIsPlaying(av)) { llRegionSayTo(av, 0, "Join the game first."); return; } gBuyer = av; llListenRemove(gMenu); gMenu = llListen(MENU_CH, "", av, ""); llTextBox(av, "Name your wolf pup (" + (string)PRICE + " coins):", MENU_CH); } listen(integer ch, string name, key av, string msg) { if (av != gBuyer) return; llListenRemove(gMenu); string petName = llStringTrim(msg, STRING_TRIM); if (petName == "") petName = "Pup"; // Pay first; if the pet cannot be made, the money goes back. if (!wolfGameExchange(av, ["$", PRICE], [], "bought a wolf pup")) { wolfGameNotify(av, "Pet shop", "Not bought: " + wolfGetLastError(), "warning"); return; } string pet = wolfGamePetCreate(av, "wolf_pup", petName, ["colour", "grey"]); if (pet == "") { string why = wolfGetLastError(); wolfGameExchange(av, [], ["$", PRICE], "refund - pet not made"); wolfGameNotify(av, "Pet shop", "Refunded: " + why, "warning"); return; } llGiveInventory(av, PET_OBJECT); wolfGameNotify(av, "Pet shop", petName + " is yours. Rez the Wolf pup from your inventory.", "success"); } }