Scripting API

Home Scripting API Index Class Overview

com.nolimitscoaster

Class Block


public final class Block
extends Object

Represents a block in the coaster, typically used in the scripted operation mode.

Returned by Coaster.getBlock(name)

Field Summary

static final int LAMP_FLASHING
Constant to be used for registerState, getCurrentLampState
static final int LAMP_OFF
Constant to be used for registerState, getCurrentLampState
static final int LAMP_ON
Constant to be used for registerState, getCurrentLampState
static final int PROTOCOL_V1
Constant that may be used for the protocol parameter of getNormalModeState()
static final int STATE_APPROACHING_BWD
Constant that may be returned by getNormalModeState()
static final int STATE_APPROACHING_FWD
Constant that may be returned by getNormalModeState()
static final int STATE_ERROR_NO_BLOCK
Constant that may be returned by getNormalModeState()
static final int STATE_ERROR_OPERATION_MODE
Constant that may be returned by getNormalModeState() or getState()
static final int STATE_ERROR_UNKNOWN_PROTOCOL
Constant that may be returned by getNormalModeState()
static final int STATE_FULL_MANUAL_MODE
Constant that may be returned by getNormalModeState()
static final int STATE_IDLE
Constant that may be returned by getNormalModeState()
static final int STATE_IN_STATION
Constant that may be returned by getNormalModeState()
static final int STATE_OCCUPIED
Constant that may be returned by getNormalModeState()
static final int STATE_OFFLINE
Constant that may be returned by getNormalModeState()


Method Summary

bool canSemiManualMoveBackward()
  Checks if train can be moved backward in semi manual block mode.
bool canSemiManualMoveForward()
  Checks if train can be moved forward in semi manual block mode.
bool doSemiManualMoveBackward()
  Move train backward in semi manual block mode.
bool doSemiManualMoveForward()
  Tries to move train forward in semi manual block mode.
Coaster getCoaster()
  Returns the coaster this block belongs to
int getCurrentLampState()
  Gets the lamp status of the block like it would be displayed on the control panel.
String getName()
  Returns the name of the block as specified in the section settings
int getNormalModeState(int protocol)
  Returns the current state when not in scripted operation mode.
int getNumberOfTrainsOnBlock()
  Returns the number of trains on the block
Section getSection()
  Returns the section as part of this block
int getState()
  Returns the current state when in scripted operation mode.
void registerState(int state, String text, int lampMode)
  Associate a user definable int value with text and lamp state. The text and lamp state will be shown on the ride panel.
void setAdvanceBwdEnabled(bool enabled)
  Enables or disables the Advance BWD button on the control panel for this block.
void setAdvanceBwdVisible(bool visible)
  Shows or hides the Advance BWD button on the control panel for this block.
void setAdvanceFwdEnabled(bool enabled)
  Enables or disables the Advance FWD button on the control panel for this block.
void setAdvanceFwdVisible(bool visible)
  Shows or hides the Advance FWD button on the control panel for this block.
void setEnableMultipleTrainsOnBlockWarning(bool enabled)
  Enables or disables the warning that will show when multiple trains on this block are detected.
void setState(int state)
  Sets the current state in scripted operation mode. The state's int value can be custom and needs to be registered prior using registerState()


Field Detail


LAMP_FLASHING

public static final int LAMP_FLASHING

Constant to be used for registerState, getCurrentLampState


LAMP_OFF

public static final int LAMP_OFF

Constant to be used for registerState, getCurrentLampState


LAMP_ON

public static final int LAMP_ON

Constant to be used for registerState, getCurrentLampState


PROTOCOL_V1

public static final int PROTOCOL_V1

Constant that may be used for the protocol parameter of getNormalModeState()

