Help with Variables

Status
Not open for further replies.

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
Im making my first game and thought I understood Variables, but they dont seem to be working as I thought they would


Heres a small piece,


After the top text the scene stops without continuing. 
What I want:


The character collects "Hearts of the city" 
I tried to set variable Heart totals to = the amount the player has in his inventory 
then tried to make conditional branches for each of the totals,  Then under each of those a variable winning percentage that is random, followed by another conditional branch based on the winning percent variable to give different messages and add different variables for wins and losses.
Pictures is one small piece of the code, but the rest is written the same, what Am I doing wrong to make this work?


as it is the Character will say "Ok the results are in" and then it stops.

variables.png
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,607
Reaction score
12,927
First Language
English
Primarily Uses
RMVXA
Can you post the next part or two of the event? So far it looks good, and the part you posted will only run if the hearts is exactly equal to 0.
 

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
heres some more its long but it keeps following the same pattern but hopefully youll find whatever my mistake is that makes it cut off at the start like that

2.png

3.png

4.png

5.png
 

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
Removed
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,607
Reaction score
12,927
First Language
English
Primarily Uses
RMVXA
Check your if/elses. You have 5 ends after the >= 5 case, 4 ends in the 1 - 4 cases, and 3 in the 0 case. I think what happened is you set it up that the cases for 1+ hearts is inside the 0 hearts case, which will make it never run. Force the hearts to be 0 and see what happens.
 

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
I have no elses, only ifs, and I forced hearts to 0 and it still just shows the first line of text


I'll see if something is inside something like you said
 
Last edited by a moderator:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,607
Reaction score
12,927
First Language
English
Primarily Uses
RMVXA
Best way to check is change line two of the event to say variable 2 = 0 (not hearts collected) and see what runs. That way you can better check all the routes. Just be sure to change it back once you are done.
 
Last edited by a moderator:

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
ok after using that tag line it ran to the first txt block but doesnt show anything past the winning percent then.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,607
Reaction score
12,927
First Language
English
Primarily Uses
RMVXA
Two problems.


You have nothing for > 50 for 0 heart, only < 50 and = 50.


The code for < 50 and = 50 are inside the same if, so one of them will never run (whichever is last). You also made the same error if you have 1 heart as well (didn't check the others). What you need is:


if variable = 50


  Code here


END


if variable < 50


  code here


END


if variable > 50


  code here


END


The END tells it to stop running the if code, so you have to be outside to do the next condition. Otherwise, the only condition that will ever run is the first one (as the others are never true).
 
Last edited by a moderator:

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
Two problems.


You have nothing for > 50 for 0 heart, only < 50 and = 50.
I had  ≥  instead of > , 
But the problem was they were all inside of each other thank you very much
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
12,607
Reaction score
12,927
First Language
English
Primarily Uses
RMVXA
Same idea though. If it is solved, let us know and we can close this thread (the way is to report your post and in the report just ask us to close the thread).
 

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
ok that part was solved but I have another issue, 


I rewrote the code like attached, and now it does this:


https://youtu.be/CNPAb1W7quk


After he sez "flight outside" its supposed to add +1 to a different variable for wins, then self switch but it continues to run the other code instead of stopping.

new.png
 

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
Definitely a hair puller lol, I even tried removing the States won / tied/ lost variables and the code still wont self switch.
 
Last edited by a moderator:

NekroG

Villager
Member
Joined
Jun 1, 2016
Messages
26
Reaction score
1
First Language
English
Primarily Uses
Well im not exactly sure what I did but after 3 hours of messing with it I finally figured it out and got it working. 
 

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,614
Reaction score
10,925
First Language
English
Primarily Uses
RMVXA
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Kingdom Under Fire: The Crusaders is finally being ported to PC. I loved playing that game on the original Xbox.
A friend told me to stop making nomnom or gulping noise when eating or drinking. Plot twist of my life. I thought people can't hear that!
Inside you are two wolves. They take in oxygen while getting rid of the Co2 gas in your body...
Ah wait, sorry. Lungs. Not wolves. that'd be silly. Wolves are huge. You probably couldnt even fit one wolf inside you.
Tag: hack and slash | gameplay: point and click. Me: "How tf two are related to each other?"

Forum statistics

Threads
94,407
Messages
920,730
Members
124,196
Latest member
DysonY
Top