Posted 26 January 2013 - 07:01 PM
Below are my server(which is hooked up to the monitor) and my client(MiningTurtle).
So I have tested the ability to send and parse the data and that works fine.
My setup is a big monitor hooked up to a computer(server) with a modem and I have two wireless turtles with the same program with minor numeric changes and obviously different labels to tell them apart. On the server I run. monitor top draw2
if I run the program on turtleA it shows up correctly at the top position. If I then run the program on turtleB it shows up in the correct lower position , but with the information from turtleA.
If I try the reverse. Starting with TurtleB it will show up correclty in the lower position with TurtleB info. If I then run Turtle A it is in the top position but with TurtleB info. So it knows where to put the message but doesnt seem to update the message. Been trying to figure this out for a couple hours and would like it if anyone could look at it with a fresh pair of eyes. Also not a pro programmer so any tips or advice is greatly appreciated.
The goal of this program is to be able to have multiple turtles running and a central location to see the progress and fuel levels.
Again thank you
========================================================
===========================================================================
So I have tested the ability to send and parse the data and that works fine.
My setup is a big monitor hooked up to a computer(server) with a modem and I have two wireless turtles with the same program with minor numeric changes and obviously different labels to tell them apart. On the server I run. monitor top draw2
if I run the program on turtleA it shows up correctly at the top position. If I then run the program on turtleB it shows up in the correct lower position , but with the information from turtleA.
If I try the reverse. Starting with TurtleB it will show up correclty in the lower position with TurtleB info. If I then run Turtle A it is in the top position but with TurtleB info. So it knows where to put the message but doesnt seem to update the message. Been trying to figure this out for a couple hours and would like it if anyone could look at it with a fresh pair of eyes. Also not a pro programmer so any tips or advice is greatly appreciated.
The goal of this program is to be able to have multiple turtles running and a central location to see the progress and fuel levels.
Again thank you
========================================================
--[[
File: draw2
Version: 1.0
Purpose: A utiltiy for monitoring multiple turtles from a central location
Author(s): GsnShadow
]]
(server) --draw2
local w,h = term.getSize() --term size
a= {} --defining the array
n=1 --defining number for array
sh=0 --screen height offset
function netClose()
rednet.close("right")
end
function netOpen()
netClose()
rednet.open("right")
end
function getData()
id, message, distance = rednet.receive()
end
function assignData()
netOpen()
getData()
--id, message = rednet.receive()
if id == 20 then
--T1m = message
sh=0
drawScreen()
elseif id == 30 then
--T2m = message
sh=5
drawScreen()
elseif id == 33 then
--T3m = message
sh=10
drawScreen()
end
end
function tClear()
term.clear()
end
function drawScreen()
local s = message
for token in string.gmatch(s,"[^%s]+") do
a[n] = token
n=n+1
end
name = a[1]
fuelLevel = a[2]
fuelNeeded = a[3]
collected = a[4]
blocks = a[5]
--print(name)
--print(fuel)
--print(fuelNeeded)
--print(collected)
--print(blocks)
iFuelLevel = tonumber(fuelLevel)
iBlocks = tonumber(blocks)
if iFuelLevel < iBlocks then
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
end
fuel = " Fuel: " .. fuelLevel
term.setCursorPos(1,1+sh)
term.write(name)
term.setCursorPos(w - #fuel+1, 1 + sh)
term.write(fuel)
term.setBackgroundColor(colors.black)
term.setTextColor(colors.white)
-- term.setCursorPos(1,2+sh)
-- term.write(" Size: " .. length .. "L x " .. width .. "W x " .. height .. "H")
term.setCursorPos(1,3+sh)
term.write(" Volume: " .. collected .. " of ".. blocks .. " Blocks") --temp
iFuelLevel = tonumber(fuelLevel)
iBlocks = tonumber(blocks)
if iFuelLevel < 1 then
term.setCursorPos(1,5+sh)
term.write(" Oh Noes! I ran out of fuel!")
elseif iFuelLevel < iBlocks then
term.setCursorPos(1,5+sh)
term.write(" I may not be able to finish the task: Low Fuel ")
end
s = ""
end
while true do
assignData()
end
===========================================================================
--[[
File: test
Version: 1.0
Purpose: A test program for draw2
Author(s): GsnShadow
]]
(client) -- I just set up a test file with plugged in data for the most part
rednet.open("right")
local label = os.getComputerLabel()
local computerID = 32
local fuel = turtle.getFuelLevel()
local fuelNeeded = 3200
local collected = 10
local message = label .. " " .. fuel .. " " .. fuelNeeded .. " " .. collected .. " " .. 2500
rednet.send(computerID, message)