Jump to content

[SCRIPT] Needed ... to select a default picture OR a random one via blue drop down menu


Katherine Heartsong
 Share

You are about to reply to a thread that has been inactive for 1070 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have a simple script that shows a random image from a prims content folder on a selected face when that object is touched. Cool and works perfectly. Now I need a bit more ...

Looking for a script(er) who can provide one step up from that ...

Prim (frame) has say 18 textures in the content folder that appear on a face. When the object is touched, I'd like a blue drop down menu with three buttons: Default, Random, and Cancel.

Cancel simply hides the menu again. Random shows a random one of the 18 images on the front face of the prim. Default shows a specific image of those 18.

Thoughts? Best place to post, or should I post in the Scripting forums? Thanks.

(Maybe something like this ... I'll try this first ... http://wiki.secondlife.com/wiki/Dialog_Menus )

Edited by Katherine Heartsong
  • Like 1
Link to comment
Share on other sites

That's pretty easy to do, although there's a bit of finesse to getting a 'proper' dialog system, that doesn't leave its listen channel always open:

integer gChannel = -27;
string gDefaultTexture = TEXTURE_BLANK; // change this to your default texture.
//end configurable options//
integer gTouchFace;
integer gNTextures;
integer gDialogHandle;
uMenu(key ID)
{
  llDialog(ID,"select an option:",["Default","Random","Cancel"],gChannel);
}
default
{
  changed(integer c)
  { if(c&CHANGED_INVENTORY)
   { gNTextures=llGetInventoryNumber(INTENTORY_TEXTURE);
   }
  }
  state_entry()
  {
    gDialogHandle=llListen(gChannel,"","","");
    llListenControl(gDialogHandle,FALSE);
    gNTextures=llGetInventoryNumber(INTENTORY_TEXTURE);
  }
  touch_start(integer i)
  { gTouchFace=llDetectedTouchFace(0);
    llListenControl(gDialogHandle,TRUE);
    llSetTimerEvent(60.0);
  }
  timer()
  {
    llSetTimerEvent(0);
    llSay(0,"Dialog Timeout");
  }
  listen(integer channel,string name,key ID,string text)
  {
    if(text=="Default")
    { // could use llSetLinkPrimitiveParamsFast instead, but I'm too lazy to type that.
      llSetTexture(gDefaultTexture,gTouchFace);
      uMenu(ID);
    }else if(text=="Random")
    {
      string texture = llGetInventoryName(INVENTORY_TEXTURE,(integer)llFrand(gNtextures));
      llSetTexture(texture,gTouchFace);
      uMenu(ID);
    }else if(text=="Cancel")
    {
      llSetTimerEvent(0);
      llListenControl(gDialogHandle,FALSE);
    }
  }
}

Dialog systems are annoying, so I try to avoid them whenever there's an easier solution.

Edited by Quistessa
retroactively fixed stupid syntax mit-steak
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1070 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...