Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- if #tArgs ~= 3 then
- print("Usage: give <id> <count> <metadata>")
- error()
- end
- if not fs.isDir("disk") then
- printError("No disk drive connected!")
- error()
- end
- local tabl = {}
- if fs.exists("disk/inventory.txt") then
- local open = fs.open("disk/inventory.txt", "r")
- tabl = textutils.unserialize(open.readAll())
- open.close()
- end
- local itemdetails = {}
- itemdetails["name"] = tArgs[1]
- itemdetails["count"] = tArgs[2]
- itemdetails["damage"] = tArgs[3]
- local numb = #tabl+1
- tabl[numb] = itemdetails
- local open = fs.open("disk/inventory.txt", "w")
- open.write(textutils.serialize(tabl))
- open.close()
- print("Added " .. tArgs[2] .. " of item " .. tArgs[1] .. " in slot " .. numb .. "!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement