Jump to content

Writing a Bus Announcement Script


Wymoree
 Share

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

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

Recommended Posts

Okay. So stepping back from the StaNav HUD project madness. I am pivotting over to the bus announcement script that I had started a while couple weeks ago. This is meant to be a prim worn by an avatar that will provide ADA and other service related announcements. I am trying to make it easier for users to quickly reconfigure their announcement when swapping to a new route. It's features include/should include.

 

  • Posting messages at certain times (Need Improvement - I'd rather have it select a random message from a list each run but right each message is based on a certain static time or interval with in a 5 minute window.)
  • Reading Config From Notecard (WIP - Trying to get this working but the rest of the scipt is functionally broken

Current Issue: For some reason after introducing the notecard reading functionality it doesn't even signal to the user that it was attached or anything is loaded. I can't even start the timer using the "/9 enableann" trigger.

The only i/o I get from it is when the config notecard doesn't exist.

Here is the script:

 

integer count;
integer ON;
key gSetupQueryId;
integer gSetupNotecardLine;
string  gSetupNotecardName = "Config";
 
//define config variables here
string ServiceRoute;
string ServiceNumer;
string DriverID;

readSettingsNotecard()
{
   gSetupNotecardLine = 0;
   gSetupQueryId = llGetNotecardLine(gSetupNotecardName,gSetupNotecardLine); 
}

default
{

    attach(key id)
    {
        if (id)     // is a valid key and not NULL_KEY
        {
            llOwnerSay("ARTA Bus Announcements v. 0.1 Loaded! Use \"/9 enableann\" to enable the messages.");
        }
        else
        {
            llOwnerSay("ARTA Bus Announcements v. 0.1 Unloaded! Have a great day!");
        }
    }
    
    state_entry()
    {

        // Check the notecard exists, and has been saved
        if (llGetInventoryKey(gSetupNotecardName) == NULL_KEY)
        {
            llOwnerSay( "Notecard '" + gSetupNotecardName + "' missing or unwritten");
            return;
        }        
        // listen on channel nine (9) for any chat spoken by the object owner.
        llListen(9,"",llGetOwner(),"");
        readSettingsNotecard();
    }

    listen(integer channel, string name, key id, string message)
    {
        if (llToLower(message) == "enableann")
        {
            llOwnerSay("ADA announcements successfully Reset. Use \"/9 enableann\". to renable announcements.");
            llSetTimerEvent(0.0);
        }
        if (llToLower(message) == "enableann")
        {
            llOwnerSay("ARTA Bus Announcements successfully enabled. Use \"/6 disableann\". to disable announcements.");
            llSetTimerEvent(1.0* (ON = !ON)); //Turns timer ON and OFF
        }
    }

    dataserver(key queryId, string data)
    {
        if(queryId == gSetupQueryId) 
        {
            if(data != EOF)
            {
                list tmp = llParseString2List(data, ["="], []);
                string setting = llList2String(tmp,0);
 
                if (setting == "ServiceRoute")
                {
                    ServiceRoute=llList2String(tmp,1);
                }
                //add more if statements here, for each config variable
                //you can also do stuff like variable=val1,val2,val3, simply
                //do llCSV2List(llList2String(tmp,1));
 
                gSetupQueryId = llGetNotecardLine(gSetupNotecardName,++gSetupNotecardLine); 
            }
            else
            {
                state running;   
            }
        }
    }           
    changed(integer change)
    {
        if (change&CHANGED_INVENTORY)
            llResetScript();
    }

    timer()
    {
        ++count;
        if(count%30 == 0)
        {
            llSay(0,"Route 57 service to "+ServiceRoute);
        }
        if(count == 60)
        {
            //Say this message at the one (1) minute mark
            llSay(0,"Please make priority seating available to passengers with disabiltites and seniors.");
        }
        if(count == 120)
        {
            //Say this message at the two (2) minute
            llSay(0,"Driven by operator 15484");
        }
        if(count == 240)
        {
            //Say this message at the four (4) minute mark
            llSay(0, "Please be curterous. Riders and strollers must share space aboard the bus.");
        }
        if(count == 300)
        {
            //Reset script time and restart messages from first message
            llGetAndResetTime();
            llSetTimerEvent(1.0* (ON = !ON)); //Turns timer ON and OFF
            llOwnerSay("Meeasge Timer Reset.");

        }
    }
}

state running
{

    changed(integer change)
    {
        if (change&CHANGED_INVENTORY)
            llResetScript();
    }
}

Any ideas? Thnak you in advance for any help rendered.

Link to comment
Share on other sites

So, you start the script and it reads a notecard and then...... it goes to state running and stays there forever, unless you add or subtract something from inventory, in which case it simply reads the notecard again and ends up in state running.  It can't respond to any chat commands because (a) it has changed states so the listen handle is no longer valid and (b) there's no listen event in state running anyway.

Not that the timer will ever be engaged, but if it were ... note that there's no way to reset it.  All that the chat command will do is turn the timer on and off, not reset count to zero.  llGetAndResetTime has nothing to do with a timer event.  It is measuring time elapsed since the last script restart or the last time that command was invoked, neither of which does anything to count.

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...