Arranging llDialog buttons

Okay, back in Second Life! And/or OpenSim.

A purely Scripting-geekery post today, on a really niche topic.

When you get one of those blue dropdowns (or pop-ups, or drop-ins, depending on your viewer) with a number (up to twelve!) of buttons in them (when you touch a danceball for instance and it asks you what dance you want to do), the piece of LSL (Liden Scripting Language) that shows you that thing with those buttons is a built-in function called “llDialog“.

(All of the built-in functions start with “ll” which presumably stands for “Linden Lab”, but which has made many beginning LSL scripters, including Yers Truly, wonder how an identifier can start with eleven at all.)

One of the arguments to llDialog is, naturally enough, a list of the strings to put on the buttons. And the order in which the strings are copied from the list onto the buttons is… perhaps counterintuitive. For instance, if the list looks like:

[ "one", "two", "three", "four" ]

then the dialog as displayed will look like:

which might not be the first thing one would have guessed.

It basically starts at the bottom, filling rows upward as it goes, until it runs out of strings.

I have sometimes fiddled around to make things come out how I want them to manually, and more often have ignored the problem entirely and just not cared that the buttons were in a stupid order.

But for some reason today I got tired of it and decided to fix it; so here:

list arrange(list l) {
list outl = [];
integer n = llGetListLength(l);
do {
if (n<3) return outl + l;
n = n - 3;
outl = outl + llList2List(l, -3, -1);
if (n==0) return outl;
l = llList2List(l, 0, -4);
} while (TRUE);
return []; // UNREACHABLE
}

This will take a list in an order, and return a list in a different order such that if you pass the new list to llDialog, the labels on the buttons will be in the order that one might expect, left to right and up to down. As in for instance:

llDialog(avatar_id, prompt, arrange(button_list), channel);

It basically just divides the input list into pieces of size three, and then reverses them, with complications in case the input list isn’t equally divisible by three. And because if you ask LSL to copy the first through fourth-to-last (inclusive) elements of a three-element list, it silently copies the entire list rather than (as one might have expected) copying nothing. And because it doesn’t realize that a “do while(TRUE)” will never exit and without the unreachable line you get an error saying that not all code paths return a value. And because llGetListLength is said to be computationally expensive. And because LSL does let you use negative indices (roughly) on lists!

This works in both Second Life and OpenSim, because the scripting languages are extremely compatible for obvious reasons.

Many, many, implementations of this same algorithm no doubt exist all over the place :) but this is mine, for the moment and for what it’s worth!

New random project: Region Mapper

Snapshot of Hughes Rise, as of 2009/03/31So on a complete whim and for no reason that I know of (possibly related to the whole mainland aesthetics discussion), I decided to write a little script that would list all the parcels in a region, in some sort of map-like form.

I had all sorts of techie ideas in my head about little survey ‘bots that would fly around 200m above the ground, communicating to a central controller using llRegionSay() and all, but I was disappointed. :) Turns out llGetParcelDetails() has no range-limit (within the current sim), so a script just sitting under a tree in the Park can see the name and description of every parcel in the Rise.

Here’s the output from my current script (with the longer strings trimmed to fit on the page):

Hughes Rise:
000 000 000 000 001 001 001 001 002 002 003 004 005 005 006 006
000 000 000 000 001 001 001 001 002 002 003 007 007 005 006 006
000 000 000 000 001 001 001 001 008 008 009 007 007 005 005 006
000 000 000 000 001 001 001 001 008 008 009 010 010 010 005 006
011 011 011 011 012 012 013 013 014 014 015 016 010 010 005 005
011 011 011 011 017 018 019 020 014 014 015 016 010 010 021 005
011 011 011 011 017 018 019 020 009 009 022 022 010 010 021 005
011 011 023 023 023 023 020 020 020 024 024 024 024 025 024 002
026 026 023 023 023 023 020 020 020 024 024 024 024 025 024 002
026 026 023 023 023 023 020 020 027 027 024 024 024 024 024 024
028 028 023 023 023 023 029 029 030 031 024 024 024 032 032 024
028 028 033 033 033 033 029 029 030 031 024 024 024 032 032 024
028 028 033 033 023 023 029 029 034 034 035 035 036 037 038 038
039 039 033 040 040 040 023 023 041 041 042 042 036 037 038 038
043 043 044 044 045 045 023 023 046 046 047 047 036 036 036 048
043 043 043 043 045 045 023 023 049 049 050 050 036 036 036 048

