Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Author: Gunny576
- Date: 4/26
- Coil Monitor System CMS
- Usage: This program is to be run on a CC turtle with a wireless motem installed on the left side.
- A coil is a ring of power cells given the following layout:
- 123
- 12x 4
- 11 5
- 10 6
- 987
- power must flow from 12 down to 1, and from 1 out into the main energy line. the turtle is placed at x and will move up to 12.
- --]]
- --Network Parameters, Channel is what the receiver should be listening to, TurtleID should be the channel you expect a reply from
- channel = 1
- turtleID = 1
- --Coil settings and start point.
- coilMax = 12
- currentCell = 1
- --Peripherial configuration
- cell = peripheral.wrap("front")
- modem = peripheral.wrap("left")
- --internal Variables used
- data = {}
- charge=nil
- function CheckSend ()
- charge = cell.getEnergyStored()/500000
- charge = string.format("%0.3f",charge)
- charge = charge+0
- --check if cell is fully charged, move on to next if it is.
- if (charge== 100 and currentCell<coilMax) then
- NextC()
- CheckSend()
- --recursive function break.
- return
- end
- if (charge==0 and currentCell>1) then
- LastC()
- CheckSend()
- --recursive function break.
- return
- end
- --load data payload
- charge=charge/100
- charge=(charge/12+((currentCell-1)/12))
- charge=charge*100
- charge = string.format("%0.3f",charge)
- charge = charge+0
- data[0] = charge
- data[2] = currentCell
- data[1] = channel
- modem.transmit(channel, turtleID, data)
- end
- function NextC ()
- turtle.turnLeft()
- if turtle.forward() then
- turtle.turnRight()
- end
- currentCell=currentCell+1
- end
- function LastC ()
- turtle.turnRight()
- if turtle.forward() then
- turtle.turnLeft()
- end
- currentCell=currentCell-1
- end
- --Main Loop
- while true do
- CheckSend()
- os.sleep(10)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement