In-game menu and variables. [SOLVED]

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
AlexCLD
Newbie
Posts: 24
Joined: Sun Mar 22, 2015 6:44 pm
Projects: Just a Number
Contact:

In-game menu and variables. [SOLVED]

#1 Post by AlexCLD » Sat Apr 18, 2015 12:04 pm

Hi, I have a doubt with the In-game menu. I have been trying to create a skill menu that allows the player to choose his abilities (only three of twelve) but all I get are errors. Here is the code:

Code: Select all

init:
    
    $ variable1 = False
    $ variable2 = False
    $ variable3 = False

    
    define n = Character(None, kind=nvl)

# The game starts here.
# - El juego comienza aquí.
label start:
    
    $ point = 1
    
    menu:
        "1" if variable1 = False:
            $ variable1 == True
            jump level1
        "2" if variable2 = False:
            $ variable2 == True
            jump level1
        "3" if variable3 = False:
            $ variable3 == True
            jump level1

label level1:
    
    $ point +=1
    
    menu:
        "1" if variable1 = False:
            $ variable1 == True
            jump level2
        "2" if variable2 = False:
            $ variable2 == True
            jump level2
        "3" if variable3 = False:
            $ variable3 == True
            jump level2
             
             
label level2:
    
    $ point += 1
    
    menu:
        "1" if variable1 = False:
            $ variable1 == True
            jump level3
        "2" if variable2 = False:
            $ variable2 == True
            jump level3
        "3" if variable3 = False:
            $ variable3 == True
            jump level3
    
    
label level3:
    
    if point >= 3:
        jump game
        
label game:
    
    n "Hi!"
And here is the issue:

Image

The question is: Is there any way to make this more simple?
or at least, how do I make it work? :?
Last edited by AlexCLD on Sat Apr 18, 2015 12:44 pm, edited 1 time in total.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: In-game menu and variables.

#2 Post by trooper6 » Sat Apr 18, 2015 12:19 pm

Code: Select all

# The game starts here.
# - El juego comienza aquí.
label start:
    $ variable1 = False
    $ variable2 = False
    $ variable3 = False    
    $ point = 1
    
    menu:
        "1" if variable1 == False:
            $ variable1 = True
            jump level1
        "2" if variable2 == False:
            $ variable2 = True
            jump level1
        "3" if variable3 == False:
            $ variable3 = True
            jump level1
Two things.
1) I always put *all* my variables inside the start label, this makes sure they participate in saving and rollback properly.
2) "=" is used to assign a value, "==" is used to compare a value.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

AlexCLD
Newbie
Posts: 24
Joined: Sun Mar 22, 2015 6:44 pm
Projects: Just a Number
Contact:

Re: In-game menu and variables.

#3 Post by AlexCLD » Sat Apr 18, 2015 12:43 pm

Thanks for the quick answer! I fixed the errors and this is working well. I make a mess when assigning variables... :lol:

Post Reply

Who is online

Users browsing this forum: Google [Bot]