Simple on-prim menu script

Last week, I posted the Easy Sticky-Note Script.

This week, I wanted to expand on this idea, of having text automatically created on signs, by creating a hypergrid-enabled teleporter system. The idea is that you’d rez the navigation object, change its description, and it would automatically add itself to your navigational network and update all the other navigation boards out there.

But what if you had two locations with the same name? I’d want the user to be able to decide whether to delete the other one — say, if they were just moving it over a few feet. Or if they wanted to rename this one. And I wanted to give them these options with an easy, on-prim menu.

It should have been easy to find an on-prim menu script to modify, but I couldn’t find one, so decided to write one.

Here it is: Menu on a prim

It’s not particularly useful right off the bat. Here are the key parts you’ll need to change to make it your own:

string main_question = "Favorite color?";
list options = ["Blue", "Red", "Green", "Yellow", "Purple", "None"];
integer main_font_size = 20;
integer options_font_size = 15;

The first four lines of the script are the key details of the menu. It assumes that you want everything on face number one on a square, flat prim, and that your question fits on one line, and your options fit on half a line each. When you run the script, it waits for you to touch the surface of the prim, then figures out which option you picked.

Right now, it doesn’t do anything afterwards except tell you, in local chat, which option you picked.

There are similar scripts out there for Second Life users which are based on having a texture that you put on the surface of the prim. If you want to change the menu, you have to change the texture.

Now, I’d like the menu to be a little bit more … spiffy. But I couldn’t figure out how to highlight the chosen option. Drawing a rectangle around the chosen word replaced everything that was there before, even when I used the osSetDynamicTextureDataBlendFace command instead of osSetDynamicTextureData. Fiddling with transparency didn’t get me anywhere. Finally, I decided to rez partly-transparent rectangles right on top of the menu selection for a few seconds. But my brain gave out before I could figure out how to scale and position the new rectangles correctly.

I did, however, figure out how to make them disappear after a couple of seconds — a one-two punch of llSleep and llDie commands in a tiny little script inside the floating rectangles.

Simple menu script
This prim has a slightly modified version of the script — I took out the “None” option to check that it still worked correctly with an odd number of options.

But when I make my teleporter system, I set it up so that everything is a specific size, and I can rez those little rectangles temporarily all I want.

Meanwhile, if you hate pop-up menus and local chat-based interactions as much as I do, I hope you take this menu script and do whatever you want with it.

I think this approach would be particularly useful for folks using Oculus Rift and similar viewers, who don’t want to see text popping up on-screen. Plus, it will also work for folks using Imprudence and other old viewers that can’t do media-on-a-prim.

The script is completely and entirely written from scratch, with my own fingers, and I hereby contribute it to the OpenSim community under the CC0 license. That means that you can take it and do whatever you want with it, no attribution required. Modify it, sell, anything at all.

Question about child prims

Another reason I made this script was to use it as a teleport board, because I can’t figure out how to update child prims. Maybe someone out there can help me?

So the idea is that I’m going to store a unique ID, the teleporter name, and a list of destinations somewhere in the cloud. (Specifically, in a Google AppEngine database.)

Each time I rez a new copy of the teleporter, I change its description to something new, like, “Main Meeting Room,” or “Daisy’s Freebie Shop” and it would check whether this destination is currently in the list and add it it’s new. Then it will create navigation signs. A big one on top with the name of the current destinations, then a bunch of signs under it for other places in the same system — that is, with the same unique ID.

If I can have those other signs be separate objects, it would be very cool. I can have them hanging from a top bar on, say, a chain. Or nailed to a post, like in MASH.

M*A*S*H signpost.
M*A*S*H signpost.
Maria Korolov