newbie question : implementation of a waiting room.

hi,
I have a query about how best to implement a waiting room scene with use of one of those “take a number” queuing gizmos.

ideally I’d like the player to enter the waiting room, talk to the receptionist, and be told to take a number (this much I’ve done so far… fairly straightforward)

The bit I’ve not done is the waiting code. basically say you have number 42 and they’re calling number 40. you would have a number of turns per number for you to read the assorted waiting room magazines, look at the posters, listen to the muzak, observe the other patients etc etc

as an aside, it would be ‘fun’ if when they called your number if you didn’t respond in a couple of turns you’d lose your spot and have to pick another number.

I don’t want the player to be stuck for hours in real time… Just a handful of turns. my game idea is all about bureaucracy and I thought this would be fun to try… but I’ve been unable to make it work quite right.

Beowulf:

Here’s my take, using the adv3lite library (if you’re not using that library, some code modifications will be required but the logic should work):

In the gPlayerChar object’s beforeTravel() method, set the ticket number and the number currently being served for the next ticket to be retrieved in the waiting room:

[code]thePlayer: Actor ‘The player’ @entry
“The player.<.p>”
isHim = true

beforeTravel(traveller, connection)
{
    // reset the ticket number and currently serving number whenever the
    // gPlayerChar enters to waiting room
    if(connection.destination == waitingRoom)
    {
        ticketNum = getNewTicketNum();
        ticket.ticketNum = ticketNum[1];
        ticket.currentlyServing = ticketNum[2];
    }
    // retrieve ticket from player when gPlayerChar leaves the waiting room
    if(gLocation == waitingRoom)
        ticket.moveInto(waitingRoom);
}

;[/code]

The ticket numbering scheme depends on a function defined somewhere in your code base. I maintain a misc_functions.t file in each project for just such needs. (I have defined this method to return a number pair that is randomly selected from a defined list; you can define the method any way you want—to always return the same numbers, or to advance sequentially through your defined list, or…-?-):

getNewTicketNum() { // wating room ticket number and currently serving number returned as a // list---ticketNums[1] is ticket number, ticketNums[2] is currently serving // number at time of retrieval local ticketNums = [[40,38],[41,38],[42,38]]; return rand(ticketNums); }

In the waitingRoom object, define two variables to keep count of the number of turns between advances of the number being served, then monitor these variables in the waitingRoom object’s roomDaemon() method:

[code]waitingRoom: Room ‘Waiting Room’
desc
{
"The waiting room. ";
if(ticket.location != thePlayer)
“A sign above a roll of tickets says, Please take a ticket and
wait for your number to be called.
”;
“<.p>”;
}
north = entry

// counters for number of waits
numWaits = 0
// number of waits before 'currently serving' number advances
maxWaits = 3

// announce number currently being served whenever the player commits an 
// action in the waiting room; advance the 'currently serving' number as 
// appropriate
roomDaemon()
{
    if(numWaits++ == maxWaits)
    {
        numWaits = 0;
        ticket.currentlyServing++;
    }
    "Now serving ticket number ";
    say(ticket.currentlyServing + 1);
}

;[/code]

The ticket itself is a child of the waitingRoom object

+ ticket: Thing 'ticket' desc { if(ticket.location == gPlayerChar) "Your number is "; else "The next available ticket is "; say(ticketNum); ". Currently serving "; say(currentlyServing); ".<.p>"; } // ticket number and currently serving number will be reset whenever the // gPlayerChar enters the wating room; see beforeTravel() method in the // gPlayerChar object definition ticketNum = 0 currentlyServing = 0 ;

Note that I have not handled what happens if the player has not responded to the clerk’s call for the number on the ticket. How that gets coded depends in large part on what it is you want to happen. But it should be easy to add that code once you’ve settled on a plan of action.

Jerry

Sorry for the delay in getting back to you.

That looks great !! Certainly gives me ideas to play with and take further! Thank you !