Author Topic: Coding for Destination Dispatch  (Read 424 times)

Offline eventhorizon

  • Administrator
  • Contributor Level II
  • *****
  • Posts: 389
  • Location: Chicago, IL
    • View Profile
    • Ryan Thoryk's Website
Coding for Destination Dispatch
« on: April 16, 2023, 10:30:38 pm »
I thought of making a tutorial on how to make Destination Dispatch code for your building's elevators.  It's not that hard to switch existing call buttons over to destination dispatch call stations.



Steps to convert an existing building to Destination Dispatch:

  • Add new textures
  • Add elevator ID parameters
  • Create Dispatch Controllers
  • Comment out Call Buttons
  • Create Call Stations (either with a floor panel, or keypad) in place of Call Buttons
  • Add letter indicators above each elevator (this is still under development, but you can use directional indicators for now)


To switch Call Buttons to regular DD Call Stations (with floor numbers)

First, add the indicator textures.  You'll need to create letter textures for each elevator ID that you're using,  In the Simple building, only "A" is used.  The textures that need to be created are "A left", "A right", "back left A" and "back right A", finally "XX" is the error texture:
Code: [Select]
AddText Black, Button<A, nimbus_sans.ttf, 47, <A, -1, -1, -1, -1, center, center, 255, 255, 255
AddText Black, ButtonA>, nimbus_sans.ttf, 47, A>, -1, -1, -1, -1, center, center, 255, 255, 255
AddText Black, Button[]A, nimbus_sans.ttf, 47, []A, -1, -1, -1, -1, center, center, 255, 255, 255
AddText Black, ButtonA[], nimbus_sans.ttf, 47, A[], -1, -1, -1, -1, center, center, 255, 255, 255
AddText Black, ButtonXX, nimbus_sans.ttf, 47, XX, -1, -1, -1, -1, center, center, 255, 255, 255

Next, prepare your elevator by adding an ID parameter to it, for identification by the controller.  Put this into your Elevator section for your first elevator:
Code: [Select]
ID = A

Other elevators should be B, C, D, etc.

After the elevator is created, you'll need to make a Dispatch Controller.  This replaces the "CallButtonElevators" command.  This is how it appears in the Simple building DD demo.
Code: [Select]
#Create a new Dispatch Controller
<Controller 1>
    Name = Dispatch Controller %controller%
    DestinationDispatch = true #turn on Destination Dispatch mode
    Hybrid = true #use hybrid mode (allow both regular and destination routes)
    Range = 5
    MaxPassengers = 10
    Elevators = 1  #assign elevator 1 to controller 1
<EndController>

Once the controller is created, find your Call Button code.  This is what the Simple building has:
Code: [Select]
<Floors 0 to 9>
    CallButtonElevators = 1
    CreateCallButtons , ElevExtPanels, ButtonUp, ButtonUpLit, ButtonDown, ButtonDownLit, 3, 6 - 4.125 - 0.33 - 0.1, 4, front, 0.5, 1, true, 0, 0
<EndFloors>

Comment out the "CallButtonElevators" and "CreateCallButtons" commands.  You can delete them later, but there's a couple things you need from them.
Put the contents of the "CallButtonElevators" into the "Elevators =" list of Controller 1 (shown above).  So if you have 3 elevators, Controller 1 should have a line like this:
Code: [Select]
Elevators = 1 - 3
That finishes your controller.  For the CreateCallButtons command, keep in mind the positioning information, and maybe the background texture (ElevExtPanels).

This next part is what the Simple building has to create the call station.  Make a button panel for the floors of your building similar to the inside of an elevator.  The only real unique change is that you need to set the old call button's position in the SetPosition command, so take it from the call button and put it in there.  Note that in this example, the position in CreateCallButtons above and SetPosition below are the same.  This code also assigns Call Station 1 to Controller 1.

