Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Is there a way to have a button pressed on another card, then have it checked by another button on a different card?

For instance, if I have a card/room called Pieces, and two other cards that are Puzzle Rooms, I want a button in each puzzle room to be pressed in order for the button in Pieces to do something. To make it sound simpler, I want the player to steal treasures from both rooms, before going into final room to leave.

This is what I have, however it keeps believing  that the buttons are not being pressed.

on click do
if puzzleroom.button1.pressed and puzzpleroom2.button2.pressed
 dd.open[deck]
 dd.say["You successfully stolen all treasures!"]
 dd.close[]
 go["end"]
else
  alert["You must collect all treasures to leave!."]
end
end

And then for my puzzle rooms buttons, I have the same thing:

on click do
pressed:true 
end

Am I doing it right? Forgive me if this is silly, I am still trying to wrap my around this...

(+1)

You’re almost there, but unfortunately Decker doesn’t allow you to add a pressed attribute to a button like that. If you want to keep track of a flag like “treasure taken”, the easiest thing would be to make a button in the puzzle-room called treasuretaken, configure it to be a checkbox, and “Show None”. Then the button that takes the treasure can do:

on click do
 treasuretaken.value:1
end

(note that you have to say 1, not true: Decker’s scripting language Lil does not recognise true and false specially, and treats them both as undefined variables)

…and the button that checks for taken treasures can do:

on click do
if puzzleroom1.treasuretaken.value & puzzleroom2.treasuretaken.value
 dd.open[deck]
 dd.say["You successfully stolen all treasures!"]
 dd.close[]
 go["end"]
else
 alert["You must collect all treasures to leave!"]
end
end

(note that the way to say “both these things must be true” is & not and - Lil does not recognise and either)

Thank you so much, this helped a ton! But weirdly, I don't know if it's just me, but when I make it checkbox + show none, I am unable to press it.

(+3)

Yes, if a checkbox is set to "show none" you can't interact with it. I think in the example given the idea is you have a hidden checkbox that stores whether the button is pressed, and then you have your normal visible button with code in it to set the value in the checkbox. I hope this makes sense?

I see! Thank you so much, was feeling kind of stupid LOL I will mess around with this!

(+2)

Hopping in too (Hello!)

There is a fun thing about buttons which is often overlooked -- All buttons can store a value, not just checkboxes.

So you don't need a second button to be a checkbox at all.

We often talk about checkboxes because the mark is visible and easier to understand but if you don't want to have a separate hidden checkbox you can change your button back to what it was originally and use this script in it:

on click do  
me.value:1 
end

When you use "me" like this in a script it refers to the widget the script is attached to... so the button (of any style you like and any name) will set it's own value to "1" when this script is inside of it and the button is clicked.

One more small correction, in the beginning of your progress checking script:

on click do  
if puzzleroom.widgets.button1.value & puzzleroom2.widgets.button2.value

Putting .widgets. between the card name and the widget name is an important part of telling Decker where to find your widget. 

Of course, use the correct names for your particular buttons and cards at this moment!

A side note about setting the value in a hidden or non-checkbox button:

Doing it this way has a side effect of being a little harder to uncheck the buttons when you want to reset the game while testing it.... but you could set these two particular buttons as 'Volatile' if you wanted to. 

That makes it so you can clear their .value anytime using [ File > Purge Volatiles ] in the menu. 

This would also remove their .value when the project is saved.

Volatile is dangerous to use on anything precious and irreplaceable -- but it's fine for temporary things like progress checkmarks.

If you feel comfortable using it you can select the widget you're using to store this progress .value and use [Widgets > Volatile] to make it Volatile.

(Again, this is not for anything precious like your art assets! Disposable .values only here!)

This whole project sounds lovely :D We're all rooting for you.

(+2)

You don't understand how much I appreciate the help! The .widgets helped a lot-- I was not understanding why it wasn't working until I realized. I cannot wait to show everyone what I was able to make during the last few weeks! It is very scuffed though!