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

Running Program From Another Computer ('then' Expected Error)

Started by enforcer4100, 18 November 2013 - 08:08 AM
enforcer4100 #1
Posted 18 November 2013 - 09:08 AM
Hello all,

I am currently working on a project with sliding doors (via frame motors), but I am a little bit stuck when it commes to executing the commands from a central computer.

Set up:
I have a central computer A which distributes the commands.
I also have 2 computers (B and C) that control the up movement (computer B)/> and the down movement (computer C).
I had a look a quick look at google and this forums and threw together these 2 'controller scripts'.

computer B:
 
rednet.open("top")
while true do
_,message = rednet.receive()
if tostring(message) = "open" then
shell.run("redpulse", "back, "2", "1)
end
end


computer C:

rednet.open("top") 
while true do
_, message = rednet.receive()
if tostring(message) = "close" then
shell.run("redpulse", "back", "2", "1")
end
end

The problem that I have is that when I try to run the above scripts (just starting them up)
I get a error ('then' expected on line 4). I am not sure what went wrong there.
The only problem I can come up with is that I am using the tostring command wrong, but the wiki is not very clear to me.
http://computercraft.info/wiki/Tostring

My central computer (computer A) just reads input and than sends it to the proper id (with rednet.send(id, message))
depending on what the input is.

Thanks in advance
enforcer
Kingdaro #2
Posted 18 November 2013 - 09:11 AM
Line 4 and 5, both programs:
if tostring(message) = "open" then

Should have a double equal sign:
if tostring(message) == "open" then
Edited on 18 November 2013 - 08:11 AM
enforcer4100 #3
Posted 19 November 2013 - 01:07 PM
Aaah should have seen that.
Thanks for your help.