5 posts
Posted 17 December 2012 - 12:42 PM
ok I'm not sure what the problem with my code is, it isn't generating any errors but the receiving terminal does not display the information.
this is what the sending computer has:
wood = {12, 12, }
print("what you want?")
local item = read()
print("how many?")
local amount = read()
if item == "wood" then
table.insert (wood, amount)
local msg = textutils.serialize(wood)
rednet.open("right")
rednet.send (2, msg)
end
and this is what the receiving computer has:
local id, msg = rednet.receive()
local wood = textutils.unserialize(msg)
print (wood[1])
print (wood[2])
print (wood[3])
I'm not entirely sure what im doing really all of what I have done so far has been accomplished by looking at the manual or the forums, but as they say the best way to learn is from your mistakes.
thanks plonkerking
7508 posts
Location
Australia
Posted 17 December 2012 - 12:44 PM
ok this may sound like its a stupid question but it has to be asked. is the receiving computers ID actually 2?
5 posts
Posted 17 December 2012 - 12:57 PM
ok this may sound like its a stupid question but it has to be asked. is the receiving computers ID actually 2?
yep the receiving computer is id 2
2088 posts
Location
South Africa
Posted 17 December 2012 - 01:02 PM
On the receiving PC change the code to this maybe:
id, msg = rednet.receive()
wood = textutils.unserialize(msg)
print (wood[1])
print (wood[2])
print (wood[3])
Making it local might be the prob
21 posts
Posted 17 December 2012 - 01:03 PM
you need rednet.open("side") on recieving computer
5 posts
Posted 17 December 2012 - 01:09 PM
you need rednet.open("side") on recieving computer
you are a genius! I knew I was missing something dead simple!
2088 posts
Location
South Africa
Posted 17 December 2012 - 01:14 PM
you need rednet.open("side") on recieving computer
Always miss the most obvious ><
7508 posts
Location
Australia
Posted 17 December 2012 - 01:15 PM
you need rednet.open("side") on recieving computer
you are a genius! I knew I was missing something dead simple!
haha its ok, apparently remiX and I did too :P/>
5 posts
Posted 17 December 2012 - 01:33 PM
great another problem!
I was trying to make the turtle move based off the variables produced but it didn't work, would you kind people please take a look and help me fix it :)/>
rednet.open("right")
local id, msg = rednet.receive()
t = textutils.unserialize(msg)
local togo = tonumber(t[1])
local amount = tonumber(t[1])
function tfuel(amount)
if turtle.getFuelLevel() < 5 then
turtle.select(16)
turtle.refuel(amount)
turtle.select(1)
end
end
function turnaround()
turtle.turnRight()
turtle.turnRight()
end
for i = 1, togo do
tfuel(1)
turtle.forward()
end
turnaround()
for r = 1, togo do
tfuel(1)
turtle.forward()
end
Edit: I fixed it on my own was just me being a plonker as my name states :P/>
apparantley you cant have 2 variables go into another variable
these were wrong:
local togo = tonumber(t[1])
local amount = tonumber(t[1])
7508 posts
Location
Australia
Posted 17 December 2012 - 02:08 PM
apparantley you cant have 2 variables go into another variable
these were wrong:
local togo = tonumber(t[1])
local amount = tonumber(t[1])
what is it saying? because you are able to!
5 posts
Posted 17 December 2012 - 02:43 PM
apparantley you cant have 2 variables go into another variable
these were wrong:
local togo = tonumber(t[1])
local amount = tonumber(t[1])
what is it saying? because you are able to!
dont know it was just frezzing and not working. Also do you know how to control how many items a turtle will suck from a chest? I've done a couple of searches but everything i tried failed :(/>
7508 posts
Location
Australia
Posted 17 December 2012 - 03:01 PM
after confirming here
http://computercraft.info/wiki/Turtle_(API)since suck doesn't seem to have an amount i would say you should do this:
turtle.select(1)
turtle.suck() -- get an entire stack
amountPulled = turtle.getItemCount()
amountDesired = 8
-- do some checks here to make sure the amount sucked is greater than the amount wanted then do this if there is more
turtle.drop(amountPulled - amountDesired) -- put back how many you dont want