13 posts
Posted 11 April 2013 - 09:32 AM
Hi, is there any function for exit/quit current running program? I found os.reboot(), but this function reset PC,
I'm looking for something like os.close() (this function doesn't exists, so don't search for that) . I tried shell.exit(), but it doesn't work.
And yes I know I can do it other way, but I want to know if something like this exists. Thnx
1214 posts
Location
The Sammich Kingdom
Posted 11 April 2013 - 09:34 AM
You can write "return" and it will exit the current function(Which the script is called as a function).
645 posts
Location
'Merica
Posted 11 April 2013 - 12:54 PM
Yeah its kinda weird, I was researching about why you can't do
os.exit()
in CC, I still didn't find a reason, but like Sammich Lord said, "return" always works too.
1522 posts
Location
The Netherlands
Posted 11 April 2013 - 01:45 PM
If you really need to, you can use error()
You would use this in a function, for example.
error('something terrible happened:/')
-- or just
error()
645 posts
Location
'Merica
Posted 11 April 2013 - 02:14 PM
If you really need to, you can use error()
You would use this in a function, for example.
error('something terrible happened:/')
-- or just
error()
Isn't it
printError("Something terrible happened :/")
not what you said. Nvm after testing it, either works, but doing my say will give you more freedom to make a custom error. But still doing "error()" would still exit the program.
379 posts
Location
Hawaii
Posted 12 April 2013 - 01:14 AM
Yea, and if you look in the bios.lua, thats how Ctrl + T works. Just conjures up an error(). But I think if you provide a message, it will display the program name and the line number the error was called from. So instead, if you want a message, you might be better off just print() ing a message and then error() ing the script.
2217 posts
Location
3232235883
Posted 12 April 2013 - 08:04 AM
Yea, and if you look in the bios.lua, thats how Ctrl + T works. Just conjures up an error().
well, when you hold ctrl-t it triggers the "terminate" event wich bypasses the event filter in the parallel api and goes to the program's coroutine and the os.pullEvent it called triggers an error and is catched by the nearest pcall wich will most likely be in the shell