Keyboard - iimurpyh/pilot-lua GitHub Wiki
A device which allows you to get player input using a keyboard-like interface.
Table of contents
Methods
void Keyboard:SimulateKeyPress(string? key, string Player)
void Keyboard:SimulateTextInput(string? input, string Player)
Events
Keyboard.KeyPressed (KeyCode key, string keyString, UserInputState state, string Player)
Keyboard.TextInputted (string text, string Player)
void Keyboard:SimulateKeyPress(string? key, string Player)
Simulates a key press just like you would press a key on the keyboard.
void Keyboard:SimulateTextInput(string? input, string Player)
Simulates textinput just like you would type in the keyboard and enter.
Event "KeyPressed" (KeyCode key, string keyString, UserInputState state, string Player)
An event which fires when a player sitting on a Seat connected to the Keyboard presses a key.
keyString
is the key pressed as a string (for example,a
if the player pressed A.) If shift is held, the keyString will be capitalized. If the key is non-printable (i.e. shift or backspace)keyString
will be nil.state
is always Enum.UserInputType.End.
Event "TextInputted" (string text, string Player)
An event that fires when a player inputs text and presses "Enter" (or "Return") on the keyboard.
Code example
Change the telescope coords with a keyboard and print out the data. Doesn't require formatting. Can be upgraded to use a screen instead of printing to the console.
local keyboard = GetPartFromPort(1, "Keyboard") --> Same deal here, but with a keyboard.
local telescope = GetPartFromPort(1, "Telescope")
keyboard:Connect("TextInputted", function(text) --> Attach the function to the event "TextInputted".
telescope:Configure:({ ViewCoordinates = text .. ", false" })
print(JSONEncode(telescope:GetCoordinate()))
end)