Skip to main content

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

I have returned!I have two questions!

My first question has to do with Button Shortcuts. As of right now, I have a puppet that does something when it is clicked, and another when it is released. I wanted to see if I could activate the puppet using a keyboard button, like spacebar. The only issue is that as far as I know, the button widget is the only way to create a shortcut like this, and whenever I use it to send a click event to my puppet, it treats the puppet like it is being perpetually being clicked down after the button press, and doesn't seem to respond to being released either. I tried making the button animated and making sure it wasn't on toggle, but so far it does not look like there is any way to make a button widget that responds to being released. (My guess is because buttons dont typically count as "clicked" until they are released, making releasing them kind of impossible.) My main goal is to just interact with the puppet using the spacebar though, so if there is another way of both clicking and releasing the puppet using keyboard, that should work too.

My second question is about Puppeteer itself. I was just wondering if you could make puppeteer code refer to variables somehow. Something along the lines of "!show [variable] smile", to make it possible to basically just costume change a puppet without having to make an all new one to sit around on the same card. (Clearing puppets won't work for what I'm doing since I need them to retain the scripts that I gave them.) 

(+4)

The Canvas is the only widget that has both click and release events, and the Button is the only widget that responds to keyboard presses, so you can’t make something that starts when you hold a key and stops when you release.

However, you can make the button send a click, then wait a while, then send a release, which is probably as close as you’re going to get:

on click do
 canvas1.event["click" 0,0]
 sleep[15] # in 60ths of a second
 canvas1.event["release" 0,0]
end

That can look a little weird, since Decker disables all interactive widgets (drawing them greyed out) until the sleep time is complete, but it prevents the player from doing more things while the previous things are still going on.

If you don’t want to freeze things like that, you can build something a little more complex that lets Decker keep doing things while you wait. Create a field to hold the timer countdown, and change the button click handler to:

on click do
 canvas1.event["click"]
 field1.data:15
 field1.animated:1
end

So when the button is clicked, it sends the click event to the Canvas, it loads 15 into the field, and sets the field to be animated (so Decker sends it view events 60 times a second). The field’s view handler looks like this:

on view do
 me.data:me.data - 1
 if me.data = 0
  canvas1.event["release" 0,0]
  me.animated:0
 end
end

So every time view is called (that is, 60 times a second), it subtracts 1 from the value it stores. When it reaches 0, it sends the release event to the canvas, and turns off animation again. As a result, when the button is clicked, the canvas is “clicked”, then things keep happening as usual while the timer ticks down, and when it does the canvas is “released”.

The field can be made “Show None” if you don’t want the player to see it; if you make the button “Show None” then it won’t react to the keyboard. However, you can make the button use the “Invisible” style to hide it, and “Show Transparent” to make it invisible even when clicked. You can also just move it off-screen.

I've actually been messing around with animated timers for a bit now, but I never realized you could actually toggle widgets being animated like that. It actually made me pretty anxious from adding too many so I wouldn't lag out the program. I'll definitely be using that second solution you gave, thank you so much for your help!