The Disk is a programmable object that is used for storing and retrieving value by writing (saving its data) and reading (loading its data), acting as a data storage device. The maximum storage on the disk is 10KB. Its data will be saved in a game.
Programming[edit | hide all | hide | edit source]
- Write(key,value) - Write a value, which contains letters or characters, to a disk with a key to save its data
- Read(key) - Return a given value with a key to receive characters for functioning, or load its data
- ClearDisk() - Clear the entire disk's data
- ReadEntireDisk() - Similar to Read(key) but return the entire disk table to receive them for functioning
Example:[edit | hide | edit source]
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:Connect("OnClick", Fire)
OffButton:Connect("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 which 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:Connect("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 a problem with an error, it won't load
TextLabel:ChangeProperties({
Text = loadingdata -- This code makes the letters appear after the disk loads
})
end
end)
Save.MouseButton1Click:Connect(function()
Disk:Write(Keyseed, TextLabel.Text) -- Save the Data to a Disk
end)
In-game description[edit | hide | edit source]
"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[edit | hide | edit source]
Default Size: 2*1*2
Configurable[edit | hide | edit source]
Not Configured