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

A Possible Bug With Terminals?

Started by ChaosBeing, 27 February 2012 - 05:06 AM
ChaosBeing #1
Posted 27 February 2012 - 06:06 AM
I just encountered a curious little bug in this script I made for a custom map.

Without going into unneeded detail, there's a patrolling turtle out in a hallway and if it's patrol is interrupted it uses the rednet.broadcast method to communicate with a terminal controlling a door. All of this works perfectly fine, the doors lock appropriately when the turtle is interrupted, the timer's set, not the slightest glitch to be found…

Until I exited the map and reloaded. The turtle starts up fine and starts patrolling, and when I check the terminal, it too has run it's startup function without presenting any errors. But when the turtle's route is interrupted, the terminal failed to lock the doors. rednet.broadcast returns true, and simply by restarting the terminal, everything works like a charm.

I thought that maybe it was a problem with trying to open the wireless router at map start, but no matter what I did, putting it in another program and running it with shell or creating and loading an API that had only one function, rednet.open, delaying it, using rednet.close and then open, or a combination of any/all of those, nothing seemed to work. I still have to assume it's something I'm doing wrong and I'm still working on it (I'll post any/all code upon request) but I've gotten to the point where I have to ask if anyone else has run into a similar predicament, and if so, did you find a way around it?
Casper7526 #2
Posted 27 February 2012 - 07:06 AM
Post your code ;)/>/>
ChaosBeing #3
Posted 27 February 2012 - 08:13 AM
Sure, and thanks for taking an interest.

Turtle:
startup - http://pastebin.com/UWTmrmFN
patrol - http://pastebin.com/WzpQ9YX4
action - http://pastebin.com/aggieGsX
remoteCommand - http://pastebin.com/pm9dYVHY - More or less empty

Terminal:
startup - http://pastebin.com/MEjTUeRC
Advert #4
Posted 03 March 2012 - 07:20 AM
I've tested this, with the following scripts:

-- Sender
if fs.exists("abrupt") then
 fs.delete("abrupt")
 sleep(5)
 os.reboot()
end
-- local h = fs.open("abrupt", "w")
-- h:close()

rednet.open("right")

while true do
 rednet.broadcast("PIE!")
 print("Sent pie.")
 sleep(1)
end


-- Listener
if fs.exists("abrupt") then
 fs.delete("abrupt")
 sleep(5)
 os.reboot()
end

--local h = fs.open("abrupt", "w")
--h:close()

rednet.open("top")

while true do
 local id, msg = rednet.receive()
 print("[", os.time(), "] ", id, ": ", msg)
end

Works as expected both on turtles and computers; the file checking was to see if a new world was loaded (in case the bug was happening, which it wasn't).

You could try a similar workaround, though, but I'm not sure why rednet is failing for you.
ChaosBeing #5
Posted 03 March 2012 - 09:41 AM
Thanks for looking into it, I was pretty sure this thread was dead and buried.

I wound up just plopping another terminal down next to it and using a peripheral command to reboot the listening terminal, and it seems to be working fine for now.

It may be a little rigged, but I'm not complaining. :unsure:/>/> Just one of those odd flukes I guess.