Content added Content deleted
No edit summary |
No edit summary Tags: Mobile edit Mobile web edit |
||
(18 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
{{Object |
|||
'''Disk''' is a Programmable Object that can be used to write and read. Maximum storage of Disk is 10KB. There are 4 codes of Disk: Write(key, data) write data giving a string key, Read(key) only returns a given value of a disk, ClearDisk() clears all value and data in a disk, ReadEntireDisk() returns the entire disk table, all value, and all data. |
|||
|title1 = {{PAGENAME}} |
|||
|image1 = Hard Drive Disk.jpg |
|||
|type = Programming |
|||
|uses = Saving microcontroller data between servers |
|||
⚫ | |||
⚫ | |||
|malleability = {{#invoke:GetPartInfo|getField|Malleability}} |
|||
|durability = {{#invoke:GetPartInfo|getField|Durability}} |
|||
}} |
|||
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== |
|||
*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:== |
==Example:== |
||
Line 18: | Line 35: | ||
end |
end |
||
Button: |
Button:Connect("OnClick", Fire) |
||
OffButton: |
OffButton:Connect("OnClick", function() |
||
Disk:Write(1, not Disk:Read(1)) |
Disk:Write(1, not Disk:Read(1)) |
||
end) |
end) |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
TextLabel Data Save: |
|||
⚫ | |||
<syntaxhighlight lang="lua" line="1"> |
|||
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) |
|||
</syntaxhighlight> |
|||
⚫ | |||
"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" |
"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== |
==Misc== |
||
===Recipe=== |
|||
⚫ | |||
===Raw Recipe=== |
|||
⚫ | |||
===Malleability=== |
|||
Maximum Size: 20*20*20 |
|||
Default Size: 2*1*2 |
Default Size: 2*1*2 |
||
==Configurable== |
==Configurable== |
||
Not Configured |
Not Configured |
||
==Gallery== |
|||
[[File:OldDisk.jpg|thumb|left|Disk in the crafting menu in the old version.]] |
|||
[[Category:Parts]] |
[[Category:Parts]] |
Latest revision as of 12:45, 7 February 2024
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
Gallery[edit | hide | edit source]
![](http://static.miraheze.org/wasteofspacewiki/thumb/9/9b/OldDisk.jpg/300px-OldDisk.jpg)