Scriptable pause?

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 580
Joined: Sun Jul 21, 2013 12:26 pm

Scriptable pause?

Post by Astrobe » Sun Jul 16, 2017 7:37 am

I often play Oolite and a game called "IRL" at the same time. Sometimes IRL has time triggered events, like going to the bathroom or feeding the cat, that require you to put on your Oculus Real for a few minutes.
It's always dangerous to let Oolite run for a few minutes because you don't know what will appear at the edge of the scanner next minute, so you have no choice but pause the game.
The ability to pause the game with a script would be useful in these situations. One could do for instance a script that auto-pauses when the condition turns red, or when you are cleared to dock.

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Scriptable pause?

Post by Diziet Sma » Mon Oct 23, 2017 6:29 am

I just came across this.. it seems to have faded with no attention paid, despite a considerable number of views.


So for the record, I'm saying this sounds like an excellent idea.. anyone else want to chip in?
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 580
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scriptable pause?

Post by Astrobe » Thu Oct 26, 2017 5:05 pm

Diziet Sma wrote:
Mon Oct 23, 2017 6:29 am
I just came across this.. it seems to have faded with no attention paid, despite a considerable number of views.
Well actually, I believe that crawlers from Google etc. artificially increase that count.
So for the record, I'm saying this sounds like an excellent idea.. anyone else want to chip in?
The feature is still on my TODO list, together with try to do something about the CPU utilization when the game is paused (~20% here).

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Scriptable pause?

Post by Diziet Sma » Fri Oct 27, 2017 1:22 am

Astrobe wrote:
Thu Oct 26, 2017 5:05 pm
Well actually, I believe that crawlers from Google etc. artificially increase that count.

I keep forgetting that on this board, search engine spiders are "registered members".. on most boards they don't increase the view count.
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

User avatar
hoqllnq
Commodore
Commodore
Posts: 154
Joined: Sun Jan 08, 2006 7:32 pm

Re: Scriptable pause?

Post by hoqllnq » Sun Oct 29, 2017 6:56 pm

This is in todays nightly.

It is a new Global method

function pauseGame() : Boolean

It does not pause the game on screens that are can normally not be paused by keyboard: mission screens, long range chart, arrival report, save menu. In those cases, the function returns false. Otherwise it pauses the game and returns true.

There is no protection mechanism like timeout or override (should there be?), so it is up to the OXP dev to make sure you don't get in a pause-loop where the script pauses again immediately after the user un-pauses.

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 580
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scriptable pause?

Post by Astrobe » Sun Oct 29, 2017 7:56 pm

Wow, thanks.

About the protection mechanism, in my humble opinion it's true that a bug in the script could be very annoying, but scripting bugs can ruin the game even with less "imperative" functions anyway.

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 580
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scriptable pause?

Post by Astrobe » Fri Nov 03, 2017 2:31 pm

Here is a bare-bones script (old OXP format, unzip in AddOns folder).

Buy the "Autopause" equipment (only 1Cr - profits will be shared with Hoqllnq, promised), and if you prime that equipment, the game pauses automatically when condition goes red.

BUT: I've observed keyboard malfunctions after un-pausing. First time it apparently switched to mouse control mode (it might just have been my fat fingers though), the next times the "fire laser" key did not work until I switched views. Tested on PC.

User avatar
hoqllnq
Commodore
Commodore
Posts: 154
Joined: Sun Jan 08, 2006 7:32 pm

Re: Scriptable pause?

Post by hoqllnq » Sat Nov 04, 2017 10:07 pm

Astrobe wrote:
Fri Nov 03, 2017 2:31 pm
keyboard malfunctions
Have you observed any more of those with the patch I gave you
and have you used it enough to confidently say they are gone?
I have tested in different screens and not found issues.
Thanks.

User avatar
phkb
Commodore
Commodore
Posts: 2280
Joined: Tue Jan 21, 2014 10:37 pm
Location: [p]laying [h]ard and [k]icking [b]utt somewhere in G7...

Re: Scriptable pause?

Post by phkb » Sun Nov 05, 2017 12:16 am

Astrobe wrote:Buy the "Autopause" equipment
Kind of breaking the fourth wall here a bit, aren't we? Pausing the game is a meta-command (ie something that the in-game world doesn't understand). But by making it a purchasable item, it's now crossed the boundary between game-world and real-world. Which is a long-winded way of say, I don't think this should be a purchasable item. Although, to be fair, at 1cr it's hardly worth quibbling over, is it? Leave it as it is. :D

But I really like the concept though! I think this can be a really useful tool for players like me who generally run with the sound off, so don't get audible warnings when red alerts take place. Very handy for when I'm on my way to the sun to scoop some fuel, and I run into an angry mob of pirates courtesy of Space Crowds.

User avatar
Diziet Sma
---- E L I T E ----
---- E L I T E ----
Posts: 6310
Joined: Mon Apr 06, 2009 12:20 pm
Location: Aboard the Pitviper S.E. "Blackwidow"

Re: Scriptable pause?

Post by Diziet Sma » Sun Nov 05, 2017 4:48 am

phkb wrote:
Sun Nov 05, 2017 12:16 am
Astrobe wrote:Buy the "Autopause" equipment
Kind of breaking the fourth wall here a bit, aren't we?

We could always rename it to "Ferris Bueller Equipment", or "Deadpool Device".. :lol: :lol: :lol: :lol:

(or maybe just "Save Ferris!")
Most games have some sort of paddling-pool-and-water-wings beginning to ease you in: Oolite takes the rather more Darwinian approach of heaving you straight into the ocean, often with a brick or two in your pockets for luck. ~ Disembodied

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 580
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scriptable pause?

Post by Astrobe » Sun Nov 05, 2017 9:35 am

phkb wrote:
Sun Nov 05, 2017 12:16 am
Astrobe wrote:Buy the "Autopause" equipment
Kind of breaking the fourth wall here a bit, aren't we? Pausing the game is a meta-command (ie something that the in-game world doesn't understand). But by making it a purchasable item, it's now crossed the boundary between game-world and real-world. Which is a long-winded way of say, I don't think this should be a purchasable item. Although, to be fair, at 1cr it's hardly worth quibbling over, is it? Leave it as it is. :D
Well that was just a quirk-and-dirty job. But equipment items are handy because of the mode switch feature, which would let us have different pause criteria.
But I really like the concept though! I think this can be a really useful tool for players like me who generally run with the sound off, so don't get audible warnings when red alerts take place. Very handy for when I'm on my way to the sun to scoop some fuel, and I run into an angry mob of pirates courtesy of Space Crowds.
Someone on IRC called it the "ALT tab" thing (not him but hello, Spalthy876!) so yes, it has more than one uses. The idea of adding mini-games or occupations for when you are masslocked has been discussed several times here; I think this feature partially solves it by letting the player do something else outside of the game - one nice thing about Oolite is that is not too resource-hungry, so you can have other programs running in the background - thus letting us being "productive" while playing. Not the best solution but not a bad one either.

BTW, if someone wants to take over this OXZ, feel free. I have to many things on my todo list already (for instance, I'd like to return to the city lights feature).
Last edited by Astrobe on Sun Nov 19, 2017 2:35 pm, edited 1 time in total.

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 580
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scriptable pause?

Post by Astrobe » Sun Nov 05, 2017 9:45 am

hoqllnq wrote:
Sat Nov 04, 2017 10:07 pm
Astrobe wrote:
Fri Nov 03, 2017 2:31 pm
keyboard malfunctions
Have you observed any more of those with the patch I gave you
and have you used it enough to confidently say they are gone?
I have tested in different screens and not found issues.
Thanks.
It triggered several times without issues since. If there's still a bug in there it's probably hiding in an edge case, so it shouldn't be critical. so I think the fix can be submitted to trunk. Let the guinea pigs^H^H beta testers to their job :lol:

User avatar
hoqllnq
Commodore
Commodore
Posts: 154
Joined: Sun Jan 08, 2006 7:32 pm

Re: Scriptable pause?

Post by hoqllnq » Sun Nov 05, 2017 6:18 pm

I have two alternative fixes:

https://github.com/jobi-wan/oolite/comm ... 177071ea74

https://github.com/jobi-wan/oolite/comm ... c7e22b19d0

Both do essentially the same thing: They move the pause/resume code form pollFlightControls and pollDockedControls to a place where Global pauseGame can use it too.
The first one moves the pause/resume code to a new method in PlayerEntity(Controls) and adds a PlayerEntity method to call it from outside.
The second one moves pause/resume code to Universe pauseGame/resumeGame. I thought this was going to be cleaner but I ended up needing some new methods to restore the saved state. It may still be nicer to have all the pause/resume in Universe pauseGame/resumeGame.

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 580
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scriptable pause?

Post by Astrobe » Sun Nov 19, 2017 2:34 pm

I've updated the auto-pause script/equipment.

Please note that it is now in OXZ format. I can't make it available from the manager yet because I can't require version 1.87 in the manifest.

This version lets you choose between pausing on yellow or red condition with equipment mode key switch 'b'.

Astrobe
---- E L I T E ----
---- E L I T E ----
Posts: 580
Joined: Sun Jul 21, 2013 12:26 pm

Re: Scriptable pause?

Post by Astrobe » Sun Dec 03, 2017 12:48 pm

FWIW the version I've uploaded a few weeks ago was borken: switching modes didn't work.

Also, who should I talk to in order to have a 1.87 version tag for the manager?

Post Reply