Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Widgets do not expose an attribute with a reference to the card that contains them. There are, however, several ways to accomplish what you describe.

Whenever a widget's event handler is fired, a number of variables will be in scope, including:

  • "me": the recipient of the event
  • "deck": the current deck
  • "card": the current card (there's some additional subtlety to this in Contraptions, which I will omit for clarity)
  • all of the widgets on the same card, according to their names
  • all of the cards in the deck, according to their names

So, for example, your button script might look something like:

on click do
 me.text:card.name
end

If the button happened to be named "myButton" and the card it was on happened to be named "myCard" you could equivalently say:

on click do
 myButton.text:myCard.name
end

Another way to access cards is via the deck. The "deck.card" attribute is the card that the user is presently viewing. Generally this will be the same as the "card" variable, but "deck.card" might be more up-to-date if you happen to go[] to another card midway through a script. Thus, we could also write the example as:

on click do
 me.text:deck.card.name
end

The mechanics of events are described in more detail in the Decker Reference Manual.

Does that answer your question?

(+1)

Yes! Thanks so much for the help. Decker is sick btw!