Posted 22 January 2013 - 08:49 AM
Hello, I got this two pieces of code running and it denies to send rednet OR receive rednet. Of course I turned on both modems and checked ID's. I also tried using the rednet command in between print to see what it it outputs. This is true.
Program 1:wireless turtle:
This program should reboot at the end but I removed that for debugging.
program 2:computer:monitorOnTop:
EDIT: Sorry, the prints are in dutch. It is changed to english now.
Should I go to bug reports with this?
I went to the IRC and came to the conclusion that the fault is not at the mod but at my bad coding :(/>
Can someone find out what the actual problem is?
The problem + fix:
I derp a lot..
I apoligse for the trouble I caused in the IRC, I take back everything I said. (I was claiming a bug….)
Sorry for all the trouble I caused, I punched myself already :P/>
Thanks, Engineer
Program 1:wireless turtle:
rednet.close("right")
rednet.open("right")
local sorts = {"iron ingot", "copper ingot", "tin ingot", "gold ingot"}
local turtle = 0
local numb = 0
sendID = 3
sender = tonumber(sendID)
term.clear()
term.setCursorPos(1,1)
print("Main Turtle 1.0")
print("Receiving..")
local p1, p2, p3 = rednet.receive()
local input = p2
print(input)
local p1, p2, p3 = rednet.receive()
local inputNumb = p2
print(inputNumb)
for i = 1, tonumber(#sorts) do
sleep(.1)
if input == sorts[i] then
print("Item found!")
print("Sending..")
print(rednet.send(sender, "true"))
numb = numb - numb + i
break
elseif i > #sorts then
print("Item not found!")
rednet.send(sender, "false")
sleep(10)
os.reboot()
end
end
print("Comparing..")
if numb > 0 and numb < 17 then
turtle = 5
--elseif numb > 16 and numb < 33 then
end
rednet.send(tonumber(turtle), tostring(input))
rednet.send(tonumber(turtle), tostring(inputNumb))
This program should reboot at the end but I removed that for debugging.
program 2:computer:monitorOnTop:
local m = peripheral.wrap("top")
local sendID = 7
local sender = tonumber(sendID)
local input = "-"
local inputNumb = "-"
local param2 = "-"
local p2 = "-"
function mon()
m.clear()
m.setCursorPos(1,1)
m.setTextScale(1.5)
m.write("Item: "..input)
m.setCursorPos(1,2)
m.write("Aantal: "..tostring(inputNumb))
m.setCursorPos(1,5)
m.write("In storage: "..param2)
m.setCursorPos(1,6)
m.write("Status: "..p2)
end
for k, v in pairs(rs.getSides()) do
rednet.close(v)
rednet.open(v)
end
mon()
term.clear()
term.setCursorPos(1,1)
print("Exact item name: ")
input = string.lower(read())
mon()
rednet.send(sender, tostring(input))
while true do
term.setCursorPos(1,5)
term.clearLine()
term.setCursorPos(1,4)
term.clearLine()
print("Max items per send: 1024")
write("Amount: ")
inputNumb = read()
if tonumber(inputNumb) ~= nil then
if tonumber(inputNumb) < 1025 then
mon()
rednet.send(sender, tostring(inputNumb))
break
end
end
end
term.setCursorPos(1,7)
print("Status: ")
param1, param2, param3 = rednet.receive()
if param2 == "false" then
p2 = param2
mon()
term.setCursorPos(1, 9)
print("Your item is not in storage.")
print("Press any key to continue..")
term.setCursorPos(1,7)
print("Status: Not in storage room")
local px = os.pullEvent("key")
if px ~= 1 then
os.reboot()
end
elseif param == "true" then
term.setCursorPos(1,7)
print("Status: In storage room")
mon()
end
for i = 1, 4 do
p1, p2, p3 = rednet.receive()
term.setCursorPos(1,7)
term.clearLine()
print("Status: "..p2)
mon()
end
sleep(2)
os.reboot()
EDIT: Sorry, the prints are in dutch. It is changed to english now.
I went to the IRC and came to the conclusion that the fault is not at the mod but at my bad coding :(/>
The problem + fix:
param1, param2, param3 = rednet.receive()
if param2 == "false" then
p2 = param2
mon()
term.setCursorPos(1, 9)
print("Your item is not in storage.")
print("Press any key to continue..")
term.setCursorPos(1,7)
print("Status: Not in storage room")
local px = os.pullEvent("key")
if px ~= 1 then
os.reboot()
end
[b]elseif param == "true" then[/b]
term.setCursorPos(1,7)
print("Status: In storage room")
mon()
end
param1, param2, param3 = rednet.receive()
if param2 == "false" then
p2 = param2
mon()
term.setCursorPos(1, 9)
print("Your item is not in storage.")
print("Press any key to continue..")
term.setCursorPos(1,7)
print("Status: Not in storage room")
local px = os.pullEvent("key")
if px ~= 1 then
os.reboot()
end
[b]elseif param2 == "true" then[/b]
term.setCursorPos(1,7)
print("Status: In storage room")
mon()
end
I derp a lot..
I apoligse for the trouble I caused in the IRC, I take back everything I said. (I was claiming a bug….)
Sorry for all the trouble I caused, I punched myself already
Thanks, Engineer
Edited by