Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- send_tank_info v1.0 for OpenCCSensors 0.1.4c
- Copyright (C) 2013 DEXTER
- 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/>.
- --]]
- -- Position of your modem
- modem_position = "left"
- -- Position of your sensor
- sensor_position = "right"
- -- The modem channel to send sensor data on
- -- This has to be the same channel you set in the display_tanks program
- modem_channel = 3
- -- Time (in seconds) when new sensor data will be sent to the display
- sleep_timeout = 0.5
- -- The positions of your tanks
- -- This is relative to your sensor. Coordinates are: X, Y, Z
- tanks={
- "0,0,-1",
- "-1,0,0",
- "-1,0,-1",
- "1,0,-1",
- "1,0,0",
- "1,0,1"
- }
- --------------------------------------
- -- DO NOT MODIFY ANYTHING FROM HERE --
- --------------------------------------
- os.loadAPI("ocs/apis/sensor")
- sens = sensor.wrap(sensor_position)
- modem = peripheral.wrap(modem_position)
- while true do
- local data_table={}
- for i, v in ipairs(tanks) do
- target_details = sens.getTargetDetails(v)
- table.insert(data_table, target_details)
- end
- local send_data={id=os.getComputerID(), data=data_table}
- 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