Debugging help requested.

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

I've (almost) finished a simple mod called Jane's Interactive Guide to Spaceships (or Jane's ROM for short).

The problem I'm having is that I want the flow to go like this:

* 'U'se ROM
* Select item to identify from list
* Hit 'I' to identify it.
=> Be told what the object is.
* Hit 'L' to leave dockscreen and return to navigation screen.

What actually happens is this.

* 'U'se ROM
* Select item to identify from list
* Hit 'I' to identify it.
=> Be told what the object is.
* Select item to identify from list
* Hit 'I' to identify it.
=> Be told what the object is.
* Hit 'L' to leave dockscreen and return to navigation screen.

Anyway I think it must be a pretty simple mistake I've made, could someone take a look and drop me a hint?

Code: Select all

    <!-- The dockscreen for the ROM user interface: -->
    <DockScreen UNID="&dsUseJanes;"
      name=       "Ship's Cargo Hold"
      type=       "itemPicker"
      backgroundID=   "&rsItemListScreen;"
      >
 
    <ListOptions
      dataFrom= "player"
      list=   "* -Alien -Illegal"
      >
        (scrSetListFilter gScreen (lambda (itm)
            (not (isItemKnown itm))
        ))
    </ListOptions>
 
    <Panes>
      <Default
          desc= "What item do you wish to identify?">
 
        <Actions>
          <Action name="Identify this item" imageID="&rsItemListScreen;" imageIndex="1" default="1" key="I">
             (scrShowPane gScreen 'Done)
          </Action>
          <Action name="Cancel" imageID="&rsItemListScreen;" imageIndex="0" cancel="1" key="C">
            <Exit/>
          </Action>
        </Actions>
      </Default>
      <Done
        noListNavigation="true"
        >

      <Initialize>
         (block Nil
            (setq itm (scrGetItem gScreen))
            (itmSetKnown itm)

            ;Check if player has wasted his Jane's ROM.
            (setq strKnown (if (itmIsKnown itm) ".  But you already knew that!" ".")) 
 
            ; Identify the Jane's ROM
            (itmSetKnown gItem)
 
            ; Remove Jane's ROM
            (objRemoveItem gSource gItem 1)

            ; Display what you've found out.
            (scrSetDesc gScreen 
               (cat "The ROM's database identifies it as " (itmGetName itm 4) strKnown)
            )
         )
      </Initialize>

      <Actions>
         <Action name="Leave" cancel="1" key="L">
            <Exit/>
         </Action>
      </Actions>

      </Done>
   </Panes>
   </DockScreen>
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

I can really tell from the xml and from your description what exactly is going on. Are you saying that the switch of pane does not happen on the first 'I' but only on the second?. From looking at your code I can not see why that should happen. Would be helpful if you posted something that could be run easily.

Perhaps try to set the item the player is trying to identify already in the calling action:

Code: Select all

<Action name="Identify..." key="I">
  (block Nil
    (setq gItemToIdentify (scrGetItem gScreen))
    (scrShowPane gScreen 'Done)
  )
</Action>
and then just use gItemToIdentify in your other pane? Not sure if that would change anything though.
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

alterecco wrote:Would be helpful if you posted something that could be run easily.
Well you can download the mod.
I can really tell from the xml and from your description what exactly is going on. Are you saying that the switch of pane does not happen on the first 'I' but only on the second?.
If you 'I'dentify two items in a row the action listed changes to 'L'eave. I presume that the action changing corresponds to the pane changing, but I don't really know what's going on. Also if you change the selection in the list instead of hitting 'I' right away then you can keep going to identify more, and more items. (Never changes to the 'L'eave action).
Perhaps try to set the item the player is trying to identify already in the calling action:

Code: Select all

<Action name="Identify..." key="I">
  (block Nil
    (setq gItemToIdentify (scrGetItem gScreen))
    (scrShowPane gScreen 'Done)
  )
</Action>
and then just use gItemToIdentify in your other pane? Not sure if that would change anything though.
I'll give it a whirl. I've just spotted one (unrelated) error in my code anyway. :oops:

[EDIT] Didn't seem to make any difference.
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

That is a weird bug, it's caused by trying to remove Jane's rom (objRemoveItem gSource gItem 1) and if you more that up to the default pane it works as intended.

The list options code

Code: Select all

(scrSetListFilter gScreen (lambda (itm) 
            (not (isItemKnown itm)) 
        ))
Doesn't work, isItemKnown is not a function but itmIsKnown is. However, with only unknown items shown you will never have to use

Code: Select all

;Check if player has wasted his Jane's ROM. 
            (setq strKnown (if (itmIsKnown itm) ".  But you already knew that!" "."))
Here's is the working version I ended up with

<ListOptions
dataFrom= "player"
list= "* -Alien -Illegal"
>
(scrSetListFilter gScreen (lambda (itm)
(not (itmIsKnown itm))
))
</ListOptions>

<Panes>
<Default>

<Initialize>
(block nil
(setq gItemToIdentify (scrGetItem gScreen))
(if gItemToIdentify
(scrSetDesc gScreen "What item do you wish to identify?")
(scrSetDesc gScreen "All your items are already known.")
)
(scrEnableAction gScreen 0 gItemToIdentify)
)
</Initialize>

<Actions>
<Action name="Identify this item" default="1" key="I">
(block Nil
; Identify the Jane's ROM
(itmSetKnown gItem)

; Remove Jane's ROM
(objRemoveItem gSource gItem 1)

(scrShowPane gScreen 'Done)
)
</Action>
<Action name="Cancel" cancel="1" key="C">
<Exit/>
</Action>
</Actions>
</Default>
<Done
noListNavigation="true"
>

<Initialize>
(block Nil
(itmSetKnown gItemToIdentify)

; Display what you've found out.
(scrSetDesc gScreen
(cat "The ROM's database identifies it as " (itmGetName gItemToIdentify 4))
)
)
</Initialize>

<Actions>
<Action name="Leave" cancel="1" key="L">
<Exit/>
</Action>
</Actions>

</Done>
</Panes>
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!
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

ptbptb wrote:Well you can download the mod.
Sorry, I completely missed that -_-

I think Prophet spotted it right... I think that when you remove an item from the list, or in general manipulate the list (even move the cursor), the initialize block is run. I may recall this incorrectly though... Perhaps the OnInit block is more suited for this? (It's been too long since I dabbled in screens)
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

alterecco wrote:I think Prophet spotted it right... I think that when you remove an item from the list, or in general manipulate the list (even move the cursor), the initialize block is run. I may recall this incorrectly though... Perhaps the OnInit block is more suited for this? (It's been too long since I dabbled in screens)
The noListNavigation="true" attribute is a useful one to know as well.
User avatar
ptbptb
Militia Lieutenant
Militia Lieutenant
Posts: 143
Joined: Mon May 10, 2010 7:34 pm

Thanks a lot Prophet. I've had the time to try that out properly and I only found one glitch, that I was able to fix. It always identified the first item on the list - whichever item you had selected. I think that was due to having a bit too much of the code inside the Initialize element, but it all seems to be working fine now.
Post Reply