The Disk is a programmable object that can be used to store and retrieve the value by writing and reading, acting as a data-storage device. The maximum storage of the Disk is 10KB.
Programming
- Write(key,value) - Write a value to a disk with a key
- Read(key) - Return a given value with a key
- ClearDisk() - Clear the entire disk
- ReadEntireDisk() - Similar to Read(key) but return the entire disk table
Example:
local Button = GetPartFromPort(2, "Button")
local Disk = GetPartFromPort(2, "Disk")
local OffButton = GetPartFromPort(3, "Button")
Disk:Write(1, false)
local function Fire()
Disk:Write(1, not Disk:Read(1))
repeat
TriggerPort(1)
wait(0.1)
until not Disk:Read(1)
end
Button:ConnectToEvent("OnClick", Fire)
OffButton:ConnectToEvent("OnClick", function()
Disk:Write(1, not Disk:Read(1))
end)
TextLabel Data Save:
local Screen = GetPartFromPort(1, 'Screen')
local Disk = GetPartFromPort(3,'Disk')
local Keyboard = GetPartFromPort(2,'Keyboard')
local Keyseed = "textsave" -- a table key is required for saving and loading
Screen:ClearElements()
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 = 'Hello, world!';
TextSize = 20;
TextScaled = false;
})
local Save = Screen:CreateElement('TextButton', {
AnchorPoint = Vector2.new(0.5, 0.5);
Position = UDim2.fromScale(0.1, 0.9);
Size = UDim2.fromScale(0.2, 0.2);
Text = 'Save';
TextSize = 20;
TextScaled = false;
})
local Load = Screen:CreateElement('TextButton', {
AnchorPoint = Vector2.new(0.5, 0.5);
Position = UDim2.fromScale(0.9, 0.9);
Size = UDim2.fromScale(0.2, 0.2);
Text = 'Load';
TextSize = 20;
TextScaled = false;
})
Keyboard:ConnectToEvent("TextInputted", function(text, playername)
TextLabel:ChangeProperties({
Text = text
})
end)
--Function Section--
Load.MouseButton1Click:Connect(function()
local loadingdata = Disk:Read(Keyseed) -- A variable which is used to load
if loadingdata then -- If there's problem with an error, it won't load
TextLabel:ChangeProperties({
Text = loadingdata -- Do the magic
})
end
end)
Save.MouseButton1Click:Connect(function()
Disk:Write(Keyseed, TextLabel.Text) -- Save a Data to a Disk
end)
In-game description
"A programmable object capable of storing data. Has a limit of 10kb of data. Has 4 functions that allow you to edit the disk. Write(key, value) writes a value to the disk with a key. Read(key) returns a given value of a disk. ClearDisk() clears the entire disk. ReadEntireDisk() returns the entire disk table. **Be aware, while disks can store userdata values, it cannot save them properly"
Misc
Default Size: 2*1*2
Configurable
Not Configured
Gallery
![](http://static.miraheze.org/wasteofspacewiki/thumb/9/9b/OldDisk.jpg/300px-OldDisk.jpg)