Skip to main content

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

How to make an alert message fire once only when going to a new card?

A topic by Flimsy Excuse created Oct 09, 2023 Views: 233 Replies: 2
Viewing posts 1 to 3

I want to do an alert message that pops up when entering a card (giving brief instructions, for example),

It feels like the right place to put this is in the basic card's script of "on view do" but this loops forever. What's the "right" way to do this? Looking at the events reference isn't helping me much.

e.g.

on load do

  alert["Click the thing!"]

end

Developer

The tricky part about doing something when a card is first visited is that the "view[]" event is also fired in other situations- if a deck is saved and reloaded, if a dialog box is closed, if you switch to an editing tool and then re-enter "Interact" mode, etc.

One way to approach this would be to make the alert box triggered by whatever script is used to take the user to that card. For example, if the user clicks a button to go to a card named "tutorialized", you might give that button a script like:

on click do
 go["tutorialized"]
 alert["just so you know, ..."]
end

Another way could be to make an invisible checkbox on that card, name it "tooted", and use it to keep track of whether the tutorial has been shown. This way you can be certain it will only ever be shown once, but you may need to remember to reset it before you save the deck:

on view do
 if !tooted.value
  tooted.value:1
  alert["just so you know, ..."]
 end
end

And a third way would be to make a deck-level script that intercepts the "go[]" function used to move between cards and trigger the tutorial there if the destination card is the one we're interested in. This is rather invasive and not particularly recommended:

on go card trans delay do
 c:deck.card
 send go[card trans (30 unless delay)]
 if (!c~deck.card)&(deck.card~tutorialized)
  alert["just so you know, ..."]
 end
end

Does any of that help?

(+1)

Thanks for the help! Those options are very educational.

This solution would totally fit my use case:

on click do  
 go["tutorialized"]  
 alert["just so you know, ..."] 
end

But I found this very educational:

on view do
  if !tooted.value
   tooted.value:1
   alert["just so you know, ..."]
  end
end

I tried the "hidden variable" option unsuccessfully, mainly because I couldn't figure out the syntax scripting wanted or expected and didn't find examples to work from. I know how assignment works in lil (the ":") and I had the "if" format from the lil reference card but got nowhere in general.

In fact I only just recently managed to get canvases working to contain images to use as "sprites". I fiddled around for a long while trying to use canvases as a canvas that I could draw on/in to make a sprite from within Decker. It's much better to paste an image from the clipboard but that has its own nonintuitive workflow (at least on Windows, where I can't copy from e.g. GIMP and use edit->paste as canvas / paste into canvas; I have to paste into a spare card as an image, then CTRL-C that, THEN what I think of as "Decker's" clipboard contains it properly.)

Anyway, I still managed to crank out a birthday card for a buddy in Decker: http://web.failmail.club/bday.html