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

Hello! Before anything else, I want to say how much I'm enjoying learning to use Decker---it's a real delight to make games in, and to just make fun UIs with. The reason I'm writing to you now, though, is that I've been struggling to override the default behavior in response to a link event. For example, there is a field I want to toggle the visibility of in response to a link event, so I wrote this in the script of another field that contains the link:

"on link x do

       examplefield.toggle[]

end"

but the deck still seems to be trying to navigate to a card named x instead.  Is there a different way I should be trying to override this behavior? Also, since I have your attention, is there a way to embed widgets within a rich text field? Thanks in advance for the help! Also sorry if these questions are strange or simple, I'm pretty new to coding and such.

What you're describing sounds like it ought to work. I would recommend making sure you have the script on the correct widget and checking carefully for typos. If it helps, here's a GIF of building the arrangement you describe from scratch:


It is not possible to embed widgets in rich text fields: they can only contain text (in multiple fonts), some of which can be hyperlinks, and inline images. With some fancy scripting and/or animated patterns it is possible to animate inline images within rich text. Here's an example with an "animated" field:


The script on the field:

on view do
 i:first extract arg where arg..type="image" from me.value
 i.paste[ref.copy[].rotate[sys.frame*.05]]
end

If you want to create the appearance of widgets within a rich text field, there are a variety of ways you might approach it. You could simply draw a card background that looks like interspersed text and widgets. (Using "Edit -> Copy Image" on widgets copies an image of them to the clipboard that you can then paste to the background and edit with drawing tools.) You could position widgets on top of a rich text field. You could even build Contraptions that contain other widgets (or images of them) stacked on top of a rich text field. I would recommend starting simple.

Thank you so much for your response! It really helped clarify what exactly my problem is. The field that contains the link I want to click to produce this behavior is embedded within a custom contraption, and for some reason that is causing some hiccup in my attempts to override the default behavior. So far I have tried adding this code to the script for the custom contraption and adding this code to the script for the embedded field in the prototype, but no luck yet. I'll keep trying though!

Found a hot-fix to my problem! For anyone curious, I just had to go into the prototype and override the link function in the embedded field (while being sure to point outside of the prototype with something like "deck.cards.exampleCard.widgets.exampleContraption.toggle[]"). In any case, I am having a blast making this game and am excited to share when it's in a more complete state.  Also looking forward to the Decker Summer Jam!