Screen
Allows for the programmatic creation of GUI elements.
Internally, it utilises a SurfaceGUI
, and is therefore no different from normal roblox GUIs.
There are some limitations with Screen
s in Waste of Space, such as an inability to use ViewportFrame
s
-- Try and get the screen part, throw an error if we don't find it using `assert`.
local screen = assert(GetPart("Screen"), "no screen connected")
-- Create a text label with the text 'Hello, world!' which takes up the entire screen.
local textLabel = Instance.new("TextLabel")
textLabel.Text = "Hello, world!"
textLabel.Size = UDim2.fromScale(1, 1)
textLabel.BorderSizePixel = 0
textLabel.BackgroundColor = Color3.fromRGB(255, 255, 255)
-- Parent it to the 'canvas' of the screen.
textLabel.Parent = screen:GetCanvas()
-- Keep the microcontroller on by permanently 'yielding' the code (making it wait).
coroutine.yield()
It is a craftable and spawnable non-flammable solid.
Here is a list of possible sizes that reach the maximum malleability (400) that have integer components: 1x400x1, 1x200x2, 1x100x4, 1x80x5, 1x50x8, 1x40x10, 1x25x16, 1x20x20, 2x100x2, 2x50x4, 2x40x5, 2x25x8, 2x20x10, 4x25x4, 4x20x5, 4x10x10, 5x16x5, 5x10x8, 10x8x5, 16x5x5, 20x10x2, 20x5x4
At its default size (8x1x8) it has a durability of 1, at its maximum size it has a durability of 2.
By default, its colour is #111111.
It requires 5 Glass
, 3 Iron
, 3 Light
, 3 Silicon
, and 3 Wire
to be crafted.
Methods
ClearElements()
Clears all objects that are descendants of the screen.
CreateElement(className, properties) → element
Creates an element of the specified class name with the specified properties.
The parameters for CreateElement
are as follows:
- The className parameter is a
string
. - The properties parameter is a dictionary with keys that are
string
s and values that areany
s.
The element return is an Instance
.
-- Try and get the screen part, throw an error if we don't find it using `assert`.
local screen = assert(GetPart("Screen"), "no screen connected")
-- Clear the left over screen elements from the last time GUIs were loaded onto it.
-- Note: If you utilise the `Instance.new` API instead, you do not need to do this,
-- as objects created through said API are *automatically* deleted when the
-- microcontroller stops running.
screen:ClearElements()
-- Call the `CreateElement` method with the `ClassName` of the object you want to create,
-- and a dictionary of the properties to apply (you cannot specify the `Parent` property).
local textLabel = screen:CreateElement("TextLabel", {
Text = "Hello, world!",
Size = UDim2.fromScale(1, 1),
BorderSizePixel = 0,
BackgroundColor = Color3.fromRGB(255, 255, 255),
})
-- Keep the microcontroller on by permanently 'yielding' the code (making it wait).
coroutine.yield()
GetCanvas() → canvas
Returns the parent container of all the screen's content.
The canvas return is a Frame
.
GetDimensions() → dimensions
Gets the size of the screen in pixels in the form of a Vector2
.
The dimensions return is the size of the screen in pixels. It is a Vector2
.
-- Try and get the screen part, throw an error if we don't find it using `assert`.
local screen = assert(GetPart("Screen"), "no screen connected")
-- Store the current screen size.
local previousScreenSize = screen:GetDimensions()
-- Connect to the `Loop` event of the `Microcontroller` that is running the code,
-- this will make the code within run precisely every game tick.
Microcontroller.Loop:Connect(function()
-- Get the new current screen dimensions.
local screenSize = screen:GetDimensions()
-- Compare these new dimensions with the previously recorded dimensions, if
-- they are equal, cancel this running code with 'return'.
if screenSize == previousScreenSize then return end
-- Do something with the information about the screen dimensions changing,
-- in this case, it triggers a print statement.
print(`The screen size changed! It used to be {previousScreenSize}, but is now {screenSize}!`)
-- Update the stored current dimensions as to make them accurately reflect reality.
previousScreenSize = screenSize
end)
Configurables
VideoID
The ID of the camera feed being to be viewed, or 0 for none. It is a number
.
It ranges between 0 and 10000000000. It increments by 1.
Events
Configured(configurerId)
Fires when the object is configured.
The configurerId parameter is the UserId
of the player who configured the object. It is a number
.