Identifies the used protocol of getNormalModeState(). The expected states returned by getNormalModeState() may change in the future. In order to stay compatible, the method takes one parameter which identifies the used protocol. Each protocol version will have a defined set of states that may be returned. PROTOCOL_V1 might return the following states: STATE_ERROR_NO_BLOCK, STATE_ERROR_OPERATION_MODE, STATE_IDLE, STATE_OCCUPIED, STATE_OFFLINE, STATE_IN_STATION, STATE_APPROACHING_FWD, STATE_APPROACHING_BWD, STATE_FULL_MANUAL_MODE


STATE_APPROACHING_BWD

public static final int STATE_APPROACHING_BWD

Constant that may be returned by getNormalModeState()

It means that this block is occupied by a train and that the train is approaching the block section running backward May be returned by getNormalModeState()


STATE_APPROACHING_FWD

public static final int STATE_APPROACHING_FWD

Constant that may be returned by getNormalModeState()

It means that this block is occupied by a train and that the train is approaching the block section running forward. May be returned by getNormalModeState()


STATE_ERROR_NO_BLOCK

public static final int STATE_ERROR_NO_BLOCK

Constant that may be returned by getNormalModeState()

It means that this block node is not a block May be returned by getNormalModeState()


STATE_ERROR_OPERATION_MODE

public static final int STATE_ERROR_OPERATION_MODE

Constant that may be returned by getNormalModeState() or getState()

It means that the operation mode does not match the method used. In scripted operation mode, getNormalModeState() cannot be used, in non scripted operation mode, getState() cannot be used. May be returned by getNormalModeState()


STATE_ERROR_UNKNOWN_PROTOCOL

public static final int STATE_ERROR_UNKNOWN_PROTOCOL

Constant that may be returned by getNormalModeState()

It means that the protocol parameter of getNormalModeState was unknown May be returned by getNormalModeState()


STATE_FULL_MANUAL_MODE

public static final int STATE_FULL_MANUAL_MODE

Constant that may be returned by getNormalModeState()

It means that this block has currently no state, because the operation mode is full manual mode control. May be returned by getNormalModeState()


STATE_IDLE

public static final int STATE_IDLE

Constant that may be returned by getNormalModeState()

It means that this block is empty.


STATE_IN_STATION

public static final int STATE_IN_STATION

Constant that may be returned by getNormalModeState()

It means that this block is occupied by a train and the train is handled by the station controller. May be returned by getNormalModeState()


STATE_OCCUPIED

public static final int STATE_OCCUPIED

Constant that may be returned by getNormalModeState()

It means that this block is occupied by a train. May be returned by getNormalModeState()


STATE_OFFLINE

public static final int STATE_OFFLINE

Constant that may be returned by getNormalModeState()

It means that this block is currently not in operation (e.g. storage tracks in auto mode). May be returned by getNormalModeState()


Method Detail


canSemiManualMoveBackward

public final bool canSemiManualMoveBackward()

Checks if train can be moved backward in semi manual block mode.

Returns:
    true if train can be moved, false if not possible or not in semi manual block mode.

Since:
    2.6.4.0


canSemiManualMoveForward

public final bool canSemiManualMoveForward()

Checks if train can be moved forward in semi manual block mode.

Returns:
    true if train can be moved, false if not possible or not in semi manual block mode.

Since:
    2.6.4.0


doSemiManualMoveBackward

public final bool doSemiManualMoveBackward()

Move train backward in semi manual block mode.

Similar to pressing the block's Backward button on the control panel.

Returns:
    true if train could be moved, false if not possible or not in semi manual block mode.

Since:
    2.6.4.0


doSemiManualMoveForward

public final bool doSemiManualMoveForward()

Tries to move train forward in semi manual block mode.

Similar to pressing the block's Forward button on the control panel.

Returns:
    true if train could be moved, false if not possible or not in semi manual block mode.

Since:
    2.6.4.0


getCoaster

public final Coaster getCoaster()

Returns the coaster this block belongs to

Returns:
    coaster this block belongs to

Since:
    2.5.7.0


getCurrentLampState

public final int getCurrentLampState()

