10 posts
Posted 15 January 2014 - 12:40 AM
I have a odd problem with one of my computers. When the server automatically restarts, my
program does not seem to start up again once the server comes back online. To get the program working again, all I have to do is restart the computer(in-game).PastebinThe computer is wired to four drawbridges, who hides my elevatorblocks when I'm not around.
7083 posts
Location
Tasmania (AU)
Posted 15 January 2014 - 02:09 AM
How do you "restart the computer"? Just right click on it, or…? If there's more to it then that, then what's the computer doing before you restart it?
Which versions of MineCraft + ComputerCraft are you using?
10 posts
Posted 15 January 2014 - 03:15 AM
I'm running MC 1.5.2 with ComputerCraft 1.5.3
When I start up the program by writing startup in the terminal view, everything works like it should. It's after a server restart the problem appears, and to resolve it I have to reboot the computercraft computer by pressing ctrl+t to terminate the program and ctrl+r to reboot, once this is done everything is back to normal and working again.
The odd thing is that the program starts up after a server restart, but it does not appear to go trough the code.
2151 posts
Location
Auckland, New Zealand
Posted 15 January 2014 - 04:03 AM
I presume it's named startup, if it isn't then thats probably your answer.
My guess is that the API your using isn't loaded when the computers turned on, but it's a complete guess. Try throwing a fairly large sleep, at least 30 seconds, (you may need to use multiple sleeps with smaller amounts if it says too long with out yield) and see what happens.
Edited on 15 January 2014 - 04:27 AM
10 posts
Posted 15 January 2014 - 05:23 AM
Ah yes, I'll try that.
Thanks for the input.
1281 posts
Posted 15 January 2014 - 05:38 AM
The api will always be there, it would throw an error otherwise when loading it. However, the sleep should do the trick, as the sensor might not be in the same chunk, and thus not properly loaded. I do not know how the sensor api would react in such a situation. Alternativly you could use
while not peripheral.getType(side) == "sensor"
sleep(1)
end
Edited on 15 January 2014 - 04:46 AM
892 posts
Location
Where you'd least expect it.
Posted 15 January 2014 - 09:20 AM
The api will always be there, it would throw an error otherwise when loading it. However, the sleep should do the trick, as the sensor might not be in the same chunk, and thus not properly loaded. I do not know how the sensor api would react in such a situation. Alternativly you could use
while not peripheral.getType(side) == "sensor"
sleep(1)
end
There's an event for that:
while not peripheral.getType(side)=="sensor" do
os.pullEvent("peripheral") --Waits until a peripheral is attached
end
1281 posts
Posted 15 January 2014 - 09:50 AM
ah, yes that would be even better i suppose.