Code: [Select]
SetAutoSize = false, false
<Floors 0 to 9>
    <CallStation 1>
        Name = Call Station %callstation%
        Controller = 1  #assign to Dispatch Controller 1

        #create a button panel and controls
        CreatePanel ElevExtPanels, 6, 5, front, 0.15, 0.15, 0.3, 0.45, 0, 0
        AddControl switch.wav, 2, 2, 0, 0, 0, 0, 1, 7, Button8
        AddControl switch.wav, 2, 3, 0, 0, 0, 0, 1, 8, Button9
        AddControl switch.wav, 2, 4, 0, 0, 0, 0, 1, 9, Button10
        AddControl switch.wav, 3, 2, 0, 0, 0, 0, 1, 4, Button5
        AddControl switch.wav, 3, 3, 0, 0, 0, 0, 1, 5, Button6
        AddControl switch.wav, 3, 4, 0, 0, 0, 0, 1, 6, Button7
        AddControl switch.wav, 4, 2, 0, 0, 0, 0, 1, 1, Button2
        AddControl switch.wav, 4, 3, 0, 0, 0, 0, 1, 2, Button3
        AddControl switch.wav, 4, 4, 0, 0, 0, 0, 1, 3, Button4
        AddControl switch.wav, 5, 3, 0, 0, 0, 0, 1, 0, Button1

        #set position of call station
        SetPosition 3, 4, 6 - 4.125 - 0.33 - 0.1

        AddIndicator mechchime9.wav, Button, Black, front, 0, 0, 0.5, 0.5, 1, 5
    <EndCallStation>
<EndFloors>

Once that's finished, your call station should be working!






To create keypads, use the same steps as above, but in your Textures section, add the Keypad textures.  This is what the Simple building has, textures for 0-99, A (all directions), XX, ?? (invalid floor), minus and star.
Code: [Select]
#Create text for keypad
    AddTextRange 0, 99, Black, Button%number%, nimbus_sans.ttf, 47, %number%, -1, -1, -1, -1, center, cente
r, 255, 255, 255
    AddTextRange 0, 99, BlackLit, ButtonLit%number%, nimbus_sans.ttf, 47, %number%, -1, -1, -1, -1, center,
 center, 255, 255, 255
    AddText Black, Button<A, nimbus_sans.ttf, 47, <A, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, ButtonA>, nimbus_sans.ttf, 47, A>, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, Button[]A, nimbus_sans.ttf, 47, []A, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, ButtonA[], nimbus_sans.ttf, 47, A[], -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, ButtonXX, nimbus_sans.ttf, 47, XX, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, Button??, nimbus_sans.ttf, 47, ??, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, Button-, nimbus_sans.ttf, 47, -, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, Button*, nimbus_sans.ttf, 47, *, -1, -1, -1, -1, center, center, 255, 255, 255

You might also need to create negative floor textures (such as -1, -2, -3, etc), or textures for floors higher than 99.

Follow the previous steps, but for the CallStation section, make a keypad instead of a floor panel.  This panel maps buttons to the Call Station actions.

Code: [Select]
SetAutoSize = false, false
<Floors 0 to 9>
    <CallStation 1>
        Name = Call Station %callstation%
        Controller = 1  #assign to Dispatch Controller 1

        #create a button panel and controls
        CreatePanel ElevExtPanels, 6, 5, front, 0.15, 0.15, 0.3, 0.45, 0, 0
        AddControl switch.wav, 2, 2, 0, 0, 0, 0, 1, Input7, Button7
        AddControl switch.wav, 2, 3, 0, 0, 0, 0, 1, Input8, Button8
        AddControl switch.wav, 2, 4, 0, 0, 0, 0, 1, Input9, Button9
        AddControl switch.wav, 3, 2, 0, 0, 0, 0, 1, Input4, Button4
        AddControl switch.wav, 3, 3, 0, 0, 0, 0, 1, Input5, Button5
        AddControl switch.wav, 3, 4, 0, 0, 0, 0, 1, Input6, Button6
        AddControl switch.wav, 4, 2, 0, 0, 0, 0, 1, Input1, Button1
        AddControl switch.wav, 4, 3, 0, 0, 0, 0, 1, Input2, Button2
        AddControl switch.wav, 4, 4, 0, 0, 0, 0, 1, Input3, Button3
        AddControl switch.wav, 5, 2, 0, 0, 0, 0, 1, InputStar, Button*
        AddControl switch.wav, 5, 3, 0, 0, 0, 0, 1, Input0, Button0
        AddControl switch.wav, 5, 4, 0, 0, 0, 0, 1, InputMinus, Button-

        #set position of call station
        SetPosition 3, 4, 6 - 4.125 - 0.33 - 0.1

        AddIndicator mechchime9.wav, Button, Black, front, 0, 0, 0.5, 0.5, 1, 5
    <EndCallStation>
