gScreen troubles ? (resolved)

Freeform discussion about anything related to modding Transcendence.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2615
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Tue Aug 18, 2015 3:26 pm

so, I'm trying to get some code to determine if a dockscreen is open or not.
The simplest way I could think was to check if gScreen exist. I thought that gScreen existed only when a dockscreen is open. After closing it, the variable should clear ?

Example:
- start a game
- (iserror gScreen) returns True
- open the ship's Interior screen
- close it
- (iserror gScreen) returns Nil

I was expecting it to return True ? shouldn't scrExitScreen clear the variable ?
What am I missing ?

PM
Fleet Admiral
Fleet Admiral
Posts: 2400
Joined: Wed Sep 01, 2010 12:54 am

Tue Aug 18, 2015 4:55 pm

digdug wrote:The simplest way I could think was to check if gScreen exist. I thought that gScreen existed only when a dockscreen is open. After closing it, the variable should clear ?
gScreen does not clear after (scrExitScreen ...).

It would be nice if we can tell if a dockscreen is open or not. I do not know of any way. Checking if playership is docked helps when player is docked, but not for sudden pop-ups in space like the Morning Star intro in EP.

In upcoming Playership Drones, I use a timed event to open a dockscreen one tick after game start, then freeze time up to a day's worth of ticks (player will probably run out of fuel if he waits for hours). Exiting screen resumes time. That stops Morning Star or other timed events from doing things until PSD settings dockscreen is done and time resumes, but it does not check for errors or dockscreens already up (because I do not know how, if it is possible).

EDIT: Ticket requesting dockscreen detection posted at Ministry.
Download and Play in 1.9 alpha...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
Star Castle Arcade: Relive classic arcade gaming in a new Transcendence adventure!
Playership Drones (WIP): Acquire more wingmen from Ship Broker. Unfinished, but updated to 1.8 beta.
Drake Technologies (Alpha) for 1.8: If you do not have 1.9 alpha 1...

User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2615
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Tue Aug 18, 2015 5:28 pm

In upcoming Playership Drones, I use a timed event to open a dockscreen one tick after game start
That's exactly what I would like to do too. And run into problems because AssumedPseudonym is doing the same.

PM
Fleet Admiral
Fleet Admiral
Posts: 2400
Joined: Wed Sep 01, 2010 12:54 am

Tue Aug 18, 2015 5:30 pm

For now, an near-indefinite time stop then resume by the pop-up event ending should suffice. That only works if all modders do that. If the one does not, it breaks.
Download and Play in 1.9 alpha...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
Star Castle Arcade: Relive classic arcade gaming in a new Transcendence adventure!
Playership Drones (WIP): Acquire more wingmen from Ship Broker. Unfinished, but updated to 1.8 beta.
Drake Technologies (Alpha) for 1.8: If you do not have 1.9 alpha 1...

User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1094
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Tue Aug 18, 2015 5:35 pm

 This would actually be fairly easy if gScreen properly cleared — I’ll put a Ministry post up on that shortly. All you’d need is something like, (if (and (gr (unvGetTick 1)) (not gScreen)) «dockscreen stuff»), cancel the timer in <OnPaneInit>, and let the engine sort out what fires first.

EDIT: …Or not. Y’all beat me to it.
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)

User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1094
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Tue Aug 18, 2015 6:25 pm

 I don’t usually doublepost, but lighting this thread up again to make sure y’all see this is worth it.

 Set the dockscreen to pop up with a recurring timer set to go off every tick. Cancel the timer in <OnPaneInit>. Since the <OnPaneInit> won’t fire until the dockscreen actually shows up, the timer won’t cancel, meaning the dockscreen will eventually pop up. The engine will have to sort the order, is all. It’s probably best to keep the stoppage of time in <OnPaneInit>, too, though I recommend using (sysStopTime 7200 (sysFindObject nil 'NG)) instead of (sysStopTime 7200 gPlayerShip) to make sure the playership doesn’t run out of gas or drift halfway from Kibo to Sol while the player is in the dockscreen in the case of EP.
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)

PM
Fleet Admiral
Fleet Admiral
Posts: 2400
Joined: Wed Sep 01, 2010 12:54 am

Tue Aug 18, 2015 7:28 pm

Recurring event is what I would use if there is a way to detect if dockscreen is active. Otherwise, there may be error spam from whatever if the dockscreen is resolved quickly enough.

Yes, excluding something other than playership is useful in case player gets placed near a gravity well. Tried gem of contrition near Sirius B, and my ship could still slingshot around the star. It would be nice if we could exclude nothing when stopping time, but that does not seem to work. Something must be excluded.
Download and Play in 1.9 alpha...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
Star Castle Arcade: Relive classic arcade gaming in a new Transcendence adventure!
Playership Drones (WIP): Acquire more wingmen from Ship Broker. Unfinished, but updated to 1.8 beta.
Drake Technologies (Alpha) for 1.8: If you do not have 1.9 alpha 1...

User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2615
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Tue Aug 18, 2015 9:23 pm

We sort of resolved it !

Something like this code allows a dockscreen to open, while another one is waiting in line using a recurring event.
The recurring event is then canceled in the OnPaneInit ! Great intuition by AssumedPseudonym :)

Of course, I also stop time in the dockscreen otherwise we break Eternity Port introduction.

Code: Select all

<!-- This station is just a global event hook -->
<StationType UNID="&WE_RandomWeaponsGlobalStation;"
    virtual= "true"
    >
  <Events>
    <OnGlobalPlayerEnteredSystem>
			(block (station)
				(block nil
				 (if (and (not (sysGetData (sysGetNode) "GlobalUpdateInited")) (eq (sysGetName) "Eridani"))
				 	 (block nil
				 	 (sysAddTypeTimerEvent 5 &WE_RandomWeaponsGlobalStation; "WEBootStrapDockScreen")
				 	 (printTo 'log "Fire the bootstrapping!")
				 	 )
				 ))
			)
    </OnGlobalPlayerEnteredSystem>				

    			<WEBootStrapDockScreen>
			(block Nil
				
				(sysAddTypeRecurringTimerEvent 10 &WE_RandomWeaponsGlobalStation; "WE_DockscreenChecker")
				(printTo 'log "BOOTSTRAP!")
				
			)
			</WEBootStrapDockScreen>
			
		<WE_DockscreenChecker>
		(block Nil
			(printTo 'log "FireDockscreen!")
			(scrShowScreen Nil &dsWEConfigurator;)
			
		)
		
		</WE_DockscreenChecker>
		
		  </Events>
		  </StationType>
gScreen should still clear when a dockscreen is closed, but at least now it's not an urgent fix :)

PM
Fleet Admiral
Fleet Admiral
Posts: 2400
Joined: Wed Sep 01, 2010 12:54 am

Wed Aug 19, 2015 1:08 pm

Are ye sure this is resolved? I still do not see a way to check if a dockscreen is up or not. If you try to fire a dockscreen while one is up, you get an error message from the object that tried to fire an event. Sure, you may use the error to delay the dockscreen, but that feels very sloppy. Also, Morning Star breaks if it tries to fire its dockscreen intro while another dockscreen is up.

For stopping time, I decided to use a special virtual station that stops time except itself during its <OnCreate> event, and starts time during its <OnDestroy> event. I cannot always count on stargates or other similar objects being available to exclude in any given system. (For example, I load the mod in Star Castle Arcade, which has no star or gates in its lone system.)
Download and Play in 1.9 alpha...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
Star Castle Arcade: Relive classic arcade gaming in a new Transcendence adventure!
Playership Drones (WIP): Acquire more wingmen from Ship Broker. Unfinished, but updated to 1.8 beta.
Drake Technologies (Alpha) for 1.8: If you do not have 1.9 alpha 1...

User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2615
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Wed Aug 19, 2015 1:54 pm

If you try to fire a dockscreen while one is up, you get an error message from the object that tried to fire an event. Sure, you may use the error to delay the dockscreen, but that feels very sloppy.
true, I see errors in the debug.log, but I don't see them ingame at least.
Also, Morning Star breaks if it tries to fire its dockscreen intro while another dockscreen is up.
true again.

What I do is to spam my dockscreen at tick 10 from game start and kill the recurring timer in the dockscreen OnPaneInit.
It's compatible with AssumedPseudonym dockscreen (that fires at tick 2), and with Morningstar dockscreen (because I stop time in the dockscreen).

So, for now, what I'm doing is compatible with Eternity Port and TBR (and possibly any other mod that fires dockscreens at game start). It's not pretty and it's possibly a near-hack. If George plans to fix the tickets we made, great, that would be awesome. In the meantime, I can work with this, so I can release mods without putting pressure on George for just 1 fix. Remember the old ugly hacks we used to do to the ship's Interior dockscreen to add stuff to it ? :)

BTW, AssumedPseudonym found out that if you sysStopTime for -1 duration, it's infinite stop.
Also you can't stop time with Nil as exception I noticed. So AssumedPseudonym stops time except a stargate, I decided to except my own virtual station. (The sun would be another option, unless we make some custom mod topology without suns in the future.)

PM
Fleet Admiral
Fleet Admiral
Posts: 2400
Joined: Wed Sep 01, 2010 12:54 am

Wed Aug 19, 2015 5:35 pm

digdug wrote:Also you can't stop time with Nil as exception I noticed. So AssumedPseudonym stops time except a stargate, I decided to except my own virtual station. (The sun would be another option, unless we make some custom mod topology without suns in the future.)
I noticed too. I use a virtual station that does time during its OnCreate and OnDestroy events. If I develop some mods with topology, I might add "systems" of deep space (i.e., has no star) and/or no stargates.
Download and Play in 1.9 alpha...
Drake Technologies (Alpha): More hardware for combat in parts 1 and 2!

Other playable mods from 1.8 and 1.7, waiting to be updated...
Godmode v3 (WIP): Dev/cheat tool compatible with D&O parts 1 or 2.
Star Castle Arcade: Relive classic arcade gaming in a new Transcendence adventure!
Playership Drones (WIP): Acquire more wingmen from Ship Broker. Unfinished, but updated to 1.8 beta.
Drake Technologies (Alpha) for 1.8: If you do not have 1.9 alpha 1...

User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1094
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Tue Apr 12, 2016 10:02 pm

 I know I’m kind of necroposting here, but I had a random out-of-the-blue lightbulb moment while I was mowing yesterday that I forgot to check until earlier today. Given how glitchy the gScreen variable has been shown to be in the past, I decided to do a little more experimentation with it. It may be pointless to check whether gScreen is defined, but y’know what does work? Checking whether (scrGetDesc gScreen) gives you any output. As long as the dockscreen actually has a description set for it (which, barring either buggy or excessively lazily written code, all dockscreens should), having that return nil will definitively let you know that you’re not in a dockscreen.
 With that in mind:

Code: Select all

(if (not (scrGetDesc gScreen)) («Code goes here»))
 That should give you code that will only run if no dockscreen is open. …And with that in mind, I am now sorely tempted to write a library for whose sole purpose is to run that check every tick and clear gScreen if there is no dockscreen open, just to simplify matters for other modders once this thread gets too thoroughly buried to be easily dug up with a search…
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)

gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Sun Apr 17, 2016 7:46 pm

I discovered by accident that calling (scrRefreshScreen gScreen) when no dockscreen is open generates an error.

I've been catching the error using the code below, which may also work as a general way to check if a screen is open:

Code: Select all

(isError (scrRefreshScreen gScreen))

User avatar
AssumedPseudonym
Fleet Officer
Fleet Officer
Posts: 1094
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

Sun Apr 17, 2016 11:00 pm

 That’d be better code to use than mine, actually, since it’ll work even if someone lazied their way through coding a dockscreen and didn’t include a proper description for it.
Image

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)

gunship256
Militia Commander
Militia Commander
Posts: 451
Joined: Sat Jul 25, 2015 11:41 pm
Location: repairing armor

Mon Apr 18, 2016 12:24 am

It's worked really well. The only downside I've seen so far is that sometimes a mod doesn't benefit from having a dockscreen refreshed constantly - for example, if the screen description is set to some temporary informative message that would be overwritten upon a refresh.

I've been using the refresh to avoid the problems that pop up when stuff enters or exit the ship's cargo hold when an itemPicker screen is open. For example, if one of my patch spiders installs or uninstalls itself, or if the thermo shell nanofac makes shells, the cursor will change, but itemPicker won't refresh. The result is that a different item is selected than is actually shown on the non-refreshed screen, leading to problems with buying and selling items that the player doesn't intend to.

I solved the problem for my mod (smart patch spiders), although it doesn't solve the problem for other items (thermo shell nanofac). There's a more complete discussion in this forum thread.

Code: Select all

(isError (setq theCursor (scrGetListCursor gScreen)))
									
(shpInstallDevice gSource theDevice)
									
; Refresh the dockscreen pane in case moving this device around broke itemPicker
; Used isError in case scrRefreshScreen is called while a dockscreen is not currently pulled up
; Use scrGetListCursor and scrSetListCursor to remember where we were in
; the itemPicker list

(isError (scrRefreshScreen gScreen))
(isError (scrSetListCursor gScreen theCursor))

Post Reply