Sorry, we don't support your browser.  Install a modern browser

Show UI of top card of face-up deck.#689

I have a mod that has several cards that have button that puts them back in the deck were they came from, when they are in the discard pile. However, the button only shows if the card is not in a deck object, so players need to know to pull the card off the deck to press the button.

It would be nice if there was some way to automatically have the UI appear on the deck, when the card is the top face-up card of the deck. It would be possible to emulate this with scripting, but to be resilient to things like reordering it would probably need to poll[1] to ensure the correct UI (if any) is displayed.

Some care may be needed to handle events from the UI; likely the solution is to require XML UI and have the event code tied to Global or otherwise not on the card/deck.

[1] It might be possiblle to use a combination of of onObjectEnterContainer, onObjectLeaveContainer, onObjectSearchEnd and onObjectRandomize instead, of polling; but 1) I don’t know if that is exhaustive 2) additional ways of reordering a deck may be added without corresponding events to detect them.

8 days ago

This is possible by using Lua. You should add UI to a deck when the card enters it, and delete UI when the card leaves the deck.

8 days ago

As I mentioned in my comment, I am aware it is possible using lua. But it is slightly more complicated than just using onObjectEnterContainer and onObjectLeaveContainer, as the deck can also be reordered by shuffling or searching. (And maybe other ways in the future). I think it would be useful for TTS to have direct support for doing this, rather than requiring anybody who wants this to figure out all the gotchas in implementing it.

8 days ago

Sadly for you, the developers are very unlikely to implement this, because it would mean that the cards would be alive inside a deck.

The cards are “dead” inside any deck to optimize CPU load. Their scripts are off.

8 days ago

Sadly for you, the developers are very unlikely […]

I prefer not to speculate on what they’ll implement, and give them credit for being able to come up with a creative solution.

because it would mean that the cards would be alive inside a deck.

  1. I don’t think this would be a terrible thing, if it was behind a per-card setting, and only applied to the front (and back card?)
  2. I’m aware of the issue, and suggested one way of handling that wouldn’t require the lua of the card to be loaded in my last paragraph, though I guess I wasn’t explicit that it was about dealing with the fact that the lua script isn’t currently loaded.
8 days ago