Controller
Description:
An interface for handling game controller inputs.
Controller.AxisName
Type: Enumeration.
Description:
Enumeration for defining the controller axis names.
Signature:
enum AxisName
"leftx"
"lefty"
"rightx"
"righty"
"lefttrigger"
"righttrigger"
end
Controller.ButtonName
Type: Enumeration.
Description:
Enumeration for defining the controller button names.
Signature:
enum ButtonName
"a"
"b"
"back"
"dpdown"
"dpleft"
"dpright"
"dpup"
"leftshoulder"
"leftstick"
"rightshoulder"
"rightstick"
"start"
"x"
"y"
end
isButtonDown
Type: Function.
Description:
Check whether a button is pressed down in current frame.
Signature:
isButtonDown: function(self: Controller, controllerId: integer, name: ButtonName): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
controllerId | integer | The controller id, incrementing from 0 when multiple controllers connected. |
name | ButtonName | The name of the button to check. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the button is pressed down. |
isButtonUp
Type: Function.
Description:
Check whether a button is released in current frame.
Signature:
isButtonUp: function(self: Controller, controllerId: integer, name: ButtonName): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
controllerId | integer | The controller id, incrementing from 0 when multiple controllers connected. |
name | ButtonName | The name of the button to check. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the button is released. |
isButtonPressed
Type: Function.
Description:
Check whether a button is in pressed state.
Signature:
isButtonPressed: function(self: Controller, controllerId: integer, name: ButtonName): boolean
Parameters:
Parameter | Type | Description |
---|---|---|
controllerId | integer | The controller id, incrementing from 0 when multiple controllers connected. |
name | ButtonName | The name of the button to check. |
Returns:
Return Type | Description |
---|---|
boolean | Whether the button is in pressed state. |
getAxis
Type: Function.
Description:
Get the axis value from a given controller.
Signature:
getAxis: function(self: Controller, controllerId: integer, name: AxisName): number
Parameters:
Parameter | Type | Description |
---|---|---|
controllerId | integer | The controller id, incrementing from 0 when multiple controllers connected. |
name | AxisName | The name of the controller axis to check. |
Returns:
Return Type | Description |
---|---|
number | The axis value ranging from -1.0 to 1.0. |