Skip to main content

MFD

MFD is a multifunctional display that contains buttons.


Structures

ButtonData

This structure contains data about the button.

Fields

  • id [ integer ] The button id.
  • state [ integer ] The status of the button. 1 - pressing, 2 - holding, 3 - released.
  • bool [ boolean ] True if the button is pressed, false if not pressed.
  • holdDuration [ integer ] The duration of holding the button in ticks.
  • holdTimeout [ integer ] After how many ticks the button status will be set to 2.

Functions

getMFDs

sc.getMFDs()

Gets all connected MFDs from the computer.

Returns:

  • [ MFD[] ] All connected MFDs from the computer.

getButtonState

MFD.getButtonState( id )

Get information about a specific button by its id.

Arguments:

  • id [ integer ] The button id.

Returns:


getAllPressedButtons

Get a table of all currently pressed buttons and their data.

MFD.getAllPressedButtons()

Returns:


getButtonsAmount

MFD.getButtonsAmount()

Get the total amount of buttons on the MFD.

Returns:

  • [ integer ] Amount of buttons.

setHoldTimeout

MFD.setHoldTimeout( id, ticks )

Sets the holdTimeout for specific or all buttons.

Arguments:

  • id [ integer ] The button id (-1 for all buttons).
  • ticks [ integer ] The ticks amount.

Example

MyScript.lua
-- Get MFD component
local MFD = sc.getMFDs()[1]

function onLoad()
-- Sets the 15 ticks hold timeout for all buttons
MFD.setHoldTimeout(-1, 15)
end

function onUpdate()
-- Getting the 1-st button data
local button = MFD.getButtonState(1)
print(button)
end