000: free resell freebie store full perm: somethings are free , …
001: Computer Land:
002: Hughes Rise :
003: : My first house
004: Galaxy Design: Primland
005: Protected Land: Protected Land
006: Hughes Rise (25,224) Mature 1600m:
007: Galaxy Design real estate – Hughes Rise 6: Flat green land …
008: oms studio 2:
009: The Camel’s Prim Farm:
010: Sadie’s Dyke Bar & Butch Store: Quiet hangout. Dressing room, …
011: Abandoned Land: Land abandoned by My World! (group) on 28-Jan-2009
012: Land ID:21088 (B.O.S) Hughes Rise, Green grassy flat land: Rent …
013: Land ID:21089 (B.O.S) Hughes Rise, Green grassy flat land: Rent …
014: Abandoned Land: Land abandoned by Ash Alecto on 14-Dec-2008
015: Abandoned Land: Land abandoned by Errol Bazar on 09-Oct-2008
016: Himmis Kleines Eckchen ;):
017: Land ID:21087 (B.O.S) Hughes Rise, Green grassy flat land: Rent …
018: Land ID:21086 (B.O.S) Hughes Rise, Green grassy flat land: Rent …
019: Land ID:21085 (B.O.S) Hughes Rise, Green grassy flat land: Rent …
020: Microparadise: Some Land! Woooot!
021: Ad-Vatar and The Question Center: Dr. Destiny
022: Abandoned Land: Land abandoned by Cricket Zipper on 31-Dec-2008
023: Workshop More Prim Farm:
024: Workshop Prim Farm: Workshop Prim Farm
025: Hughes Rise – First Land: Land For The Landless
026: =Hughes Rise=: objects included
027: La’s Tipi: Keep Out
028: Julie’s Place: Julie’s Place
029: Hughes Rise Park, upper section:
030: Dale Inis random Hughes Rise land:
031: oms studio 1:
032: Jilly and om’s Japanese tryst:
033: Bippie’s Home: Bippie and Halo’s home. Friends welcome. IM one …
034: Gray Estates Part Deux:
035: My Secret Hideaway: Sometimes you want to go, where nobody …
036: Sweetwater Retreat (240,232) Mature 1536m:
037: Hughes Rise: Hughes Rise
038: Heavenly Bodies Tattoos & Shapes: Tattoo, Tattoos, Shapes, …
039: Scott’s Seat lowlands:
040: AVATARS AVATARS,Batman,Pooh Bear,Star Wars,Betty Boop, …
041: Hughes Rise (216,145) Mature 512m:
042: DAT LAND:
043: Scott’s Seat: Land in the Mist
044: MeadowSide: Portal to Happiness
045: Workshop: Wherever you go etc.
046: Marqs Gettaway:
047: Workshop Annex: Workshop Annex
048: AI WorkShop: AI Skybox Workshop
049: Abandoned Land: Land abandoned by bWhittl Kips on 08-Jan-2009
050: A Garden : Murasaki Suisei

The map is upside-down, I think, and possibly backwards. And/or sideways. Also it’s numbers instead of some nice visual.

The next thing I’m thinking of is learning enough SVG to produce a more map-like map, with boundaries drawn as lines and all, from the same data (a strictly inworld prim-based version would also be possible, but would probably require quite a few prims). I may or may not ever get around to doing that. :) I might also throw the script into the Wiki at some point, if I think it’s reached the point of non-triviality.

It would also be fun to overlay the parcel map on top of the visual maps that the Second Life API makes available (like the one at the top of the posting there; click through for the API version). Clever SVG might be able to do that also. If anyone knows of anyone else doing anything like any of this, send email or post a comment!

And then I’m still planning a posting about inworld Profile Displayers, which I have a picture all taken for and more or less know what the words will say, but have just not gotten around to. Busy, busy…

Blowing stuff up

In a couple of places recently (Vidal Tripsa and Crap Mariner come to mind, but darned if I can find the actual postings depite long milliseconds of searching) I’ve seen references to causing builds to blow up by setting them physical and temporary, and then delinking them.

The other evening amazing small-stuff maker PatriciaAnne (see her Lilliton for instance) IMd me asking for a script to make something explode, and I jumped at the chance to say “sure” and thus commit myself to figuring out the details and writing a script to do that myself.

I eventually wrote it, and gave it to PatriciaAnne, and also to the world on the Second Life wiki. And now we have a demo!

Here is the thing to be blown up: a popular freebie house, rezzed on a nice seacliff somewhere in Shengri La:

The Beginning

We insert the script, utter the magic words, and ka-boom:

Boom!

Debris flying everywhere!

And here is the result:

Aftermath

Nicely destroyed.

(Some number of seconds later the debris all vanishes automatically; no need for cleanup work…)