Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+3)

Following up on Millie's post -- I made a little slider example that does what she said in the last section. This slider is animated (60 view events per second), locked (not interactive for users in Interact mode) and volatile (doesn't save the value stored in it between sessions).

%%WGT0{"w":[{"name":"timerslider","type":"slider","size":[100,25],"pos":[152,105],"locked":1,"animated":1,"volatile":1,"script":"on change val do\n\nend\n\non view do\n if me.value=180 #60 frames per second x 3#\n me.value:0\n go[\"Next\"] #change this to the name of the card you want to go to#\n else\n me.value:me.value+1\n end\nend","interval":[0,180],"style":"compact"}],"d":{}}

And, explaining the script contained in it:

on view do
if me.value=180   
me.value:0   
go["Next"]   
else  
me.value:me.value+1  
end 
end 

Or, to explain it more casually:

on every view event (60 per second on this animated widget) 
IF my stored number has reached 3 seconds (180 = 60 frames x 3) 
reset me back to 0 
then go[] to another card 
ELSE (in any other circumstance) 
make my stored number go up by 1 
end (for the if statement) 
end (for the on view do)

Technically I made a "Count Up" rather than a "Count Down" but I hope it makes sense anyway! You're welcome to use or deconstruct this example for your project.

More notes:

Probably change the go["Next"] to have the name of the card you actually want it to go to?

A live countdown timer can be a little annoying while testing your other interactive elements... But it should be fine if the rest of the card is ready.

If it's annoying while testing anyway I can explain a way to make it easier to work around while editing your project. I wanted to keep it simple for this example.

When everything works how you like.... set this timerslider widget's visibility to "None" so your players can't see it. :)

(1 edit) (+3)

Hey ahmwma, I've been at this all day and was soooo close to getting it. haha. I actually arrived at most of the code snippet myself but to reset the counter, I tried doing it from the button on my previous card 🤦‍♀️. You gave me that last piece of the puzzle to make this work, thank you so much! And thank you for coding a widget I can use to speed up my process, it'll be so helpful! 

EDIT: in the copy-paste widget, I think you have me.value:me.value+1 there under both the if and the else?

(1 edit) (+2)

Oops, you're right! I changed my mind about how to do it while I was writing the post and I think I updated the widget in my open copy of decker and forgot to update the code snippet for you.

My mistake! I'll fix it for anyone who stumbles on the thread in the future. The codebox in the post is correct, and now so is the copied widget.

It sounds like you've got it figured out now, though. :D Good luck with your project!