Skip to main content

Payload terminal

Metadata

Name: Payload Terminal
Description: Payload terminal where teams have to escort a payload to the end of a path.
Version: v2.0
Author: Omega77073
Compatibility: >=2.0.0
Supports debug: true

A payload terminal where teams have to escort a payload to the end of a path.

Installation

1. Get the model

Find a file with the model here

2. Move the model

Place the model in Main folder > Addons

3. In the Server script add before loading addons:

wrapper:LoadTerminal(script.Parent.Addons["Terminal-Payload"])

4. Create a path

A payload path is a folder containing waypoints (parts), it starts with a waypoint named START and ends with a waypoint named END. Each waypoint, except the final one should have an ObjectValue child named Next pointing to the next waypoint in the path.

Example of a payload path

5. Prepare your payload model

Your payload model should have a Primary Part set to a part that represents the zone of the payload, it will also be used as the anchor point of the model.

6. Configure the terminal

Configure the terminal

  • Set the payload path by setting the PayloadPath ObjectValue to the folder containing the waypoints.
  • Set the payload model by setting the PayloadModel ModelValue to the model representing the payload.
  • Edit default settings as you wish by editing the attributes of Configuration > Default configuration values

You're done !

Network Optimization

It is recommended to use the Network optimization addon when using this terminal to reduce network usage drastically.

Components

-- See the DefaultComponents module script for reference
function components.updateProgress(terminal: terminal, tickRate: number): { newProgress: number }

function components.movePayloadModel(terminal: terminal, newCFrame: CFrame)

function components.getPlayerCount(terminal: terminal,tickRate: number): { AttackersCount: number, DefendersCount: number }

function components.computeState(terminal: terminal): "locked" | "attacker" | "defender" | "neutral"

function components.getWinner(terminal): "attackers" | "defenders" | "draw" | nil

function components.activateWaypoint(terminal: terminal, waypointIndex: number)

Path events

The payload terminal supports additionnal waypoints events for control over the path behavior.

Add a BindableEvent inside a waypoint and it will be fired when the payload reaches that waypoint with the following data:

{
{
waypointIndex : number, -- index of the waypoint reached
distanceToWaypoint = number, -- distance from the payload to the waypoint

forwardSpeed : number -- speed of the payload forward in the config
backwardSpeed : number -- speed of the payload backward in the config

progress : number, -- current progress of the payload
state : "locked" | "attacker" | "defender" | "neutral", -- current state of the payload

timeLeft : number, -- time left in seconds for the terminal
}
}

Add a StringValuenamed Instructions inside a waypoint to give instructions to the terminal when the payload reaches that waypoint. An instruction string is a JSON formatted list of actions to perform, currently supported actions are:

ActionparametersDescription
waittime: numbermakes the terminal wait for the specified time in seconds before being unlocked
locknonelocks the terminal until manually unlocked
moveProgressprogress: numbermoves the payload by the specified progress amount
moveDistancedistance: numbermoves the payload by the specified distance amount
moveTimetime: numbermoves the payload for the specified time in seconds
setAsMinimumProgressnonesets the current progress as the minimum progress, the payload won't be able to move backward past this point. Useful for doors closing behind the payload

Example instruction strings:

[
{"action":"wait","value":5},
{"action":"moveDistance","value":40}
]
[
{"action":"setAsMinimumProgress"}
]

Events

Event NameParametersDescription
playerCountChangedattackersCount, defendersCountFired when the player count changes
progressChangednewProgressFired when the payload moves
stateChangednewStateFired when the terminal's state changes
endEventwinnerFired when the terminal ends
startEventFired when the terminal starts
partialUpdateA list of changed properties, used for replication