Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local speaker = peripheral.find "speaker"
- if not speaker then printError("No speaker attached") return end
- local oldFS = fs
- local lastfile = nil
- local clicksRemaining = 0
- _G.fs = {
- isDriveRoot = fs.isDriveRoot,
- combine = fs.combine,
- complete = fs.complete,
- getDir = fs.getDir,
- getName = fs.getName,
- getCapacity = fs.getCapacity,
- getDrive = fs.getDrive
- }
- local function click(n)
- clicksRemaining = math.min(clicksRemaining + n, 10)
- end
- local function fn(name, n)
- _G.fs[name] = function(path, ...)
- if lastfile ~= path then
- click(n)
- lastfile = path
- end
- return oldFS[name](path, ...)
- end
- end
- fn("attributes", 1)
- fn("isReadOnly", 1)
- fn("move", 2)
- fn("getSize", 1)
- fn("getFreeSpace", 1)
- fn("makeDir", 1)
- fn("list", 3)
- fn("isDir", 1)
- fn("exists", 1)
- fn("delete", 1)
- fn("open", 2)
- function _G.fs.copy(src, dest)
- click(math.min(math.ceil(oldFS.getSize(src) / 4096), 8))
- lastfile = nil
- return oldFS.copy(src, dest)
- end
- function _G.fs.find(wildcard)
- click(select("#", wildcard:match("(%*)")))
- lastfile = nil
- return oldFS.find(wildcard)
- end
- if turtle then
- local oldTurtle = turtle
- _G.turtle = setmetatable({}, {__index = oldTurtle})
- local function wrap(name)
- _G.turtle[name] = function()
- speaker.playNote("snare", 1, 0)
- return oldTurtle[name]()
- end
- end
- wrap "forward"
- wrap "back"
- wrap "up"
- wrap "down"
- wrap "turnLeft"
- wrap "turnRight"
- end
- speaker.playNote("bit", 1, 24)
- parallel.waitForAny(function()
- while true do
- if clicksRemaining > 0 then
- speaker.playNote("hat", 0.5, 18)
- clicksRemaining = clicksRemaining - 1
- end
- sleep(0.025)
- end
- end, function() shell.run("shell") end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement