×
Create a new article
Write your page title here:
We currently have 276 articles on Waste Of Space Wiki. Type your article name above or create one of the articles listed here!



    Waste Of Space Wiki

    Keyboard: Difference between revisions

    Content added Content deleted
    (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: Line 1:
    {{Object
    {{Object
    |title1 = {{PAGENAME}}
    |image1 = Keyboard.png
    |image1 = Keyboard.png
    |type = {{#invoke:GetPartInfo|getField|Type}}
    |type = {{#invoke:GetPartInfo|getField|Type}}
    |uses = [[Programming]]
    |uses = <!-- write a short summary of what the part is used for here -->
    |recipe = {{#invoke:GetPartInfo|getField|Recipe}}
    |recipe = {{#invoke:GetPartInfo|getField|Recipe}}
    |raw_recipe = {{#invoke:GetPartInfo|getField|Raw recipe}}
    |raw_recipe = {{#invoke:GetPartInfo|getField|Raw recipe}}
    Line 12: Line 13:
    <!-- Some information -->
    <!-- Some information -->
    The '''Keyboard''' is used in programming to take multiple key inputs.
    The '''Keyboard''' is used in programming to take text input. It is used by clicking on it or connecting it to a [[VehicleSeat]], typing text and pressing enter. It is to note the newline caused by pressing enter to input is included in the text.
    <!-- Automated fields -->
    <!-- Automated fields -->
    Line 21: Line 21:
    ==Configuration==
    ==Configuration==
    {{#invoke:GetPartInfo|getField|ConfigurationLarge}}
    {{#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]]
    [[Category:Parts]]

    Revision as of 10:46, 12 November 2022


    The Keyboard is used in programming to take text input. It is used by clicking on it or connecting it to a VehicleSeat, typing text and pressing enter. It is to note the newline caused by pressing enter to input is included in the text.


    In-game Description

    "Similar to a button, except is programmable to take more than one key input. Can be attached to a vehicle seat or clicked by a player."

    Configuration

    • Cannot be configured.

    Programming Example

    This program takes keyboard input and prints it to a screen

    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
    
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • Axenori • 3 days ago
  • Voivsone • 4 days ago
  • Axenori • 4 days ago
  • Axenori • 5 days ago
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies.