This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
Startup/shutdown
Started by Duster, 21 March 2016 - 09:06 PMPosted 21 March 2016 - 10:06 PM
I know there is a startup script, soo is there a shutdown one?
Posted 21 March 2016 - 10:15 PM
nope, you could override os.shutdown for your custom shutdown needs though
local oldShutdown = os.shutdown --# make a backup of the old function
function os.shutdown()
--# add your custom shyutdown here
oldShutdown() --#this is why we needed the backup
end
Edited on 21 March 2016 - 09:16 PM
Posted 21 March 2016 - 10:17 PM
Of course, that'll only trigger if you specifically run a script that calls that doctored function. If the server shuts down or the computer's chunk unloads, the system will still simply shut off without running any special code.
Posted 21 March 2016 - 10:28 PM
so there is no script that fires before the computer shuts down
Edited on 21 March 2016 - 09:29 PM
Posted 21 March 2016 - 10:39 PM
Edit: is there a way to turn off a computer on a lan network?
Posted 21 March 2016 - 10:53 PM
Of course, that'll only trigger if you specifically run a script that calls that doctored function. If the server shuts down or the computer's chunk unloads, the system will still simply shut off without running any special code.
nope, you could override os.shutdown for your custom shutdown needs thoughlocal oldShutdown = os.shutdown --# make a backup of the old function function os.shutdown() --# add your custom shyutdown here oldShutdown() --#this is why we needed the backup end
anyway to turn off computers on a lan network
Posted 21 March 2016 - 11:32 PM
Yes, peripheral.find("computer").shutdown()anyway to turn off computers on a lan network
Although, this will not run os.shutdown(), so it can't be overriden.
Edited on 21 March 2016 - 10:33 PM
Posted 21 March 2016 - 11:34 PM
what do you mean it doesnt run os.shutdown?
Yes, peripheral.find("computer").shutdown()anyway to turn off computers on a lan network
Although, this will not run os.shutdown(), so it can't be overriden.
Posted 21 March 2016 - 11:41 PM
Yes, peripheral.find("computer").shutdown()anyway to turn off computers on a lan network
Although, this will not run os.shutdown(), so it can't be overriden.
Doesn't this return an address (or side)?
peripheral.call(peripheral.find("computer"), "shutdown")
Posted 21 March 2016 - 11:46 PM
peripheral.wrap("computer").shutdown()
Shuts down wrapped computerYes, peripheral.find("computer").shutdown()anyway to turn off computers on a lan network
Although, this will not run os.shutdown(), so it can't be overriden.
Doesn't this return an address (or side)?
peripheral.call(peripheral.find("computer"), "shutdown")
Posted 22 March 2016 - 12:50 AM
Moved to Ask a Pro.
Posted 22 March 2016 - 03:06 AM
Doesn't this return an address (or side)?
peripheral.find() returns wrapped peripherals, not strings.
It is possible to do stuff with the "side name" using its optional "function" parameter, though.
Another trick is that you can use that function to perform actions through all found peripherals. For example, if you wanted to shutdown ALL computers detected on the network, you'd do:
peripheral.find("computer", function(side, object) object.turnOff() end)
Posted 22 March 2016 - 10:09 AM
If you want to do your custom shutdown over lan then you will need something on every computer which listens for a rednet signal and then calls your custom shutdown.
your master computer then just sends the correct rednet signal to all of the computers
your master computer then just sends the correct rednet signal to all of the computers
Posted 22 March 2016 - 08:33 PM
Ok ill try
If you want to do your custom shutdown over lan then you will need something on every computer which listens for a rednet signal and then calls your custom shutdown.
your master computer then just sends the correct rednet signal to all of the computers