Gets the lamp status of the block like it would be displayed on the control panel.

3 states are possible. Off: no train on the block. On: train is on the block. Flashing: train is approaching to the block.

Returns:
    LAMP_OFF, LAMP_ON, or LAMP_FLASHING

Since:
    2.6.4.0


getName

public final String getName()

Returns the name of the block as specified in the section settings


getNormalModeState

public final int getNormalModeState(int protocol)

Returns the current state when not in scripted operation mode.

In normal operation mode, it will return one of the STATE_ constants (See above) depending on the used protocol. In scripted operation mode, this method has no use and will always return STATE_ERROR_OPERATION_MODE. In scripted operation mode, the getState() method should be used instead.

Parameters:

protocol - Needs to be PROTOCOL_V1. Depending on the used protocol, different states can be returned. Currently there is only one supported protocol which is PROTOCOL_V1

Returns:
    value representing state of normal operation mode (see STATE_ constants)

Since:
    2.5.1.0


getNumberOfTrainsOnBlock

public final int getNumberOfTrainsOnBlock()

Returns the number of trains on the block


getSection

public final Section getSection()

Returns the section as part of this block


getState

public final int getState()

Returns the current state when in scripted operation mode.

In scripted operation mode, it will return the value that was set with setState(). In all other operation modes, it will always return STATE_ERROR_OPERATION_MODE. For normal operation modes, there is a special method getNormalModeState() that can be used to detect the block's state.

Returns:
    custom user value representing state that was set using setState()


registerState

public final void registerState(int state, String text, int lampMode)

Associate a user definable int value with text and lamp state. The text and lamp state will be shown on the ride panel.

This method has only effect when the coaster is in scripted operation mode, otherwise is should not be used.

Parameters:

state - user definable value that acts as a enumerator, should be >= 0, negative values will be used internally for errors.
text - display text of the control panel's text field for this block
lampMode - display mode of the control panel's lamp for this block (Accepts LAMP_OFF, LAMP_ON, LAMP_FLASHING)

setAdvanceBwdEnabled

public final void setAdvanceBwdEnabled(bool enabled)

Enables or disables the Advance BWD button on the control panel for this block.

By default the button is not enabled. The button is used for manual block mode. This method has only effect when the coaster is in scripted operation mode, otherwise it should not be used.


setAdvanceBwdVisible

public final void setAdvanceBwdVisible(bool visible)

Shows or hides the Advance BWD button on the control panel for this block.

By default the button is not visible. The button is used for manual block mode. This method has only effect when the coaster is in scripted operation mode, otherwise it should not be used.


setAdvanceFwdEnabled

public final void setAdvanceFwdEnabled(bool enabled)

Enables or disables the Advance FWD button on the control panel for this block.

By default the button is not enabled. The button is used for manual block mode. This method has only effect when the coaster is in scripted operation mode, otherwise it should not be used.


setAdvanceFwdVisible

public final void setAdvanceFwdVisible(bool visible)

Shows or hides the Advance FWD button on the control panel for this block.

By default the button is not visible. The button is used for manual block mode. This method has only effect when the coaster is in scripted operation mode, otherwise it should not be used.


setEnableMultipleTrainsOnBlockWarning

public final void setEnableMultipleTrainsOnBlockWarning(bool enabled)

Enables or disables the warning that will show when multiple trains on this block are detected.

By default the warning is enabled. It may make sense to disable the warning for special multi-move block scripts. This method has only effect when the coaster is in scripted operation mode, otherwise it should not be used and the method call will be ignored.

Parameters:

enabled - false: do not show warning, true: show warning (default)

Since:
    2.5.7.4


setState

public final void setState(int state)

Sets the current state in scripted operation mode. The state's int value can be custom and needs to be registered prior using registerState()

This method has only effect when the coaster is in scripted operation mode, otherwise it may not be used.

Parameters:

state - int value that was previously registered using registerState()