Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- send_tank_info_v3 v3.0 for OpenPeripheral 0.4.1
- Copyright (C) 2016 Duisburger98
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
- --]]
- -- The modem channel to send tank data on
- -- This has to be the same channel you set in the display_tanks program
- modem_channel = 3
- -- Tank data will be sent in every sleep_timeout seconds
- sleep_timeout = 0.5
- --------------------------------------
- -- DO NOT MODIFY ANYTHING FROM HERE --
- --------------------------------------
- modem = peripheral.find("modem")
- if not modem then
- error("Please attach one wireless modem.")
- end
- sides = {"left", "right", "front", "back", "top", "bottom"}
- while true do
- local tanks = {}
- for i,side in ipairs(sides) do
- local isTank = peripheral.getMethods(side)
- if isTank then
- for k,v in pairs(isTank) do
- if v == "getTankInfo" then
- local p = peripheral.wrap(side)
- local info = p.getTankInfo("unknown")
- for m,n in ipairs(info) do
- local data={position=side, data=n}
- table.insert(tanks, data)
- end
- end
- end
- end
- end
- send_data={id=os.getComputerID(), tanks=tanks}
- serialized_data = textutils.serialize(send_data)
- modem.transmit(modem_channel,modem_channel,serialized_data)
- sleep(sleep_timeout)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement