dockscreen from code

This is a moderated forum that collects tutorials, guides, and references for creating Transcendence extensions and scripts.
Post Reply
User avatar
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

Fri Jun 12, 2009 4:04 pm

One thing I could never do is call up a dockscreen from an <invoke>.

When I tried last time, a good while ago, it just crashed. Is there some trick i'm missing?

User avatar
Wolfy
Fleet Admiral
Fleet Admiral
Posts: 5353
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Fri Jun 12, 2009 4:25 pm

copy paste the code from George's barrels? (or the longzhou sphere?) that should work- I think.
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'hycrotan 'nonBinary))
Image

User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Fri Jun 12, 2009 7:50 pm

There is no real way to do it via script (without hackage).

You can of course use the built in invoke functionality of a usable item, by having the useScreen attribute set, but if you want to do stuff from script, and use (scrShowScreen gScreen ...) the game crashes.

The reason is that the global gScreen has not been set to anything before we have entered a screen. So, ideally it should never be used when outside of a screen. Hower, there is really only ever one screen, so if it has already been set, you can reuse it for the rest of the session. You can use the trick from this snippet to make it work:

http://transcendence.pastebin.com/f1b2845ab

.]

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

Sat Jun 13, 2009 12:07 pm

a very evil hack :D
I think that we need a system to call a screen from script, it could be used to fake a radio communication system for example by popping-up a dockscreen with the image of the bridge of the other ship, just like communications in Star Control 2 than can happen in the middle of the fight, or as soon as you recon a ship.

User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Sat Jun 13, 2009 1:36 pm

digdug wrote:a very evil hack :D
I think that we need a system to call a screen from script.
Indeed. Having a standardised way of doing this would be very cool.
digdug wrote:it could be used to fake a radio communication system for example by popping-up a dockscreen with the image of the bridge of the other ship, just like communications in Star Control 2 than can happen in the middle of the fight, or as soon as you recon a ship
The only downside I can see is that a DS popping up in the middle of battle can be potentially lethal, since time does not stop time. I don't think I would like to have this feature available outside of an action triggered explicitly by me.

.]

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

Sat Jun 13, 2009 3:28 pm

so, what we need is to freeze time too, even if an abuse of this kind of dockscreens can fragment a bit too much the space-fighting experience.

User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Sat Jun 13, 2009 4:01 pm

digdug wrote:so, what we need is to freeze time too, even if an abuse of this kind of dockscreens can fragment a bit too much the space-fighting experience.
That can already be done via script. What we really cant do, is show a screen when gScreen is not set yet. Hopefully this will appear in 1.0 or further on. Ticket time perhaps?

User avatar
Bobby
Militia Captain
Militia Captain
Posts: 675
Joined: Wed Jul 25, 2007 7:39 pm

Mon Jun 15, 2009 2:45 pm

thanks all for the help, I thought about the standard usescreen attribute, but with an emergency use device sifting through 10 tons of usables could potentially be fatal. I will try that hack and see how it goes, unless there is a usekey attribute.

User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Mon Jun 22, 2009 10:43 am

On a related note, I did some sniffing around last night, and discovered what i think is the earliest way at getting at gScreen. It might not be totally relevant to this thread, but it has to do with dockscreens and script, so what the heck. Example here:

http://transcendence.pastebin.com/f3649c964

.]

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

Mon Jun 22, 2009 11:15 am

very clever! :D
<OnObjDocked> can run scrShowScreen gScreen and pop up your dockscreen, but because OnObjDocked is a station event, you registered the playership to the station with objRegisterForEvents to get the event to the playership! :shock:

and ... teleported! :D

User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Mon Jun 22, 2009 7:56 pm

digdug wrote:very clever! :D
<OnObjDocked> can run scrShowScreen gScreen and pop up your dockscreen, but because OnObjDocked is a station event, you registered the playership to the station with objRegisterForEvents to get the event to the playership! :shock:

and ... teleported! :D
:D That sounds way more magical that what is actually going on.

To recap:

A global station reponds to <OnGlobalSystemCreated> by spawning a local station in the system as soon as the system is created. This local system in turn, has the <OnObjDocked> xml event present, calling a function, (OnObjDocked). The first thing this station does, is to register for events with the playership. Now, the moment we dock with a station, (OnObjDocked) is triggered. The real cool thing, is that we can use gScreen here, even though the player has never had a screen open before. So... gScreen is always set inside <OnObjDocked> !!

Basically it allows us to reliably hijack the players dockscreen.

.]

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

Mon Jun 22, 2009 8:40 pm

in your Globals function, if you sysFindObject stations at 1 ls from the playership, can you actually get the station the gPlayership is docking to ?
If so, we can hijack ANY dockscreen with some script work ?

Post Reply