<EndFloors>

You can also change the "mechchime9.wav" to something like "indicatorsound*.wav" and when the indicator shows something like "XX", it'll play "indicatorsoundXX.wav", or "indicatorsoundA.wav" for elevator A.






For letter indicators above the elevator, I'm still developing that, but for now you can use a Directional Indicator above each elevator.  This is one of the Triton Center's current ones:
Code: [Select]
AddDirectionalIndicator 1, true, true, true, ElevExtPanels, ButtonA, ButtonLitA, ButtonA, ButtonLitA, 3.426 + 0.2 + 0.66 + 0.02, 0, 8.2, right, 0.5, 0.5, true, 0, 0
Basically it just displays the "ButtonA" texture for Up and Down, and the "ButtonLitA" when lit.  Make sure you load the "ButtonA" and "ButtonLitA" textures.
« Last Edit: May 16, 2023, 11:34:26 pm by eventhorizon »

Share on Facebook Share on Twitter


Offline SLIA Productions

  • General Member
  • Posts: 17
    • View Profile
Re: Coding for Destination Dispatch
« Reply #1 on: May 15, 2023, 10:13:40 pm »
snipped. If you want to see this, go to the first post. I snipped it so it;s not too long. -SLIA
Is it possible to add it to a BBC(Beno Building Creator) made building?
Sirens and Lifts Of Iowa, a YouTube Content Creator with 500+ subs.
Favorite siren: FS&S XT22.
Any tornado siren enthusiasts here?

Offline QuarioQuario54321

  • Contributor Level I
  • *
  • Posts: 152
  • Location: Michigan, United States
    • View Profile
Re: Coding for Destination Dispatch
« Reply #2 on: May 15, 2023, 11:56:14 pm »
Well yes. Maybe fix some shafts though with the grouping first though since BBC didn’t allow elevators in different shafts to be on the same controller without you manually coding it in yourself.

But this is a very useful tutorial, I’d pin this.

Offline MultiMonorail

  • General Member
  • Posts: 15
    • View Profile
Re: Coding for Destination Dispatch
« Reply #3 on: May 16, 2023, 11:22:20 am »
Here's some more information regarding the indicators that I'd like to add on:

The indicator now shows the direction of the elevator from the DD panel. This is to tell the traveler where the elevator is.
Because of this, you have to create textures that include both the elevator ID and the direction for the indicator to work properly.

For example:
Code: [Select]
    AddText Black, Button<A, nimbus_sans.ttf, 47, <A, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, ButtonA>, nimbus_sans.ttf, 47, A>, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, Button[]A, nimbus_sans.ttf, 47, []A, -1, -1, -1, -1, center, center, 255, 255, 255
    AddText Black, ButtonA[], nimbus_sans.ttf, 47, A[], -1, -1, -1, -1, center, center, 255, 255, 255

(The [] symbol means that the elevator is behind you in that direction instead of in front of you.)

Offline eventhorizon

  • Administrator
  • Contributor Level II
  • *****
  • Posts: 389
  • Location: Chicago, IL
    • View Profile
    • Ryan Thoryk's Website
Re: Coding for Destination Dispatch
« Reply #4 on: May 16, 2023, 11:35:16 pm »
Here's some more information regarding the indicators that I'd like to add on:

I updated the post with that information.
Like Like x 1 View List