Just wondering if this is the right way to use the rednet event:
rednet_message, id , msg, dist = os.pullEvent()
print(id, msg, dist)
If so im getting problems with this…
Or how do you use it?
rednet_message, id , msg, dist = os.pullEvent()
print(id, msg, dist)
emty, is, msg, dist = os.pullEvent("rednet_message")
More or less, that should work. What kind of problems are you having with it?
Unless you are only trying to pull rednet_message, in which case you should do this:emty, is, msg, dist = os.pullEvent("rednet_message")
function drawLines()
term.clear()
term.setCursorPos(1,1)
paintutils.drawLine(1, 10, 50, 10, 128)
end
rednet.open("right")
red1 = paintutils.loadImage(red)
green1 = paintutils.loadImage(green)
while true do
emty, id, msg, dist = os.pullEvent("rednet_message")
print(id, msg, dist)
if id == 3 then
if msg == "green" then
drawLines()
paintutils.drawImage(green1, 25, 10)
else
drawLines()
paintutils.drawImage(red1, 25, 10)
end
else
drawLines()
end
end
id, msg, dist = rednet.receive()
Nope. rednet.receive() returns three args:id, msg, dist = rednet.receive()
function drawLines()
term.clear()
term.setCursorPos(1,1)
paintutils.drawLine(1, 10, 50, 10, 128)
end
rednet.open("right")
red1 = paintutils.loadImage(red)
green1 = paintutils.loadImage(green)
while true do
emty, id, msg, dist = os.pullEvent("rednet_message")
print(id, msg, dist)
if id == "3" then
if msg == "green" then
drawLines()
paintutils.drawImage(green1, 25, 10)
else
drawLines()
paintutils.drawImage(red1, 25, 10)
end
else
drawLines()
end
end
function drawLines()
term.clear()
term.setCursorPos(1,1)
paintutils.drawLine(1, 10, 50, 10, 128)
end
rednet.open("right")
red1 = paintutils.loadImage("red")
green1 = paintutils.loadImage("green")
while true do
emty, id, msg, dist = os.pullEvent("rednet_message")
print(id, msg, dist)
end
With this:function drawLines() term.clear() term.setCursorPos(1,1) paintutils.drawLine(1, 10, 50, 10, 128) end rednet.open("right") red1 = paintutils.loadImage(red) green1 = paintutils.loadImage(green) while true do emty, id, msg, dist = os.pullEvent("rednet_message") print(id, msg, dist) if id == "3" then if msg == "green" then drawLines() paintutils.drawImage(green1, 25, 10) else drawLines() paintutils.drawImage(red1, 25, 10) end else drawLines() end end
At the moment im geting "paintutils:14: Expected string"
adding quotation marks onto the loadimage paramaters stops this, but then nothing shows up atall.
With this:function drawLines() term.clear() term.setCursorPos(1,1) paintutils.drawLine(1, 10, 50, 10, 128) end rednet.open("right") red1 = paintutils.loadImage(red) green1 = paintutils.loadImage(green) while true do emty, id, msg, dist = os.pullEvent("rednet_message") print(id, msg, dist) if id == "3" then if msg == "green" then drawLines() paintutils.drawImage(green1, 25, 10) else drawLines() paintutils.drawImage(red1, 25, 10) end else drawLines() end end
At the moment im geting "paintutils:14: Expected string"
adding quotation marks onto the loadimage paramaters stops this, but then nothing shows up atall.
I c the problem you have to use red1 = paintutils.loadImage("red") with "" for a name
adding quotation marks onto the loadimage paramaters stops this, but then nothing shows up atall.
Yeah, the pull event is not working, this doesnt even show anything.function drawLines() term.clear() term.setCursorPos(1,1) paintutils.drawLine(1, 10, 50, 10, 128) end rednet.open("right") red1 = paintutils.loadImage("red") green1 = paintutils.loadImage("green") while true do emty, id, msg, dist = os.pullEvent("rednet_message") print(id, msg, dist) end
function drawLines()
term.clear()
term.setCursorPos(1,1)
paintutils.drawLine(1, 10, 50, 10, 128)
end
rednet.open("right")
red1 = paintutils.loadImage("red")
green1 = paintutils.loadImage("green")
while true do
event, id, msg, dist = os.pullEvent("rednet_message")
print(id, msg, dist)
if id == 1 then
if msg == "green" then
drawLines()
paintutils.drawImage(green1, 25, 10)
elseif msg == "red" then
drawLines()
paintutils.drawImage(red1, 25, 10)
end
else
sleep(10)
drawLines()
end
end
try thisfunction drawLines() term.clear() term.setCursorPos(1,1) paintutils.drawLine(1, 10, 50, 10, 128) end rednet.open("right") red1 = paintutils.loadImage("red") green1 = paintutils.loadImage("green") while true do event, id, msg, dist = os.pullEvent("rednet_message") print(id, msg, dist) if id == 1 then if msg == "green" then drawLines() paintutils.drawImage(green1, 25, 10) elseif msg == "red" then drawLines() paintutils.drawImage(red1, 25, 10) end else sleep(10) drawLines() end end
the id shut not be inbetween ""
Before we go too far, where are the "red" and "green" images stored on the computer? They require absolute paths, just like the fs api.