dockscreen help request

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

I have a device idea that needs a dockscreen and I don't know dockscreens.

I want a dockscreen to be spawned by an <onInstall> event that will provide an itempicker and then run some script on the picked item.

Ideally this would be inserted into the station dockscreen with parent of the install screen as its parent.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

This has not been tested, but it should work

Code: Select all


<DockScreen UNID="&dsOnInstall;"
    name=            "On Install Screen"
    type=            "itemPicker"
    backgroundID=    "&rsItemListScreen;"
    >
    <ListOptions
        dataFrom="player"
        list="*"
        />
    <Panes>
        <Default>
            <Actions>
                <Action name="Select Item" default="1" key="S">
                    (block (itm)
                        (setq itm (scrGetItem gScreen))
                        ;; do whatever you want with itm here
                    )
                </Action>
                <Action name="Back" key="B">
                    (block Nil
                        ;; run any clean up code you need here
                        (scrShowScreen gScreen gPrevScreen gPrevPane)
                    )
                </Action>
            </Actions>
        </Default>
    </Panes>
</DockScreen>

<!-- Somewhere inside the Item -->
<Events>
    <OnInstall>
        (block Nil
            (scrShowScreen gScreen &dsOnInstall; "Default")
        )
    </OnInstall>
</Events>
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

Alterecco and I apparently came up with nearly identical results, however there was an unforseen problem because dsInstallDevice tries to call a screen at the same time that the onInstall was calling the screen so I managed a workaround.

Code: Select all

<DockScreen UNID="&dsOnInstall;" 
    name=            "On Install Screen" 
    type=            "itemPicker" 
    backgroundID=    "&rsItemListScreen;" 
    > 
    <ListOptions 
        dataFrom="player" 
        list="*" 
        /> 
    <Panes> 
        <Default> 
            <Actions> 
                <Action name="Select Item" default="1" key="S">
                    (block (itm) 
                        (setq itm (scrGetItem gScreen)) 
                        ;; do whatever you want with itm here 
                    ) 
                </Action> 
                <Action name="Back" key="B"> 
                    (block Nil 
                        ;; run any clean up code you need here 
                        ;; NOTE: gPrevScreen and gPrevPane have been hacked so the substitued var names are used
                        (scrShowScreen gScreen gOldScreen gOldPane) 
                    ) 
                </Action> 
            </Actions> 
        </Default> 
    </Panes> 
</DockScreen> 

<!-- Somewhere inside the Item --> 
<Events> 
    <OnInstall> 
        (block Nil
            ;; save the intended destination screen under different variables
            (setq gOldScreen gPrevScreen)
            (setq gOldPane gPrevPane)

            ;; hack the vanilla screen to get the redirect to work properly
            (setq gPrevScreen &dsOnInstall;)
            (setq gPrevPane "Default") 
        ) 
    </OnInstall> 
</Events> 
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
Post Reply