×
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

    Disk: Difference between revisions

    Content added Content deleted
    No edit summary
    No edit summary
    Tags: Mobile edit Mobile web edit
     
    (7 intermediate revisions by 2 users not shown)
    Line 10: Line 10:
    }}
    }}


    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. Its data will be saved in a game.
    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==
    ==Programming==
    *Write(key,value) - Write a value, which contains letters or characters, to a disk with a key to save its data
    *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
    *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
    *ClearDisk() - Clear the entire disk's data
    *ReadEntireDisk() - Similar to Read(key) but return the entire disk table to receive them
    *ReadEntireDisk() - Similar to Read(key) but return the entire disk table to receive them for functioning


    ==Example:==
    ==Example:==
    Line 35: Line 35:
    end
    end


    Button:ConnectToEvent("OnClick", Fire)
    Button:Connect("OnClick", Fire)
    OffButton:ConnectToEvent("OnClick", function()
    OffButton:Connect("OnClick", function()
    Disk:Write(1, not Disk:Read(1))
    Disk:Write(1, not Disk:Read(1))
    end)
    end)
    Line 42: Line 42:


    TextLabel Data Save:
    TextLabel Data Save:
    <syntaxhighlight lang="lua" line=1>
    <syntaxhighlight lang="lua" line="1">
    local Screen = GetPartFromPort(1, 'Screen')
    local Screen = GetPartFromPort(1, 'Screen')
    local Disk = GetPartFromPort(3,'Disk')
    local Disk = GetPartFromPort(3,'Disk')
    local Keyboard = GetPartFromPort(2,'Keyboard')
    local Keyboard = GetPartFromPort(2,'Keyboard')
    local Keyseed = "textsave" -- a table key is required for saving and loading
    local Keyseed = "textsave" -- a table key which is required for saving and loading


    Screen:ClearElements()
    Screen:ClearElements()
    Line 77: Line 77:
    })
    })


    Keyboard:ConnectToEvent("TextInputted", function(text, playername)
    Keyboard:Connect("TextInputted", function(text, playername)
    TextLabel:ChangeProperties({
    TextLabel:ChangeProperties({
    Text = text
    Text = text
    Line 87: Line 87:
    Load.MouseButton1Click:Connect(function()
    Load.MouseButton1Click:Connect(function()
    local loadingdata = Disk:Read(Keyseed) -- A variable which is used to load
    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
    if loadingdata then -- If there's a problem with an error, it won't load
    TextLabel:ChangeProperties({
    TextLabel:ChangeProperties({
    Text = loadingdata -- Do the magic
    Text = loadingdata -- This code makes the letters appear after the disk loads
    })
    })
    end
    end
    Line 95: Line 95:


    Save.MouseButton1Click:Connect(function()
    Save.MouseButton1Click:Connect(function()
    Disk:Write(Keyseed, TextLabel.Text) -- Save a Data to a Disk
    Disk:Write(Keyseed, TextLabel.Text) -- Save the Data to a Disk
    end)
    end)
    </syntaxhighlight>
    </syntaxhighlight>

    ==In-game description==
    ==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"
    "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"
    Line 108: Line 109:


    ==Gallery==
    ==Gallery==
    [[File:OldDisk.jpg|thumb|left|Disk in the tutorial place]]
    [[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]

    Disk in the crafting menu in the old version.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.

    Recent changes

  • 116.111.185.163 • 10 hours ago
  • 116.111.185.163 • 10 hours ago
  • 116.111.185.163 • 10 hours ago
  • 116.111.185.163 • 11 hours ago
  • Cookies help us deliver our services. By using our services, you agree to our use of cookies.