Skip to main content

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

Emitting na event on ply link click?

A topic by avery created 28 days ago Views: 96 Replies: 3
Viewing posts 1 to 2
(+1)

Hi! Haven't been able to find any discussion on this exact topic, apologies if I've missed a solution sitting right in my face.

Messing with Ply and Twee once more. I wanted to create a link that might shoot out an event when clicked, but not link between Passages. If I could define custom syntax, it might look something like:

```

:: LinkingPassage

There's a lightswitch. <Click!->flickswitch>

[[Whatever.->SomeOtherPassage]]

```
`Click!` would show up as a hyperlink that would send the event `flickswitch` out to the deck when clicked.
Now, there are some horrible ways I could do this, like linking to a passage with some tags (`SpawnDogImage`) that I ingest somewhere as in the twee.deck example, then run some logic that adds my dog image to the deck then renders the previous passage, maybe changing some state to change how the passage is rendered. Obviously, this feels pretty gross.

Is there an idiomatic way to emit an event when clicking on a rich text link in Decker that I'm missing? I'm completely fine with writing some inline Lil in my twees, custom syntax was a pipedream example..

Thank you for your incredible work on Decker as always :) hope to have something neat to show when this project is done.

Developer

Rich-text links can contain any string as their "link payload", and rich-text fields generate a link[] event with this string as an argument when clicked. (See: Events in the decker reference manual.)

If you examine the link[] event handler in the card-level script of the deconstructed twine player example, you can see how the event changes the active passage and renders the new one. Introducing an appropriate convention for the link payload- say, an "@"" prefix- would make it reasonably straightforward to make certain link events trigger different events on the current card instead of changing passage and re-rendering. With some internal surgery you could also make similar changes to the behavior of the PlyPlayer contraption.

Make sense?

(+1)

Believe so! Haven't had a chance to play with this yet, but when I do I'll come back and let you know :)

(+1)

Ok yes! Can custom-handle the event with my own logic in the card. Really nice and simple. I'll try to make a minimal project to demonstrate the kinds of workflow im interested in doing with this and share it around!