Skip to main content

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

I'm trying to make it so that in my current project of a little visual novel, that if you aren't comfortable with specific content, it boots your back to the 1st card, and if you're okay with said content, it moves to the third page. I have it set up as a boolean, but there may be better ways to go about it, any help I can get with this?

adult_ok:true
on view do
 dd.open[deck]
 dd.say["This game may contain adult themes not suitable for all audiences"]
 r:dd.ask[
  "If you're okay with these terms, proceed forward:"
  ("YES", "NO")
 ]
 if r~0
  adult_ok:true
  dd.say["Then, the Contract has been Sealed."]
 else r~1
  adult_ok:false
  dd.say["Then, the World was covered in Darkness."]
 end
 dd.close[]
end
# later in the game, after the dialog
if not adult_ok
 go["home"]
else
 # continue game normally
end
(+1)

The basic logic you have there is sound, but I can spot a few problems that are likely to trip you up.

The most basic is, Decker doesn’t have true and false constants - those are just variable names and are nil by default, so if true alert["hello"] end will never show an alert, unless you happen to have defined true:1 somewhere else. Where you would write true and false, just change them to 1 and 0 respectively.

The next problem you’re likely to hit is that the value of the adult_ok variable is not preserved between events. If you want to store that value somewhere, you need to store it in something - in this case, probably a button with the “Checkbox” appearance on a card somewhere. If you don’t already have a card to store the state of the game, you can make a new one called, say “gamestate”, put a button named adult_ok on it, give it the “Checkbox” appearance, and then in your code you can do:

gamestate.widgets.adult_ok.value:alert["Are you OK with seeing adult content?" "bool" "Yes"]

…to ask the user and store the resurt in gamestate.widgets.adult_ok.value. Then you can later check it:

if gamestate.widgets.adult_ok.value
 go["adultcontent"]
else
 go["nextmorning"]
end

Of course, that’s assuming you actually want to store the answer and adjust the game accordingly. If you just want to make a disclaimer and only proceed to the actual game if the player clicks “yes”, then you don’t actually need to store that anywhere: if the player winds up anywhere but the first two cards, you can assume they must have clicked “yes” at some point in the past. Then you can just write:

if alert["Are you OK with seeing adult content?" "bool" "Yes"]
 go["thesagabegins"]
else
 go["titlescreen"]
end

…and never worry about it again.