User:Allen Kerensky/Myriad Lite/Myriad Lite Food Potion-Preview6.lsl

From OpenSimulator

< User:Allen Kerensky | Myriad Lite
Revision as of 13:19, 19 March 2013 by Allen Kerensky (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Myriad_Lite_Food_Potion-Preview6.lsl

// Myriad_Lite_Food_Potion-Preview6.lsl
// Copyright (c) 2012 Allen Kerensky (OSG/SL) All Rights Reserved.
// Copyright (c) 2012 Yoshiko Fazuku (Avination/OSG/SL) All Rights Reserved.
// This work is dual-licensed under
// Creative Commons Attribution (CC BY) 3.0 Unported
// http://creativecommons.org/licenses/by/3.0/
// - or -
// Modified BSD License (3-clause)
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice, 
//   this list of conditions and the following disclaimer.
// * 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.
// * Neither the name of Myriad Lite 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 DEVELOPERS ``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 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.
//
// The Myriad RPG System was designed, written, and illustrated by Ashok Desai
// Myriad RPG System licensed under:
// Creative Commons Attribution (CC BY) 2.0 UK: England and Wales
// http://creativecommons.org/licenses/by/2.0/uk/
 
string  VERSION = "0.0.1"; // version number
string  VERDATE = "20120830"; // version date
 
integer CHANMYRIAD = -999;      // channel for Myriad RP events
string  DIV = "|";              // Myriad message field divider
integer HEALAMOUNT = 5;         // heal how many critical/wound boxes?
 
list choices = ["Cancel", "Eat Now!"];
string msg = "Please make a choice. You can only eat this food once";
key ToucherID;
integer channel_dialog;
integer listen_id;
 
default{
 
  state_entry() {
    channel_dialog = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
    llRequestPermissions( llGetOwner(), PERMISSION_ATTACH );
  }
 
  run_time_permissions( integer vBitPermissions )
  {
        if (PERMISSION_ATTACH & vBitPermissions)
        {
            llAttachToAvatar(ATTACH_RHAND);
        }
        else
        {
            llOwnerSay( "You must attach item to use" );
        }
  }
 
  on_rez(integer rez)
    {
        if(!llGetAttached())
        { //reset the script if it's not attached.
            llResetScript();
        }
        ToucherID = llGetOwner();
        llDialog(ToucherID, msg, choices, channel_dialog);
        listen_id = llListen( channel_dialog, "", ToucherID, "");
        llSetTimerEvent(60); //HERE WE SET A TIME LIMIT
    }
 
  touch_start(integer total_number) {
    ToucherID = llDetectedKey(0);
    llDialog(ToucherID, msg, choices, channel_dialog);
    listen_id = llListen( channel_dialog, "", ToucherID, "");
    llSetTimerEvent(60); //HERE WE SET A TIME LIMIT
  }
 
  listen(integer channel, string name, key id, string choice) { 
    key who = llGetOwner();
    integer chanplayer = (integer)("0x"+llGetSubString((string)who,0,6));
    if (choice == "Eat Now!") {
        llListenRemove(listen_id); 
        llRegionSay(CHANMYRIAD,llKey2Name(who)+" has eaten an apple!");
        llWhisper(chanplayer,"HEALPARTIAL"+DIV+(string)HEALAMOUNT); // tell player HUD to heal some damage
        // change aperance or deleate 
    }else{ 
        //do something nothing.
        llListenRemove(listen_id);
    }
  }
 
  timer() { //TIME’S UP!
    llListenRemove(listen_id);
    llSetTimerEvent(0.0); //Stop the timer from being called repeatedly
  }
}
Personal tools
General
About This Wiki