I am thinking of a feature that is is being worked on for Autoscend that might make a useful platform feature.
The idea is that a specified time before rollover, stop whatever we're doing and execute a Day-Ending Script.
I'm thinking it would need to
1: stop any running script
2: clear the command buffer
3: run a user-selected script that could do anything, but would most likely consume to full and put on pajamas. Other things may also make sense. Pulls, etc...
It would probably have to be a best-effort based script; if a running script did not exit, you might not get it run.
Also, not entirely sure what the best User Experience is if they're in the GUI or the Relay Browser when T-300 (or whatever the timeframe ends up being). If there's no script running to interrupt, does it wake up and run?
This is all related to the scripting discussion from a while back about how to have an abort function at all.
The idea is that a specified time before rollover, stop whatever we're doing and execute a Day-Ending Script.
I'm thinking it would need to
1: stop any running script
2: clear the command buffer
3: run a user-selected script that could do anything, but would most likely consume to full and put on pajamas. Other things may also make sense. Pulls, etc...
It would probably have to be a best-effort based script; if a running script did not exit, you might not get it run.
Also, not entirely sure what the best User Experience is if they're in the GUI or the Relay Browser when T-300 (or whatever the timeframe ends up being). If there's no script running to interrupt, does it wake up and run?
This is all related to the scripting discussion from a while back about how to have an abort function at all.
If you want to have your script do anything whatsoever when it exits, wrap the code in your main() function in a try/finally construct.
This is VeracityMeatFarm:
My script could "exit" or "abort" and it would still execute the finally block.Code:try { set_property( COUNTER_SCRIPT, new_counter_script ); run_tasks(); } finally { set_property( COUNTER_SCRIPT, old_counter_script ); // ... // print( "Net income = " + pnum( meat_delta ) + " Meat in " + pnum( turn_delta ) + " turns. Meat/Adventure = " + pnum( run_mpa ) ); print( "Cumulative income = " + pnum( meat_total ) + " Meat in " + pnum( turn_total ) + " turns. Meat/Adventure = " + pnum( cumulative_mpa ) ); } }