Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Modifying card/widget state from inside Ply?

A topic by avery created 12 days ago Views: 87 Replies: 2
Viewing posts 1 to 2
(+1)

Hi!

Messing around for the jam, and have been considering doing something with Ply. I'd like to be able to affect the state of my card (say, toggling visibility of some widget `toggler` by using `toggler.toggle["solid"]`) from within my Ply syntax.

Currently, with the twine player from https://beyondloom.com/decker/twee.html#twineplayer ,  I cannot find a way to do this. Throwing `{toggler.toggle["solid"]}` inside of the syntax here seems to have no effect. I assume this is some sandboxing / side effect of the way lil is handled by the twee library, but I'm curious if there's existing work on this topic that I could draw from instead of sitting down and plonking away at this myself.

Thanks!

Developer(+1)

By default, the Ply renderer doesn't have the deck, cards, or any local widgets in scope when it evaluates a Lil fragment, so it can't manipulate parts of the deck.

If you're using "twee.render[story passagename vars]" directly like in this demo, "vars" can be a dictionary containing arbitrary bindings, including references to the widgets of the current card.

The PlyPlayer contraption has similar functionality, but it is less flexible; you can read and write its .vars attribute, but this feature is only designed to store data that can be serialized in a field's .data attribute, not references to deck parts.

The easiest way to have Ply stories interact with a surrounding deck is to use the passage[] event that the PlyPlayer emits every time it visits a new passage. By keeping deck-influencing logic separate from the Ply story itself the story will still be entirely playable within the Twine editor. There's some relevant discussion in this thread.

Does that help at all?

(+1)

Yes! This is super helpful. Should've figured it was a scope thing :p. Many thanks!