Myriad_Lite_Narrator-v0.0.9-20120704.lsl
// Myriad_Lite_Narrator-v0.0.9-20120704.lsl
// Copyright (c) 2012 By Allen Kerensky (OSG/SL)
// The Myriad RPG System was designed, written, and illustrated by Ashok Desai
// Myriad RPG licensed under the Creative Commons Attribution 2.0 UK: England and Wales
// http://creativecommons.org/licenses/by/2.0/uk/
// Myriad Lite software Copyright (c) 2011-2012 by Allen Kerensky (OSG/SL)
// Baroun's Adventure Machine Copyright (c) 2008-2011 by Baroun Tardis (SL)
// Myriad Lite and Baroun's Adventure Machine licensed under the
// Creative Commons Attribution-Share Alike-Non-Commercial 3.0 Unported
// http://creativecommons.org/licenses/by-nc-sa/3.0/
// You must agree to the terms of this license before making any use of this software.
// If you do not agree to this license, simply delete these materials.
// There is no warranty, express or implied, for your use of these materials.
// GLOBALS - CUSTOMIZE THESE IN SETUP() FUNCTION
string MESSAGE; // the description
integer BECOME_PHANTOM; // become phantom, such as an area detect, or stay non-phantom such as when used in floor prim?
integer IGNORE_OBJECTS; // do not send narration to objects (like bullets!) which blunder in
integer RPEVENT_FLAG; // send as Myriad Lite RP event, or as play Say into local chat? HINT - make secrets just for HUD users and public tour stuff for everyone
// GLOBAL RUNTIME variables which change as the script runs
list agents; // list of UUIDs active in sim
key agent_key; // key of who we're narrating to
integer dynachan; // temporary place to calculate the player dynamic channel
// MYRIAD LITE MESSAGE REFERENCE
// CHANPLAYER - OUT - RPEVENT|narrationtext
integer CHAN_REGION = -999;
integer HAND_RUMOR;
integer CHAN_RUMOR;
string API_RUMOR_FIND = "RUMOR_SERVER_FIND";
string API_RUMOR_FOUND = "RUMOR_SERVER_FOUND";
string API_RUMOR_PUT = "RUMOR_PUT";
integer FLAG_DEBUG;
string CHAN_PREFIX = "0x"; // channel prefix for calculating dynamic channel numbers
string API_DIVIDER = "|"; // The field divider within BAM messages
string RUMOR_VISITED; // sent as rumor suffix
//============================================================================
// DEBUG
//============================================================================
DEBUG(string debugmsg) {
if ( FLAG_DEBUG == TRUE ) llInstantMessage(llGetOwnerKey(llGetKey()),"DEBUG: "+debugmsg);
}
//============================================================================
// DEFAULT STATE
//============================================================================
default {
//------------------------------------------------------------------------
// COLLISION_START EVENT
//------------------------------------------------------------------------
collision_start(integer detected) {
while ( detected-- ) {
agent_key = llDetectedKey(detected); // who hit us?
if ( IGNORE_OBJECTS == TRUE && llGetOwnerKey(agent_key) != agent_key ) return; // ignoring objects
if ( llListFindList(agents,[agent_key]) == -1 ) { // does this key already appear in agents list?
if ( llGetFreeMemory() <= 256 ) { // is memory low?
agents = []; // free some memory by emptying agents list
}
agents = [agent_key] + agents; // add this agent
if ( RPEVENT_FLAG == TRUE ) { // say as Myriad Lite RP event, or plain local chat say?
dynachan = (integer)("0x"+llGetSubString(agent_key,0,6)); // calculate avatar's dynamic HUD channel
llSay(dynachan,"RPEVENT|"+MESSAGE); // send them the narration as an RP event
} else {
llSay(PUBLIC_CHANNEL,MESSAGE); // say to anyone, HUD or not
}
// Send a rumor that the player progressed in the quest
if ( CHAN_RUMOR != 0 ) {
string who = llKey2Name(agent_key);
string rumor = API_RUMOR_PUT+API_DIVIDER+who+API_DIVIDER+who+RUMOR_VISITED;
llRegionSay(CHAN_RUMOR,rumor);
}
}
}
}
//------------------------------------------------------------------------
// LISTEN EVENT
//------------------------------------------------------------------------
listen(integer channel,string name,key id,string message) {
channel = 0; // LSLINT
name = ""; // LSLINT
// Rumor server found, save its channel number
if ( message == API_RUMOR_FOUND ) {
CHAN_RUMOR = (integer)(CHAN_PREFIX + llGetSubString((string)id,0,6));
return;
}
}
//------------------------------------------------------------------------
// ON_REZ EVENT
//------------------------------------------------------------------------
on_rez(integer params) {
params = 0; // LSLINT
llResetScript(); // on rez, reset the script from the top
}
//------------------------------------------------------------------------
// STATE_ENTRY EVENT
//------------------------------------------------------------------------
state_entry() {
// EDIT ME TO SAY The SHORT NAME and LONG DESCRIPTION of this area
// Be sure to mention what is seen to the north, east, south, west, above, below, and any RP clues for this area
MESSAGE = "(Myriad Lite Central Example BAM Area) An example of the Myriad Lite implementation of Baroun's Adventure Machine (BAM) for implementing roleplaying quests. Wear a Myriad Lite HUD with BAM Module, and click the BAM Adventure Giver NPC. To the east is the Myriad_Future example region. To the north is the tabletop roleplaying area with Myriad_Modern example region beyond it. To the northwest is the example combat and healing area. To the west is the Myriad Lite character builder area and Myriad_Medieval region beyond it. To the south is the Myriad Combat region.";
// EDIT ME TO SAY a rumor that the person visited this area
RUMOR_VISITED=" visited the Myriad_Central example BAM area.";
// DONE EDITING
BECOME_PHANTOM = TRUE; // become phantom, such as an area detect, or stay non-phantom such as when used in floor prim?
IGNORE_OBJECTS = TRUE; // do not send narration to objects (like bullets!) which blunder in
RPEVENT_FLAG = TRUE; // send as Myriad Lite RP event, or as play Say into local chat? HINT - make secrets just for HUD users and
agents = []; // start with an empty list of who we've shown the narration to
if ( BECOME_PHANTOM == TRUE ) { //if we're not in a floor prim
llVolumeDetect(TRUE); // set us up to detect collisions with the prim volume
} else {
llVolumeDetect(FALSE); // only detect collisions when run into, rather than through
}
if ( HAND_RUMOR != 0 ) llListenRemove(HAND_RUMOR);
CHAN_RUMOR = (integer)(CHAN_PREFIX + llGetSubString((string)llGetKey(),0,6));
HAND_RUMOR = llListen(CHAN_RUMOR,"",NULL_KEY,"");
llRegionSay(CHAN_REGION,API_RUMOR_FIND); // send request for rumor server channel
}
}