Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits) (+4)

Hi! No stupid questions, it's always good to ask if you're confused -- and this looks like a fun project!
I'm going to take a guess at rewriting your script, and then explain the changes I made.

on click do
play["sound2"]
sleep["play"] 
    if haveicefish.value
    go["card3"]
    else
    go["card2"]
    end
end

And now I'll walk you through it:

sleep["play"]

sleep[] is used to make pauses/delays in Decker. 
In this case, I'm telling Decker to sleep[] until it's done "play"-ing that sound.

if haveicefish.value
go["card3"]
else
go["card2"]
end

Since it's a binary choice like this, we can put everything together into one If... Else... statement. 
(I'll get back to the .value thing in a moment.)

I'm only checking for haveicefish.value now. If the player doesn't haveicefish Decker will use the script written under else instead.

(And if the script under "else" would be "do nothing", you don't need to have an "else" section at all.)

Additionally, if you need more branching possibilities you can use elseif

if haveicefish.value 
go["fishparty"]
elseif havesmallfry.value 
go["bigpond"]
else
go["smallpond"]
end

You can also check if multiple things are True, if one or the other is True, or is something is False in these ways:

if thing1.value & thing2.value # AND
if thing1.value | thing2.value # OR
if ! thing1.value # NOT

Finally, each If... statement needs it's own end, separate from the end of the overall script.

on click do
    if truething.value
    alert["yay!"]
    end
end

Hopefully this all made some amount of sense so far! Let's talk about the other thing...

haveicefish.value

So, I've been using .value here because I'm actually not sure what you're checking. (I might just be missing something.) But I'll explain what I'm doing with that. 

Variables in Decker are typically stored in widgets. 
If it's a binary true/false situation I might store it in a button styled as a checkbox:


if haveicefish.value would check to see if this checkbox is marked/True/value=1
Checkboxes can be made to be true or false in your various scripts like this:

haveicefish.value:1 #writes the value true/checked/1 to this checkbox
haveicefish.value:0 #writes the value false/unchecked/0 to this checkbox

If you're doing something that isn't just true/false and you need to store a number (perhaps the number of fish caught?), you might put that in a slider or a field. This slider's .value is the number that it has stored in it.


It really depends on what you're trying to do though, so please ask! Especially if I've rambled about things you don't need, or if I've made something more confusing.

---

One more note about storing things in widgets... sometimes I'll store all my widgets that track game flags and variables that I'll need to check later on a "behind-the-scenes" card and point to them in my scripts like this:

if fishstatus.widgets.haveicefish.value

This would look for the card "fishstatus", look at the names of it's widgets, find the widget named "haveicefish" and see if it's value is true (a marked checkbox, I guess) before proceeding with the rest of the if statement. 

It can be longer to write (depending on how you name things), but it's often handy to store this stuff -- in their widget containers -- on a separate card together.

I hope something in here helped.