Tuesday 3 February 2009

Dialog in Second Life...

integer CHANNEL = 42; // dialog channel list MENU_MAIN = ["Sit", "Stand", "Fly", "Cheat", "Options..."]; // the main menu list MENU_OPTIONS = ["Cherry", "Blueberry", "Vinegar", "Slime", "Chips", "Salad", "...Back"]; // a submenu  default {     state_entry() {         llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)     }          touch_start(integer total_number)      {         llDialog(llDetectedKey(0), "What do you want to do?", MENU_MAIN, CHANNEL); // present dialog on click     }          listen(integer channel, string name, key id, string message)      {         if (llListFindList(MENU_MAIN + MENU_OPTIONS, [message]) != -1)  // verify dialog choice         {             llSay(0, name + " picked the option '" + message + "'."); // output the answer             if (message == "Options...")                  llDialog(id, "Pick an option!", MENU_OPTIONS, CHANNEL); // present submenu on request             else if (message == "...Back")                  llDialog(id, "What do you want to do?", MENU_MAIN, CHANNEL); // present main menu on request to go back             // here you have the name and key of the user and can easily verify if they have the permission to use that option or not             else if (message == "Sit")                  llSay(0, "This is where stuff would happen if this wasn't just an example");         } else              llSay(0, name + " picked invalid option '" + llToLower(message) + "'."); // not a valid dialog choice     } }


/////////// Old Code //////////////////////////

default {     state_entry()     {         llSay(0, "Hello, Avatar!");     }      touch_start(integer total_number)     {         llSay(0, "Touched.");         llParticleSystem([PSYS_PART_FLAGS, PSYS_PART_FOLLOW_SRC_MASK | PSYS_PART_EMISSIVE_MASK,     PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE | PSYS_SRC_BURST_RADIUS,     PSYS_PART_START_COLOR, <1,1,1>,PSYS_SRC_ANGLE_BEGIN,1.57,PSYS_SRC_BURST_RADIUS,110.0,PSYS_PART_START_SCALE,<0.5,0.5,0.5>,PSYS_PART_END_SCALE,<0.5,0.5,0.5>,PSYS_SRC_BURST_PART_COUNT,10]);     } } 


////////////

integer cha = 25; default { state_entry() { // listen on channel zero for any chat spoken by the object owner. llListen(cha,"",llGetOwner(),""); } listen(integer channel, string name, key id, string message) { // check if the message corresponds to a predefined string. // llToLower converts the message to lowercase. // This way, "HELLO", "Hello" or "HeLLo" will all work the same way. if (llToLower(message) == "hello") { // if the message from the owner is "hello", respond with "Hello.". llSay(0,"Hello."); } if (llToLower(message) == "start") { llParticleSystem([PSYS_PART_FLAGS, PSYS_PART_FOLLOW_SRC_MASK | PSYS_PART_EMISSIVE_MASK, PSYS_SRC_PATTERN, PSYS_SRC_PATTERN_ANGLE | PSYS_SRC_BURST_RADIUS, PSYS_PART_START_COLOR, <1,1,1>,PSYS_SRC_ANGLE_BEGIN,1.57,PSYS_SRC_BURST_RADIUS,110.0,PSYS_PART_START_SCALE,<0.5,0.5,0.5>,PSYS_PART_END_SCALE,<0.5,0.5,0.5>,PSYS_SRC_BURST_PART_COUNT,10]); } if (llToLower(message) == "stop") { llParticleSystem([]); } } }

///////////////////////////////

No comments:

Post a Comment

Azure OpenAI Architecture Patterns & Deployment Patterns

Sharing some useful links that will help customers architect Azure OpenAI solution using the best practices: (1) Azure OpenAI Landing Zone r...