×
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
    Diagram for how to construct a basic computer including a MicroController.

    Waste of Space features a programming language named Pilot.lua. Pilot.lua lets players manipulate the states of objects in-game. As Pilot.lua is a superset of Luau – Roblox' superset of Lua 5.1 learning Luau (or at least Lua 5.1) first would be beneficial.

    Documentation for all the parts can be found here [1]. Important parts for programming:

    • Microcontroller - Runs code when triggered by Polysilicon if it is powered. This is an essential part, as it is the only way to run code.
    • Port - Allows the Microcontroller to interact with other objects, configure them, and send triggers. While not strictly essential, it is still a core part of programming as it is the only way for a Microcontroller to interact with its surroundings.
    • Screen - Displays user interface objects on its surface using Gui elements (such as TextLabel, Button, ..). It is one of the most common ways to provide the user with feedback as it is able to display it in a clear, visual way. It can be to a certain extent supplemented with the much easier to program signs.
    • Disk - Stores values in a dictionary format. Can store large amounts of data like code and model codes. Data stored on a disk is permanent, as opposed to variables on a microcontroller (which are lost when the microcontroller is powered off, or the server is restarted).
    • EthernetCable (optional) - Allows Ports to reach further when placed touching the hole of the port, similar to how a wire allows power to reach further.
    • (UNSTABLE) Router (optional) - The router is the Antenna of ethernet cables. It does the same thing as ethernet cables, only wireless. This is incredibly useful, as it allows for wireless connections, and allows for parts to be connected from across the region. Note that this is ONLY in unstable.

    Other less-important items in coding include:

    • Modem - Allows for cross-region message passing and communication with arbitrary www domains (Sends GET and or POST requests to either the WOS internet, or the real (www) one). Allows for the creation of an internet of sorts. See the article for more details.
    • LifeSensor - Returns the names of players and their Vector3 location, if they are within its range. Can be used to make, for example, smart turrets.
    • Gyro - Not programming-exclusive, though still widely used as it has a programmable method called gyro:PointAt(vector3 position). This, along with LifeSensor, can make an accurate turret, or if you just want to make the gyro point at a certain place.
    • Keyboard - Used for inputting text, commands, or when attached to a Seat or VehicleSeat, can be used to get keys pressed to make keybinds.
    • Microphone - Retrieves chat messages. Can be used for chat logs or chat commands.
    • Instrument - Measures physical properties such as temperature or velocity.
    • TouchScreen - A improved version of the Screen, as it allows you to get the X and Y (in offset) of the cursor on the screen. Note that you can use buttons on Screens for User input.

    As an example, the code below is code for a smart turret that takes chat commands and targets players accordingly, with the command target playername:

    local Gyro = GetPartFromPort(1, "Gyro") -- Gets gyro attached to port 1
    local Microphone = GetPartFromPort(2, "Microphone") -- Gets microphone attached to port 2
    local Commanders = { -- List of usernames allowed to use the smart turret
      ["Robuyasu"] = true;
    }
    -- Connects to the microphone, adding an event to it that will listen for chat input
    Microphone:Connect("Chatted", function(Player, Message) 
    
      -- This simply makes sure that the player speaking is allowed to run a command
      if not Commanders[Player] then return end
    
      if Message:lower():sub(0, 6) == "target" then -- If the message starts with target
        local Victim = Message:sub(8) -- Gets the rest of the message
        Gyro:Configure({Seek=Victim}) -- Configures the seeker to target that person
      end
    end)
    

    There are many functions in Pilot.lua that allow you to interact with other objects:

    • GetPort(ID) - Returns a port instance that can be used in other functions. It is only really recommended if your going to do something like port:Connect("Triggered")
    • GetPartFromPort(ID or Port Instance, ClassName) Returns a part if found directly attached to a port. An example would be GetPartFromPort(2, "Screen")
    • TriggerPort(ID or Port Instance) - pretty self explanatory, sends a trigger signal from the given port or port instance
    • GetPartsFromPort(ID or Port Instance, ClassName) Returns an array of different parts attached to the Port. In order to use, it is recommended to use ipairs, however, a for i = number, number do along with Parts[i] will work too.

    All objects will contain certain programmable properties and functions. However, all instances will contain the following properties and methods:

    • Properties
      • Configurable properties, for example an IonRocket's thrust speed property
      • ClassName, which is simply the name of the object
    • Methods
      • Object:Trigger(), which simply triggers the object
      • Object:Configure({Property=NewValue}), which configures the part to the given dictionary/table
      • Object:Connect, connects a function to an object's event
    • Events
      • part:Connect("Triggered", function)

    Certain parts however will have their own special properties.

    • Screen
      • Methods
        • Screen:CreateElement(string GUIClassName, dictionary Properties), an example includes Screen:CreateElement("TextLabel", {Text = "Hello World!"; TextScaled = true});
        • Screen:ClearElements(), which clears all elements in a gui
    • Disk
      • Methods
        • disk:Write(string Key, any Value) writes a value in the disk with the given key.
        • disk:Read(string Key) Reads the value in the disk with the given key. If there is no value, returns nil.
        • disk:ClearDisk() clears the disk
        • disk:ReadEntireDisk() returns a dictionary of all the values and keys in a disk.
    • Keyboard
      • Events
        • keyboard:Connect("KeyPressed", function(keycode key, string key, string player) end) fires when someone presses a key while sitting on a Seat attached to the keyboard
        • keyboard:Connect("TextInputted", function(string Text, string player) end) fires when someone presses on the Keyboard to open the text menu, and submits text. Note: the keyboard adds an extra character at the end on accident, because you press enter to submit, and so it adds an extra character.

    Tutorials[edit | hide all | hide | edit source]

    These tutorials are assuming you know a thing or two about coding already. More are yet to come.

    Events[edit | hide | edit source]

    One of the most important parts about programming in WoS is events. Events allow you to get player input, detect when something happened, and more. For example, if you are using the Microphone, in order to get when a player has talked, you need to use the chatted event. A full list of events can be found here. To get an event, you need to first do the connect method on the part, like this; microphone:Connect(). Within the parenthesis, you need to put two parameters. The first one is simple, just put the name of the event within a string (example: "Chatted"). As the second parameter, we put the function we want it to run when the event happens. This is known as a callback. Basically, its when you pass a function as a parameter to another function. In this example, we want the :Connect() method to run a function whenever the "Chatted" event happens. In that second parameter, we can reference an already existing function, or make a function within the parameter. Here is our code so far:

    local microphone = GetPartFromPort(1, "Microphone") --this gets the microphone object
    microphone:Connect("Chatted", function() --so we call the connect method, then we tell it to run the function whenever it detects the event
    print("Someone talked!!!")
    end)--we need to end the function, and close the open parenthesis
    

    Now, this isn't very useful on its own. We have no way of telling what the person even said! All we know is when someone talked. However, we are in luck. When the connect method calls the function, it also passes the parameters along with the function (once again, all the events and what they return can be found here). In the case of the chatted event, it returns the players name, and the message they sent. Here is the example code:

    local microphone = GetPartFromPort(1, "Microphone") --this gets the microphone object
    microphone:Connect("Chatted", function(player, message) --so we call the connect method, then we tell it to run the function whenever it detects the event
    print(player.. " Said: ".. message) --print what was said and who said it (eg. Playername Said: Hello!)
    end)--we need to end the function, and close the open parenthesis
    

    Screen[edit | hide | edit source]

    The Screen is a confusing part for beginner programmers, because of all the confusing stuff like UDim2. So, here's an explanation. Screens are a very useful item for displaying information, allowing for much more possibilities then just simply configuring signs. While signs will work for displaying text, it doesn't have nearly as much possibility as screens. Screens can display multiple elements, and have custom size/position. However, when it comes to creating Screen elements, it can be confusing because it uses a whole new data type called UDim2. UDim2 is a data type consisting of 4 values. The order goes XScale, XOffset, YScale YOffset,. What the heck does all that mean?? Well, simply put, Offset is the X or Y size/position of the element in pixels. Scale is the X or Y size/position in screen sizes. What do you mean, "screen sizes"??? 1 scale is equal to the entire size of the screen. 1 XScale is equal to the width of the screen, while 1 YScale is equal to the height of the screen. Scale is very important, as it allows for the ScreenElement to look the same no matter the size of it. In order to make a screen element cover the entire screen, you would put the scale at 1 for both. So what you can do is make the screen size equal to UDim2.new(1, 0, 1, 0). Whats the point of putting the zeros? Is there an easier way to do it? There is an easier way to do it. instead of using UDim2.new, you can use UDim2.fromScale, which is where you only need to put 2 values instead of 4, UDim2.fromScale(1, 1). Before I continue, if you need further help understanding UDim2, go visit the Creator documentation page. Now comes the part where I actually explain how to make a new element. So first to create the element, you need to get the screen from the port.

    local screen = GetPartFromPort(1, "Screen") --Gets the screen
    

    Next we would need to clear any elements that are already on the screen using screen:ClearElements().

    local screen = GetPartFromPort(1, "Screen") --Gets the screen
    screen:ClearElements() --clears the screen of any previous elements
    

    Now, to create the element using screen:CreateElement().

    local screen = GetPartFromPort(1, "Screen") --Gets the screen
    screen:ClearElements() --clears the screen of any previous elements
    screen:CreateElement("classname", {properties}) -- creates an element with the given name and properties
    

    Now, we must add the Classname of element we want to create. I will use TextLabel.

    local screen = GetPartFromPort(1, "Screen") --Gets the screen
    screen:ClearElements() --clears the screen of any previous elements
    screen:CreateElement("TextLabel", {}) -- creates an element with the given name and properties
    

    Now, we need to add a few properties.

    local screen = GetPartFromPort(1, "Screen") --Gets the screen
    screen:ClearElements() --clears the screen of any previous elements
    screen:CreateElement("TextLabel", {  -- creates an element with the given name and properties
    Text = "Hi!", --Sets the text to Hi!
    TextScaled = true -- Automatically scales the text to fit the screen
    })
    

    Now, lets use what we learned above, and use UDim2.fromScale to make the size and position.

    local screen = GetPartFromPort(1, "Screen") --Gets the screen
    screen:ClearElements() --clears the screen of any previous elements
    screen:CreateElement("TextLabel", {  -- creates an element with the given name and properties
    Text = "Hi!", --Sets the text to Hi!
    TextScaled = true, -- Automatically scales the text to fit the screen
    Size = UDim2.fromScale(1, 1), --Makes the size cover the whole screen
    Position = UDim2.fromScale(0, 0) --sets the position
    })
    

    Congrats! You made your first Screen element. A few more notes are:

    • Position is the position of the element in the top left corner
    • when doing scale for position, the top is y=0, the bottom is y=1, the left is x=0, the right is x=1. This confuses some people because positive y is actually down, not up.

    Modem[edit | hide | edit source]

    The Modem allows you to send messages across the entire universe! You could even create a makeshift internet of sorts with it! This being said, it seems like a scary and confusing prospect for new programmers. But the reality is, that it is very simple. There are two main things you need to know to make a messaging system or something like that. First is the SendMessage method. This is very simple. It sends a message across the universe. All you need to put in the method's parameters is the message you with to send, and the Modem ID you wish to send it on. Here is an example:

    local modem = GetPartFromPort(1, "Modem")--gets the modem object
    modem:SendMessage("Hello WoS", 1) --sends the message "Hello WoS" on the Modem
    

    Well you can send messages, but how do you receive? You receive messages using an event. If you are unfamiliar with events, please read the tutorial above about events. The event name is MessageSent. It fires when a message is received from a modem with the same ID. It only provides a singular parameter, and that is the data that was sent. Here is an example of a modem that picks up messages and writes it to a sign.

    local modem = GetPartFromPort(1, "Modem")--gets the modem object
    local sign = GetPartFromPort(2, "Sign")--gets the sign object
    modem:Connect("MessageSent", function(message)
    sign:Configure({SignText=message})--write the message to a sign
    end)
    

    There you go! You have just made a simple messaging system. You can expand on this by using Keyboards to send messages, or use screens to make a nice looking UI.

    Another method is the RealPostRequest, it enables you to send post requests to real websites such as google. Here's an example:

    local Modem = GetPartFromPort(1,"Modem")
    local Sign = GetPartFromPort(1,"Sign")
    
    local Payload = JSONEncode({"Data",1,2,3})
    
    local Data, Success = Modem:RealPostRequest("http://CustomLinkHere.com",Payload,false,nil,{["Content-Type"]="application/json"})
    if Success then
     Sign:Configure({SignText=Payload})
    end
    

    Sadly, the RealGetRequest does not work. So you have to use the post requests.

    If you want to use the RealPostRequest for sending data to your computer then you will have to use third party resources. (i.e. website hosting) how ever, learn Luau first, you will need some LUAU experience or lua 5.1 experience, learn Lua 5.1 then Luau then pliot.lua.

    Resources[edit | hide | edit source]

    • There is currently one player-made wiki, murpyh's
    • Some information on parts can be found at mawesome's part list site, though some information is inaccurate or not displayed there
    • Roblox creator documentation contains a load of info on rbx.lua. If you are unfamiliar with lua, or coding in general, it is highly recommended to learn rbx.lua first. if you do NOT know what rbx.lua IS, it is a nickname for Luau.

    Programming Examples[edit | hide | edit source]

    A flappy bird arcade machine, made by iiMurpyh
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.