Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

RenJS

HTML5 Visual Novel creation made easy and free · By lunafromthemoon

Some Help on Choices and Conditionals

A topic by Lapinay created Jul 13, 2019 Views: 252 Replies: 4
Viewing posts 1 to 5
(3 edits)

Hi. I'm trying to prototype a simple dollmaker using Visual Choices and If statements.

Basically players choose a body type, a top and a bottom, but i don't understand why the condition doesn't do what i want sometimes... Everything works as intended, but  one thing does not: when players click on shirt 1 by example, i can't make the shirt to stick to the character...

Is there a way you could clue me in on this, lunafromthemoon? Thanks!

bodychoice:
  - show room: WITH FADE CONTINUE
  - show body_1: AT 400,300 WITH CUT
  - var body: 0
  - var bottom: 0
  - var top: 0
  # Let user choose a body type
  - visualchoice:
    - body_1 AT 200,400: 
      - var body: "{body} + 1"
      - deuzi says:  value of body is {body}
      - scene: topChoice
    - body_2 AT 400,400:
      - var body: "{body} + 2"
      - scene: topChoice
    - body_3 AT 600,400:
      - var body: "{body} + 3"
      - scene: topChoice
topChoice:
  - hide body_1: AT 400,300 WITH CUT
  - if ({body}=="1"):
    - show body_1: AT 400,300 WITH CUT
  - if ({body}=="2"):
    - show body_2: AT 400,300 WITH CUT
  - if ({body}=="3"):
    - show body_3: AT 400,300 WITH CUT
  - deuzi says: i'm at topChoice
  # Let user choose a top 
  - visualchoice:
    - top_1 AT 200,400:
      - show top_1: AT 400,300 WITH CUT
      - var top: "{top} + 1"
      - deuzi says: value of top is {top}
      - scene: topBottom
    - top_2 AT 400,400:
      - show top_2: AT 400,300 WITH CUT
      - var top: "{top} + 2"
      - deuzi says:  value of top is {top}
      - scene: topBottom
    - top_3 AT 600,400:
      - show top_3: AT 400,300 WITH CUT
      - var top: "{top} + 3"
      - deuzi says:  value of top is {top}
      - scene: topBottom
topBottom:
  - hide body_1: AT 400,300 WITH CUT
  - if ({body}=="1"):
    - show body_1: AT 400,300 WITH CUT
  - if ({body}=="2"):
    - show body_2: AT 400,300 WITH CUT
  - if ({body}=="3"):
    - show body_3: AT 400,300 WITH CUT
  - if ({top}=="1"):
    - show top_1: AT 400,300 WITH CUT
  - if ({top}=="2"):
    - show top_2: AT 400,300 WITH CUT
  - if ({top}=="3"):
    - show top_3: AT 400,300 WITH CUT
  - deuzi says: i'm at topBottom
  # Let user choose a top 
  - visualchoice:
    - bottom_1 AT 200,400:
      - show bottom_1: AT 400,300 WITH CUT
      - var bottom: "{bottom} + 1"
      - deuzi says: value of bottom is {bottom}
      - scene: yourLook
    - bottom_2 AT 400,400:
      - show bottom_2: AT 400,300 WITH CUT
      - var bottom: "{bottom} + 2"
      - scene: yourLook
    - bottom_3 AT 600,400:
      - show bottom_3: AT 400,300 WITH CUT
      - var bottom: "{bottom} + 3"
      - scene: yourLook   
yourLook:
  - hide body_1: AT 400,300 WITH CUT
  - if ({body}=="1"):
    - show body_1: AT 400,300 WITH CUT
  - if ({body}=="2"):
    - show body_2: AT 400,300 WITH CUT
  - if ({body}=="3"):
    - show body_3: AT 400,300 WITH CUT
  - if ({top}=="1"):
    - show top_1: AT 400,300 WITH CUT
  - if ({top}=="2"):
    - show top_2: AT 400,300 WITH CUT
  - if ({top}=="3"):
    - show top_3: AT 400,300 WITH CUT
  - if ({bottom}=="1"):
    - show bottom_1: AT 400,300 WITH CUT
  - if ({bottom}=="2"):
    - show bottom_2: AT 400,300 WITH CUT
  - if ({bottom}=="3"):
    - show bottom_3: AT 400,300 WITH CUT
  - deuzi says:  Here's here new look.
Developer

Hello Alix, 

What exactly is the problem? Do the body parts appear at a wrong position? Do they disappear? I'll be easier to debug if you tell us exactly what is the intended behaviour and what is actually happening.

(4 edits)

Hi :)  Let me explain. Player has to choose one body type,  one top and one bottom  for the clothes.  When player clicks on a top ( a visual choice),  the corresponding top is  shown on a position placed on top of the body type image, but the top image  (let's say a shirt), appears when shown then disappear when player has to choose a bottom in the next visual choices. I can't figure out what i did wrong. Thank you for helping.

I would be most grateful if you could check the project, here is a ZIP file:  

https://wetransfer.com/downloads/b4d8bb1f4a4a5afaa6fc086e9134743220190716173439/...
Developer

Hey, at first view, I think the main problem is that you're initializing the variables top and bottom just at the start. This is a problem because you are modifying the values with an addition instead of absolute values, so if you say you want to choose again, you keep adding and if this end value is more than 3 then you don't have anything to show.

Let me explain with an example:

scene bodyChoice

1. Init body, top and bottom with 0

2. Choose body: I choose option 1, then body = body + 1 = 0 + 1 = 1

scene topChoice

1. show body_1 because body == 1

2. Choose top: I choose option 1, then top = top + 1 = 0 + 1 = 1

scene topBottom

1. show body_1 because body == 1

2. show top_1 because top == 1

3. Choice (Ok or choose another top): I choose another top

scene topChoice

1. show body_1 because body == 1

2. Choose top: I choose option 3, then top = top + 3 = 1 + 3 = 4 (!!!!!!!)

Here's the problem, now top == 4, and you don't have a top_4 to show, and in fact, what you want to show is top_3, the same problem happens with the bottoms.

There are two ways of solving this: You can reset top and bottom to 0 at the start of the functions with the visual choice that modifies them. This means, every time you do the addition, the variable will be 0. The second option, and the one I recommend you do is to change the additions for assignations. What I mean with this is very simple: Instead of doing:

      - var top: "{top} + 1"

You do:

      - var top: 1

And the same with all the assignations, including body, top and bottom.

I think this should fix all your problems, but let me know how it goes.

Cheers!

Hi. Dear lunafromthemoon, thanks to your recommendation the magic happens. Thank you !