Change font size
It is currently Thu Nov 22, 2018 5:35 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 2   [ 15 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: Teleport Hud with Menu
PostPosted: Mon Mar 14, 2011 1:23 am 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 408
I struggled with how to get this hud working for several days, until it hit me that using various States for the locations could be a solution. So that is what I did. I modified this from the Plaza Teleport System, but am NOT using the single prim for the menu system it used (although it could be used that way), but instead a more flexible pop up menu in the right corner of your viewer. I have gotten use to using a Teleporter Hud on SL and have been looking for one a long time here on SL. But have never found one, so I put one together myself.

It should reside up in your top left corner, so if you attach it there it will work best. As I mentioned before each destination has its own state, this allows me to isolate just the information needed for each location. I have populated the first menu page with OSgird plazas and a few places I like to shop and recommend. I have left out information on the second page, as you can enter your own preferences or even locations in your own sims. You basically make changes in three areas to add new locations or edit old ones. You will see notes in the script as to where to modify or add new locations.

Basically the way it works is once you have it attached to your top left corner, you click on the hud and the menus will pop up. All entries on the first page are active. Once you click on your destination it will confirm this in your chat. The menu will disappear, and you then click on the hud once more. This will bring up the Destination map with the current information on that location. Click the teleport button or double on the map if you wish to land in a different spot. Sometimes you have to teleport twice, as you don't always end up exactly on the right coordinates.

You can add more menu pages also. If I understand correctly, since you can have up to 72 ifs in a script, then it is possible to have up to 72 locations, minus the number of buttons used to go from page to page. Hope you enjoy this hud, and I am pleased to offer this to others to further the use of OSGID and Opensim.

I have placed a free copy of the Hud itself with full permission in the Wright Plaza Freebie building just inside the front door to the left. Working on a skybox teleport rezzer which I already have working, and will be sharing that one shortly too. I added a line of code which should generate a random channel so its not necessary to change it ,I did this because other wise your menu may interfer with a neighbor that has the same hud. I have also disabled the feedback chat as it was for debugging only.

{L_CODE}:
//lsl
////////////////////////////////////////////////////////////////////////
// Script Name: TP Hud With Menu  V1.5
// Author: albertlr Landar
// A teleport hud modified from the plaza teleport system for OSgrid

// when touched, presents a dialog with multiple teleport destinations
// Touch again to teleport - wear in top left corner.  A copy of this
// Script and the hud can be obtained in the Wright Plaza Freebie building.

// This program is free software; you can redistribute it and/or modify it.
// License information must be included in any script you give out or use.
// This script is licensed under the Creative Commons Attribution-Share Alike 3.0 // License from http://creativecommons.org/licenses/by-sa/3.0 unless licenses are
// included in the script or comments by the original author,in which case
// the authors license must be followed.

// Please leave any authors credits intact in any script you use or publish.
///////////////////////////////////////////////////////////////////////////////
string DestinationName;
vector DestinationPos;
vector DestinationLook;
integer CHANNEL; // dialog channel
integer handle;
key ToucherID;


list MENU_MAIN = ["Bade Plaza", "Lbsa Plaza", "SeaPrior Plaza", "Teravus Plaza", "Wright Plaza", "Zaius Plaza", "Sandbox Plaza", "Port Azure", "Snoopies", "ScriptWorkz", "Freebie Mall", "Next..."]; // the main menu
list MENU_OPTIONS = ["Place 1", "Place 2", "Place 3", "Place 4", "Place 5", "Place  6", "Place 7", "Place 8", "Place 9", "Place 10", "Place 11", "...Back"]; // a submenu

CancelListener(){
    llListenControl(handle, FALSE);
    llOwnerSay("Listener Turned Off");  // uncomment if you don't want feed back on the listener status
}

default {

    state_entry() {

        // llResetScript(); // I've disable the llRestScript as it does not seem to be needed.  However you will probably have problems Teleporting between Megaregions, and this might help to recover in those circunctances.  Otherwise you will need to reset the Hud Manually if needed.
    }

    touch_start(integer total_number)
    {
        ToucherID = llDetectedKey(0);
        CHANNEL = (integer)(llFrand(-1000000000.0) - 1000000000.0);
        handle = llListen(CHANNEL, "", ToucherID, ""); // listen for dialog answers from user)

        llListenControl(handle, TRUE); // ...enable listen
        llOwnerSay("Listener Turned On");// uncomment if dialog not wanted.
        llDialog(llDetectedKey(0), "Click A Destination, Then Click The Hud To TP.", 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

        {
            if (message == "Next...")
                llDialog(id, "Click A Destination, Then Click The Hud To TP.", MENU_OPTIONS, CHANNEL); // present submenu on request
            else if (message == "...Back")
                llDialog(id, "Click A Destination, Then Click The Hud To TP.", MENU_MAIN, CHANNEL); // present main menu on request to go back

            else if (message == "Bade Plaza"){
                state Bade;}

            if (message == "Lbsa Plaza"){
                state Lbsa;}

            if (message == "SeaPrior Plaza"){
                state SeaPrior;}

            if (message == "Teravus Plaza"){
                state Teravus;}

            if (message == "Wright Plaza"){
                state Wright;}

            if (message == "Zaius Plaza"){
                state Zaius;}

            if (message == "Sandbox Plaza"){
                state Sandbox;}

            if (message == "Port Azure"){
                state Azure;}

            if (message == "Snoopies"){
                state Samsara;}

            if (message == "ScriptWorkz"){
                state ScriptWorkz;}

            if (message == "Freebie Mall"){
                state Freebie;}

        }

    }

}

state Bade
{
    touch_start(integer num_detected){
        DestinationName = "Bade Plaza";
        DestinationPos = <92.0,115.0,41.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state Lbsa
{
    touch_start(integer num_detected){
        DestinationName = "Lbsa Plaza";
        DestinationPos = <99.0,127.0,40.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state SeaPrior
{
    touch_start(integer num_detected){
        DestinationName = "SeaPrior Plaza";
        DestinationPos = <142.0,130.0,23.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state Teravus
{
    touch_start(integer num_detected){
        DestinationName = "Teravus Plaza";
        DestinationPos = <104.0,137.0,23.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state Wright
{
    touch_start(integer num_detected){
        DestinationName = "Wright Plaza";
        DestinationPos = <128.0,126.0,22.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state Zaius
{
    touch_start(integer num_detected){
        DestinationName = "Zaius Plaza";
        DestinationPos = <120.0,101.0,24.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state Sandbox
{
    touch_start(integer num_detected){
        DestinationName = "Sandbox Plaza";
        DestinationPos = <133.0,95.0,23.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state Azure
{
    touch_start(integer num_detected){
        DestinationName = "Port Azure";
        DestinationPos = <133.0,95.0,23.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state Samsara
{
    touch_start(integer num_detected){
        DestinationName = "Samsara";
        DestinationPos = <154.0,15.0,23.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state ScriptWorkz
{
    touch_start(integer num_detected){
        DestinationName = "ScriptWorkz";
        DestinationPos = <131.0,130.0,24.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}

state Freebie
{
    touch_start(integer num_detected){
        DestinationName = "Wright Plaza";
        DestinationPos = <34.0,142.0,22.0>;
        DestinationLook = <128.0,128.0,22.0>;
        llMapDestination( DestinationName, DestinationPos, DestinationLook );
        CancelListener();
        state default;}
}


The only places it does not work are areas where scripts are not allowed. It will get you there but you will have to use landmarks to leave. You may encounter problems if Teleporting from one Mega REgions to another, so if you need to reset the script you can do this without removing it. It is full permission so you can edit just the visible hub link, and reset it while it is attached. May add a reset button at some point if its needed. Enjoy.


Last edited by albertlr Landar on Sat Apr 23, 2011 1:58 am, edited 8 times in total.

Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Mon Mar 14, 2011 3:17 pm 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 408
Ok confession.... I discovered two little problems with the script I first posted. One I forgot to remark out the debug feedback to chat. So I have now revised it and those two areas are now disabled. You don't want your neighbor knowing necessarily where you are teleporting too. No longer need to change the channel because I added a random channel line of code. So if you had already downloaded the script, get the above revised version. I have also replaced the actual hud at Wright Plaza with these changes.


Last edited by albertlr Landar on Mon Mar 14, 2011 10:50 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Mon Mar 14, 2011 5:28 pm 
OSG Elite
User avatar

Joined: Thu Dec 11, 2008 7:51 am
Posts: 392
Location: England UK
Hi albertlr,

You might want to take a look at this script I created a while ago. It should complement your HUD very well in generating a unique channel per avatar.

viewtopic.php?f=5&t=2798

_________________
"Nothing lasts forever; It's scientific"
~David Byrne (Talking Heads)


Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Mon Mar 14, 2011 9:09 pm 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 408
Thanks Adelle for the suggestion. You have an interesting way of getting the end result. But I had found a little code snippet that probably works with only one line.

I have updated the script above with this.

Just changed the line integer CHANNEL = 4501;
to integer CHANNEL;

and added just before the llListen line the following:

CHANNEL = (integer)(llFrand(-1000000000.0) - 1000000000.0);

And it produces a random number between -1000000000 and -2000000000.

It seems to work....

thank you again.


Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Tue Mar 15, 2011 6:51 am 
OSG Elite
User avatar

Joined: Thu Dec 11, 2008 7:51 am
Posts: 392
Location: England UK
Yep that will work just as well, infact I do use that for some scripts too. You might also want to look at llListenControl (http://lslwiki.net/lslwiki/wakka.php?wa ... tenControl) using a timer of say, 30 seconds to turn off the listener, then turn it back on again on touch.

The reason I developed my technique was for a HUD that 'talked' to an object the avatar was sitting on. The HUD had to talk on the same channel as the object the avatar was sitting on, so using that method in both the HUD and the 'seat' was able to generate the same channel based on the avatar's UUID and goes something along these lines:

Avatar wears HUD
Channel is generated from llGetOwner

Avatar sits on object
Channel is generated from llAvatarOnSitTarget

Both results are identical and unique and can be used to 'say' from the HUD and 'listen' in the object on the same channel, whilst avoiding cross-talk from identical scripts/objects in listen range.

Obviously that doesn't apply to your script, but thought I would share that with you anyway :)

_________________
"Nothing lasts forever; It's scientific"
~David Byrne (Talking Heads)


Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Tue Mar 15, 2011 12:58 pm 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 408
Thanks again Adelle, thats a great idea to better control the llListen. I have been programming in Basic, DbaseII, Fox and Visual Foxpro for many years, but getting into LSL is a little challenge to me. Having worked for non profits most of my life, we had limited funds most of the time, so I had to write our own applications to get things done. I was even considering writing something to convert MYSQL data to Visual Foxpro and back, but not sure that would work well. And I have updated the script to include the new code you suggested. Thanks again for your guidance.


Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Sat Apr 23, 2011 1:21 am 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 408
Well after examining my original script more closely I discovered a bug. I had used a code section for the LSL examples for turning off the listener. The problem is it would only turn off if you issue the word "off" in chat. And on top of that it had to be on the specific channel that the script chose which was random. So if you did not issue the command on the right channel the listener would keep going. So I resorted to a simple on off change. Now when you click the Hud the first time it will turn the listener on, when you click the hud the second time to bring up the teleport map, it turns the listener off. This will be confirmed with a message in chat to remind you. Now be warned if you do not click the hud the second time, the listener will continue and you can contribute to lag with it. You do not have to teleport, you can close the TP map without teleporting, but the listener will be turned off if you just click the hud a second time. I have also resolved a bug, where if you teleport into an area where scripts are turned off, if you then teleport using a landmark to get out,the next time you try to use the Hud it would get into a loop of continually giving you the main menu and never go to the teleport map unless you reset the script. I discovered that the initializion variables in the state_entry() were being corrupted, so I moved them down after the touch_start, and that seemed to resolve that issue. I did leave a llResetScript() under the state_entry() disabled. But do not think that will be needed. Therefore I have replaced the above script with the new changes. Anyone that used the old one can just copy and paste the new one into your hud. But remember you will need to add any changes to your destiantions. I am going to post another version of my hud soon with more menu choices to fill in for those that may have a hard time in expanding it. I have also put a the new update replacing the one in the Freebie building in Wright Plaza.


Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Sat Apr 23, 2011 2:48 am 
OSG Elite
User avatar

Joined: Sat Nov 06, 2010 10:19 am
Posts: 1055
Location: Czech Republic
Interesting script :)

Did you even considered make it more for non-scripters. Eg split it into separate primmy "buttons" which would contain up to 12 LM. The script could then load inventory and get teleport data from the LM's inside via llRequestInventoryDat and location names for buttons just from it's names..

So any non-scripter could easily manage the bookmarks.

Cheers Bo


Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Sat Apr 23, 2011 7:20 am 
OSG Elite
User avatar

Joined: Thu Dec 11, 2008 7:51 am
Posts: 392
Location: England UK
albertlr, what I do when using listen handles is to use a timer set to say, 30 seconds after which it will remove the listen. You could implement this so you touch the HUD, the menu comes up, then after 30 seconds of inaction it automatically turns the listen off. This will get around the having to touch twice.

_________________
"Nothing lasts forever; It's scientific"
~David Byrne (Talking Heads)


Top
 Profile  
 
 Post subject: Re: Teleport Hud with Menu
PostPosted: Sat Apr 23, 2011 11:18 am 
Site Admin

Joined: Sun Nov 28, 2010 5:09 pm
Posts: 408
Adelle I actually tried to use the timer but because I am using multiply states I kept running into problems with it, and the listener was being turned off at the wrong times. In a situation where there is just one main state it works ok. I am still experimenting so if I can eventually figure out how to get it to work under these circumstances I will revise it. But any suggestions would be appreciated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 15 posts ]
Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net