This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Noodle's profile picture

Can't Update Coords?

Started by Noodle, 25 April 2012 - 12:44 AM
Noodle #1
Posted 25 April 2012 - 02:44 AM
http://pastebin.com/zJGJH4Ai
Above is the code.
Both computers connect and they can move around and stuff but it doesn't show on the other's computer?
I use vars for the send and connecting.
It sends a msg rednet.send(player2, "up") and when the other computer receives it should do
currentY = currentY - 1
drawSprite() – redraws the screen.

But it doesnt seem to do that?
ComputerCraftFan11 #2
Posted 25 April 2012 - 03:26 AM
http://pastebin.com/f0QB7bxD

This should fix it.
It never worked because it never received

The second while true do will never happen until the first is canceled

I changed it to elseif event == "rednet_message" then


P.S. wanna be in nexus again?
Noodle #3
Posted 25 April 2012 - 03:38 AM
It didn't work?
But I get: "the second while true do will never happen until the first is canceled"
So attach all them together?
I GET IT!

And no.. Not nexus again. Head of OS Dev I was… Now im gone.
Noodle #4
Posted 25 April 2012 - 04:45 AM
http://pastebin.com/NxefAEXT
Help please! I fixed still not working!
Luanub #5
Posted 25 April 2012 - 05:23 AM
First off the edit feature is a nice thing to use on the forums..

Second try this, I just slightly changed the if logic and added in breaks to stop the loops prior to moving to the next function. Everything else looks correct.

Spoiler

function movementMulti()
	    while true do
			    event, key, command = os.pullEvent()
			    if event == "key" then
            if key == 17 and currentY >= 1 then
					        currentY = currentY - 1
					        rednet.send(player2, "up")
					        drawSpriteMulti()
                break
			        elseif key == 31 and currentY <= 18 then
					        currentY = currentY + 1
					        rednet.send(player2, "down")
					        drawSpriteMulti()
                break
			        elseif key == 30 and currentX >= 1 then
					        currentX = currentX - 1
					        rednet.send(player2, "left")
					        drawSpriteMulti()
                break
			        elseif key == 32 and currentX <= 50 then
					        currentX = currentX + 1
					        rednet.send(player2, "right")
					        drawSpriteMulti()
			               break
            end
			    elseif event == "rednet_message" then
					    if key == player2 and command == "up" then
							    currentY2 = currentY2 - 1
							    drawSpriteMulti()
                break
					    elseif key == player2 and command == "down" then
							    currentY2 = currentY2 + 1
							    drawSpriteMulti()
                break
					    elseif key == player2 and command == "left" then
							    currentX2 = currentX2 - 1
							    drawSpriteMulti()
                break
					    elseif key == player2 and command == "right" then
							    currentX2 = currentX2 + 1
							    drawSpriteMulti()
                break
					    else
							    drawSpriteMulti()
                break
					    end
			    end
	    end
end
Noodle #6
Posted 25 April 2012 - 01:13 PM
I see what you did there.. I'ma try.
Noodle #7
Posted 25 April 2012 - 01:18 PM
Ahh.. no it didn't work.
OminousPenguin #8
Posted 25 April 2012 - 01:41 PM
Edit: never mind