Fixed some things and added an example program
(Created page with "{{Object |image1 = Keyboard.png |type = {{#invoke:GetPartInfo|getField|Type}} |uses = <!-- write a short summary of what the part is used for here --> |recipe = {{#invoke:GetPartInfo|getField|Recipe}} |raw_recipe = {{#invoke:GetPartInfo|getField|Raw recipe}} |malleability = {{#invoke:GetPartInfo|getField|Malleability}} |durability = {{#invoke:GetPartInfo|getField|Durability}} |configuration = {{#invoke:GetPartInfo|getField|Configuration}}...") |
(Fixed some things and added an example program) |
||
Line 1:
{{Object
|title1 = {{PAGENAME}}
|image1 = Keyboard.png
|type = {{#invoke:GetPartInfo|getField|Type}}
|uses = [[Programming]]
|recipe = {{#invoke:GetPartInfo|getField|Recipe}}
|raw_recipe = {{#invoke:GetPartInfo|getField|Raw recipe}}
Line 12 ⟶ 13:
<!-- Some information -->
The '''Keyboard''' is used in programming to take
<!-- Automated fields -->
Line 21:
==Configuration==
{{#invoke:GetPartInfo|getField|ConfigurationLarge}}
== Programming Example ==
This program takes keyboard input and prints it to a screen
<syntaxhighlight lang="lua" line="1">
local Screen = GetPartFromPort(1, 'Screen') -- gets a Screen
local Keyboard = GetPartFromPort(2, "Keyboard") -- gets a Keyboard
Screen:ClearElements() -- Clears screen
local TextLabel = Screen:CreateElement('TextLabel', {
AnchorPoint = Vector2.new(0.5, 0.5);
Position = UDim2.fromScale(0.5, 0.5);
Size = UDim2.fromScale(1, 1);
Text = ' ';
TextSize = 20;
TextScaled = false;
}) -- Creates a container for text
local function WriteScreen(text)
text = text:sub(1, -2) --removes the newline from pressing enter to confirm keyboard input
TextLabel:ChangeProperties({ -- change the text
Text = text;
})
end -- function to edit text label
Keyboard:Connect("TextInputted", WriteScreen)
-- when text is inputted to the keyboard it will run the WriteScreen function
</syntaxhighlight>
[[Category:Parts]]
|