CC: Tweaked

CC: Tweaked

42M Downloads

Events (Shutdown/Startup)

saismeesaimonsaimes opened this issue ยท 1 comments

commented

It would be nice if we could have a file named .events or something, a bit like .htaccess in a webserver.

Here's my idea. A file named .events could be located in the root, and you could link a file like this.

.devents/startup.event startup.lua .devents/shutdown.event shutdown.lua

That would be the default file (as an example)

You could also add your own events to the .devents directory, and fire them like this:

os.fireevent(.devents/EVENTNAME.event)

This can be used to fire events for multiple other programs to run from and can be used somewhat like functions. Default events such as startup or shutdown cannot be fired manually, and only fire upon the respective times. startup and shutdown are readonly events, meaning they cannot be deleted.

Creating an event would be simple. Just do:

edit .devents/EVENTNAME.event

This will create an empty file, which cannot be edited, and is only visible (and can be deleted). Upon an event not being found with fireevent, it will cause an error and terminate.

Obviously a lot can be tweaked. I'm also very new to Github so yeah.

commented
  • Startup: I don't really want to extend the system any further than we currently have. It's already confusing having startup, startup.lua and startup/, so I don't want to add fuel to the fire.
  • Shutdown: See dan200/ComputerCraft#503. There's a lot of issues with having any ability to listen to a shutdown.
  • For any custom event, I'm really not sure about doing this. I'd rather we added a way to run background "threads" at startup (like rednet.run) and then people could just listen through os.pullEvent as normal.