Coding for overlays

Hey everyone! I was wondering how I limit my reader to only choosing 3 overlays. I see some stories where you will have to choose certain objects but you’re only limited to 2 or 3. How do I code this?

If you mean like a find the object mini game, you code them as tappables. You just code those specific overlays to be able to be tapped-- or if they’re hidden, you can put overlays with opacity 0 over them and have those be the overlays people tap. The overlay must be put in a specific layer and cannot be overlapping with another overlay. Only the top overlay can be tapped. They’re coded similar to choices. For example, if you wanted someone to find the rubber duck and a bar of soap, you might have something like this:

label game
tappable
“DUCK” {
&overlay DUCK opacity 0 in 1
@GAMECOUNTER +1
NARRATOR
You found the duck!
if (GAMECOUNTER = 2) {
goto after_game
} else {
goto game
}
} “SOAP” {
&overlay SOAP opacity 0 in 1
@GAMECOUNTER +1
NARRATOR
You found the soap!
if (GAMECOUNTER = 2) {
goto after_game
} else {
goto game
}
}
label after_game
NARRATOR
You found all the objects!

For me, I use a counter in order to keep track of how many objects have been found. You can do this and have objects that the reader can tap, but not the specific object by not adding to the counter.

Thank you! But in one of the stories I recently read, you have to choose three items to take with you for your survival, but I don’t exactly know how to code it so the reader can choose whichever 3 they want, but stop them at 3

You would need to use the points system for that. For each overlay they tap on, make the reader gain 1 point. Then use an if/else where if they have 3 points they move on with the story and if they have less than three points they go back to choose another overlay

label tap_game

tappable
“HAT” }
@CHARACTER +1

} “MASK” {
@CHARACTER +1

}”SHOE”{
@CHARACTER +1

}”JACKET”{
@CHARACTER +1
}

if (CHARACTER = 3)
NARR
You have 3 items now. Let’s move on.
goto end_tap_game

} elif (CHARACTER = 2)
NARR
You have 2 items. You need 1 more item.
goto tap_game

} else {
NARR
You have 1 item. You need 2 more items.
goto tap_game
}

label end_tap_game
#continue story here

1 Like

Thank you! It worked for the most part, but when she clicks two items it still says “you only have one item, please choose two more” and then it allows the character to choose all the items, here’s my coding :slight_smile:
label tap_game

tappable
“WATER”{
@LYVIA +1

@overlay WATER opacity 0 in 2

}“ROPE2”{
@LYVIA +1

@overlay ROPE2 opacity 0 in 2

}“FIRST AID KIT”{
@LYVIA +1

@overlay FIRST AID KIT opacity 0 in 2
@overlay KIT SUPPLIES opacity 0 in 2

}“SILENCER”{
@LYVIA +1

@overlay SILENCER opacity 0 in 2

}“KNIFE”{
@LYVIA +1
@overlay KNIFE opacity 0 in 2

}if (LYVIA = 3){
NARRATOR
You have chosen 3 items.

goto end_tap_game

} elif (LYVIA = 2){
NARRATOR
You have 2 items. Please chose one more.
goto tap_game

} else {
NARRATOR
You have 1 item. Please choose two more.
goto tap_game
}

label end_tap_game

Make sure to reset story progress or refresh the page if you’re using the web previewer. If you only just keep restarting the episode and playing through those parts the points just keep adding up.

Or you can just add @CHARACTER =0 after before the label tap_game

I tried to add the @CHARACTER=0 but it still didn’t work. She chooses one item and it says “You have one item, please choose two more.” But after she chooses her second one, it still says the character has only picked up one item.

Can you show where you put this?

label tap_game
@LYVIA =0
tappable
“WATER”{
@LYVIA +1

@overlay WATER opacity 0 in 2

}“ROPE2”{
@LYVIA +1

@overlay ROPE2 opacity 0 in 2

}“FIRST AID KIT”{
@LYVIA +1

@LYVIA walks to spot 0.272 112 382 in 2 AND LYVIA is walk_neutral_rear

@LYVIA faces right

@LYVIA is reach_kneel_neutral

@overlay FIRST AID KIT opacity 0 in 2
@overlay KIT SUPPLIES opacity 0 in 2

}“SILENCER”{
@LYVIA +1

@overlay SILENCER opacity 0 in 2

}“KNIFE”{
@LYVIA +1
@overlay KNIFE opacity 0 in 2

}if (LYVIA = 3){
NARRATOR
You have chosen 3 items.

goto end_tap_game

} elif (LYVIA = 2){
NARRATOR
You have 2 items. Please chose one more.
goto tap_game

} else {
NARRATOR
You have 1 item. Please choose two more.
goto tap_game
}

label end_tap_game

I even tried resetting the points, I think it has something to do with the coding where it says “you have 1 item”

Sorry I meant to say place this before the label not after :weary:

I think this worked! Thank you so so much! I was stressing out over it, I couldn’t get it to work! <3

1 Like

Would it be okay if I ask you one more thing?

For sure, what do you need help with?

I was wondering how I can make my character remember that she chose the rope or knife, etc. I looked at your templates but I’m not quiet sure how I would fit that into all of my coding, I don’t want to mess it up.

You can add gains for those options.

Thank you! I figured everything out.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.