Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local basalt = require("basalt")
- Vaults = 2
- fs.makeDir("vault_cache")
- Controller = peripheral.wrap("top")
- DirectionOut = true
- DirectionIn = false
- function DistanceToRotationDuration(speed, distance)
- return (math.ceil(distance / (speed / 512)) + 2) / 20
- end
- function Split(inputstr, sep)
- if sep == nil then
- sep = "%s"
- end
- local t={}
- for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
- table.insert(t, str)
- end
- return t
- end
- function SetPusherLock(state)
- Controller.setOutput("top", state)
- end
- function SetHandDirection(dir)
- Controller.setOutput("right", not dir)
- end
- function SetGrabberLock(state)
- Controller.setOutput("back", state)
- end
- function SetChassisDirection(dir)
- Controller.setOutput("left", not dir)
- end
- function SetChassisLock(state)
- Controller.setOutput("front", state)
- end
- function Reset()
- SetHandDirection(DirectionIn)
- SetPusherLock(false)
- SetGrabberLock(false)
- sleep(5)
- SetPusherLock(true)
- SetGrabberLock(true)
- SetChassisDirection(DirectionIn)
- SetChassisLock(false)
- sleep(5)
- SetChassisLock(true)
- end
- function GrabVault(index)
- Duration = DistanceToRotationDuration(128, index * 3 + 3)
- SetChassisDirection(DirectionOut)
- SetChassisLock(false)
- sleep(Duration)
- SetChassisLock(true)
- SetHandDirection(DirectionOut)
- SetGrabberLock(false)
- sleep(2)
- SetHandDirection(DirectionIn)
- sleep(2)
- SetGrabberLock(true)
- SetChassisDirection(DirectionIn)
- SetChassisLock(false)
- sleep(Duration)
- SetChassisLock(true)
- SetHandDirection(DirectionOut)
- SetPusherLock(false)
- sleep(2)
- SetHandDirection(DirectionIn)
- sleep(2)
- SetPusherLock(true)
- end
- function ReturnVault(index)
- Duration = DistanceToRotationDuration(128, index * 3 + 3)
- SetHandDirection(DirectionOut)
- SetGrabberLock(false)
- sleep(2)
- SetHandDirection(DirectionIn)
- sleep(2)
- SetGrabberLock(true)
- SetChassisDirection(DirectionOut)
- SetChassisLock(false)
- sleep(Duration)
- SetChassisLock(true)
- SetHandDirection(DirectionOut)
- SetPusherLock(false)
- sleep(2)
- SetHandDirection(DirectionIn)
- sleep(2)
- SetPusherLock(true)
- SetChassisDirection(DirectionIn)
- SetChassisLock(false)
- sleep(Duration)
- SetChassisLock(true)
- end
- local main = basalt.createFrame()
- local button = main:addButton() --> Here we add our first button
- button:setPosition(4, 4) -- We want to change the default position of our button
- button:setSize(16, 3) -- And the default size.
- button:setText("Click me!") --> This method sets the text displayed on our button
- local function buttonClick() --> Create a function we want to call when the button gets clicked
- basalt.debug("I got clicked!")
- end
- -- Now we just need to register the function to the button's onClick event handlers, this is how we can achieve that:
- button:onClick(buttonClick)
- basalt.autoUpdate()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement