Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function getDevices(deviceType) -- Credit: https://github.com/sandalle/minecraft_bigreactor_control, https://github.com/Sanwi
- local deviceName = nil
- local deviceIndex = 1
- local deviceList, deviceNames = {}, {} -- Empty array, which grows as we need
- local peripheralList = peripheral.getNames() -- Get table of connected peripherals
- for peripheralIndex = 1, #peripheralList do -- Log every device found
- if (string.lower(peripheral.getType(peripheralList[peripheralIndex])) == string.lower(deviceType)) then -- Log devices found which match deviceType and which device index we give them
- deviceNames[deviceIndex] = peripheralList[peripheralIndex]
- deviceList[deviceIndex] = peripheral.wrap(peripheralList[peripheralIndex])
- deviceIndex = deviceIndex + 1
- end
- end -- for peripheralIndex = 1, #peripheralList do
- return deviceList, deviceNames
- end
- local reactorList, reactorNames = getDevices("bigreactors-reactor")
- -- Get default rod levels
- local rodLevels = reactorList[1].getControlRodLevel(1)
- while true do
- term.clear()
- term.setCursorPos(1,1)
- term.write("Rod insertion level: "..tostring(rodLevels))
- term.setCursorPos(1,2)
- term.write("Press S to extract by 10%, and W to insert by 10%")
- term.setCursorPos(1,3)
- term.write("Press E to extract by 1%, and F to insert by 1%")
- local event, key = os.pullEvent("key")
- if key == 17 then -- S
- rodLevels = rodLevels + 10
- elseif key == 31 then -- W
- rodLevels = rodLevels - 10
- elseif key == 18 then -- E
- rodLevels = rodLevels + 1
- elseif key == 33 then -- F
- rodLevels = rodLevels - 1
- end
- if rodLevels < 0 then rodLevels = 0 elseif rodLevels > 100 then rodLevels = 100 end
- reactorList[1].setAllControlRodLevels(rodLevels)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement