Help with Variables

Discussion in 'RPG Maker MV' started by NekroG, Nov 3, 2016.

Thread Status:
Not open for further replies.
    Tags:
  1. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    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
     
    #1
  2. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    10,864
    Likes Received:
    10,493
    Location:
    USA
    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.
     
    #2
  3. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    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
     
    #3
  4. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    Removed
     
    Last edited by a moderator: Nov 3, 2016
    #4
  5. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    10,864
    Likes Received:
    10,493
    Location:
    USA
    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.
     
    #5
    NekroG likes this.
  6. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    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: Nov 3, 2016
    #6
  7. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    10,864
    Likes Received:
    10,493
    Location:
    USA
    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: Nov 3, 2016
    #7
    NekroG likes this.
  8. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    ok after using that tag line it ran to the first txt block but doesnt show anything past the winning percent then.
     
    #8
  9. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    10,864
    Likes Received:
    10,493
    Location:
    USA
    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: Nov 3, 2016
    #9
    NekroG likes this.
  10. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    I had  ≥  instead of > , 
    But the problem was they were all inside of each other thank you very much
     
    #10
  11. bgillisp

    bgillisp Global Moderators Global Mod

    Messages:
    10,864
    Likes Received:
    10,493
    Location:
    USA
    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).
     
    #11
  12. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    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
     
    #12
  13. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    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: Nov 3, 2016
    #13
  14. NekroG

    NekroG Villager Member

    Messages:
    26
    Likes Received:
    1
    First Language:
    English
    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. 
     
    #14
  15. Kes

    Kes Global Moderators Global Mod

    Messages:
    19,162
    Likes Received:
    9,823
    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.
     
    #15
Thread Status:
Not open for further replies.

Share This Page