Jump to content

Is it possible to process objects within objects?


GloriaGlitter
 Share

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

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

Recommended Posts

I have written a script for Landmark management.  When you touch the object (can look like a signpost for instance), a dialog menu opens offering 8 categories e.g. Beaches, Clubs, Stores, etc.  For each category there are 8 sub menus with buttons for 8 beach names, 8 club names, etc.  When the sub menu button is clicked another dialog opens displaying a link (showing just the shortened place name instead of the whole url) to the selected place profile from where the user can read about the place and teleport there if desired.  I have written the script so that all the data is in variables e.g.

string menu1 = "Beaches";

string menu1but1 = "Dusk Point";
string menu1but1url1 = "Tropical%20Seas/70/226/21";
string menu1but2 = "Secret Beach";
string menu1but1url2 = "Opelessence/156/95/21";

etc.

The rest of the script builds the menus and links as described above.

This all works perfectly well.  But I was thinking about what happens when I give the script to another person to use for their own landmarks.  All they need to do is to replace my variables with their own landmark information.  I realised this was 64 place names, 64 urls and 8 category names - 136 variables plus a lot of manual cutting and pasting to get the region information.

So I thought how can I make this simpler for my next owner of this script - could I just get them to place all their landmarks into the signpost object?

So my idea was that they create 8 objects (lets call them sub-objects) and place 8 landmarks into each and place these 8 sub-objects into my main object.  A sub-object name would be "Beaches" for instance which would be used for the category button name and they would also rename the 8 contained landmarks to a shorter name to be used for displaying on the place menu buttons and also for the place profile link.  This would require much less effort for the new script owner.

So first I tackled the process of taking a Landmark and extracting the url information to create my link to the place profile - this works fine.  Having cracked that for one landmark, my next task to accomplish was going to be reading all 8 landmarks within the sub-object and extracting the data to assign to my variables. If I could get that to work then I would repeat this for all 8 sub-objects.

This is when I realised that I needed to be able to process objects within objects and wondered if there was a way to do this as I hadn't seen any script examples that did this - maybe it is not possible within LSL and I would have to go back to the drawing board.  Worst case is that I leave my script as it is and the script owner changes all the variables but it would be more elegant if I could get them to use their existing landmarks in the way I described above.

So, is it possible to process items such as landmarks that are contained within objects which themselves are within an object?  I am half expecting a one-word answer to my question (smiles) but if my idea is not feasible would there be an alternative elegant solution or is my existing script the best way anyway - "if it is not broken don't try and fix it"?

Link to comment
Share on other sites

a way is to encode each menu dialog as a string separated by a pipe char, then parse it to a list on demand

i put some explanatory p-code here as variations on this topic come up quite often

// list places can be inlined or loaded from a notecard
// @0..@n is the ident(ity) marker
list places = [
   "Beaches|Shops",
   "@0", "Warm beaches|2|Dusk Point|Secret Beach|Tropical Seas/70/226/21|Opelessence/156/95/21",
   "@1", "Lovely shops|3|My Shop|Other Shop|Nother Shop|my shop/slurl|other shop/slurl|nother shop/slurl",
   "@2", ...
   "@3", ...
];

string ident;
list buttons;
list slurls;

// to get the top menu
touch_start(...)
{
   ident = "@@"; // top menu ident
   buttons = llParseString2List(llList2String(places, 0), ["|"], []);
   // buttons = [Beaches,Shops]
   llDialog(... buttons, ...);
}


listen( ..., string text)
{
   if (ident = "@@") // top menu ident
   {  
      // make and display the page dialog for the selected top menu item

      integer i = llListFindList(buttons, [text]); // i in [0..n]
      ident = "@" + (string)i;
      
      i = llListFindList(places, [ident]);
      list data = llParseString2List(llList2String(places, i + 1), ["|"], []);

      string desc = llList2String(data, 0);     // menu dialog description
      integer num = llList2Integer(data, 1);    // number of  buttons/slurls for this menu dialog
      buttons = llList2List(data, 2, 1 + num);  // button captions
      slurls = llList2List(data, 2 + num, -1);  // slurls for the buttons

      llDialog(..., desc, buttons, ...)
   }
   else  // is a page
   {
      integer i = llListFindList(buttons, [text]);
      string slurl = llList2String(slurls, i);

      ... do something with slurl ...
   }
}

 

 

Edited by Mollymews
typeo code
Link to comment
Share on other sites

Hi Molly - thanks for replying to my questions.  My existing menu script itself works ok for me and I could move my variables from the script to be read in from a notecard or reorganise them into lists as you suggest.  But what I wanted to achieve though, is to make this process even easier for anyone I share my script with who will want use their own landmarks rather than mine by them simply dragging their landmarks from their inventory into an object.  I wanted to save them the bother of editing the script or notecard. 

Ideally I'd like to have a single object which will contain x number of objects (which I will call sub-objects), each of which will hold the landmarks for a particular category (e.g. beaches, stores, etc).  These sub-objects themselves would be called 'Beaches', 'Stores', etc so that my script would read the sub-object name to create the top level menu buttons.   The next level buttons would be created by processing the landmarks contained within each sub-object. 

This concept though requires my script to be able to 'open' these sub-objects to be able to process the landmarks contained within them.   So my question was more about whether I can access the contents of objects contained in the inventory of a main object where my script would sit rather than about how to build a menu structure.  I have a feeling that this might not be possible.

Link to comment
Share on other sites

To my knowledge you cannot read content of nested objects (objects with objects), the object has to be rezzed i order to examine its content with LSL.

The must easy way to make setup of you advanced sign post is to use notecard setup together with the landmarks, textures etc for each. Most simple by telling the users, they must provide in groups of same numbers. If no NC or no present, define a token or string to represent this. Your end user just drag LM, textures etc into the sign post and update the NC accordingly. Simple example:

[LM]
The Rain Forrest
[texture]
00000000-0000-0000-0000-000000000000
[nc]
Welcome To The Rain Forrest
[present]
Umbrella

Edited by Rachel1206
Link to comment
Share on other sites

Thanks Molly and Rachel - Ok, I got it now - instead of objects think of notecards.  So I could have 8 notecards inside my object, each notecard title being the name of one of my top level menu buttons and within each notecard the 8 relevant landmarks.  I've got something now that I can get my teeth into.  Thanks

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1473 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...