variable dependent menu items

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
magi
Special Project Artist
Posts: 323
Joined: Thu Jul 14, 2005 7:06 pm
Projects: Hanafuda Club, Infinity Rain
Location: Arizona
Contact:

variable dependent menu items

#1 Post by magi »

Is it possible to use variable dependent menu items, or image map/image bottoms?

for example, if you have several variable, that when its set to true, an option will appear in a series of menu items or options.

for example if:
$ item1 = true
$ item2 = true
$ item3 = true

[menu]
  1. [item1]
  2. [item2]
  3. [item3]
and now if we set some of the variable to false
$ item1 = true
$ item2 = false
$ item3 = true

[menu]
  1. [item1]
  2. [item3]
and is it possible to apply something like this in image map and ui buttons and such? O.o;; Its important, in the sense that I wanted to do something that is more none-linear and modular(?) in terms of the structure of the game, and allow the player to piece together the structure of the story according to their own priorities.

This is also important in terms of the "exploration" aspect of what I wanted to do. Sort of having the player navigate through a series of image maps, but you can choose from a mnue also, but only to places that you have visited before, for example.

Another question, when I brought in an image map, overlay sort of disappears. Is it suppose to happen? Although the image map is used as a menu items, so I guess I should probably add it to the original overlay control its appearance using a variable. I still have to experiment with this. -_-;;.

Aenakume
Regular
Posts: 182
Joined: Mon Aug 11, 2008 4:38 am
Projects: Arts... i hate arts -_-
Contact:

Re: variable dependent menu items

#2 Post by Aenakume »

Yes, it is possible. For menus, simply add an if to the end of the menu, and the option will only show when the if is true:

Code: Select all

menu whatever:
    "Choose from:"
    
    "item1" if item1:
        jump option1
    
    "item2" if item2:
        jump option2
    
    "item3" if item3:
        jump option3
For imagemaps and ui buttons, just do if statements in the python blocks like you normally would:

Code: Select all

if item1:
    ui.imagebutton("item1.png")

...

Code: Select all

hotspots = []
if item1:
    hotspots += hotspot1

...

renpy.imagemap("ground.png", "selected.png", hotspots)
“You can lead a fool to wisdom, but you cannot make him think.”

magi
Special Project Artist
Posts: 323
Joined: Thu Jul 14, 2005 7:06 pm
Projects: Hanafuda Club, Infinity Rain
Location: Arizona
Contact:

Re: variable dependent menu items

#3 Post by magi »

uguu, this really show how little I know about programming.

I tested out your code, and it works. This opens up many interesting possibilities for me. :D

I have another question. I still don't understand how to add additional properties that is possible on a image map. By default, the imagemap suppresses overlays when it is shown, I know its part of the properties on the imagemap, but I don't know the proper syntax.

What I did:

Code: Select all

    $ action2 = renpy.imagemap ("action_a.png", "action_b.png", [
                                                        (47,21,132,79, "talk"),
                                                        (47,77,131,135, "look"),
                                                        (47,134,131,192, "move"),
                                                ], overlays = true )
What is wrong with this? >w<;; There is no example of adding properties after then the hot spots.

Aenakume
Regular
Posts: 182
Joined: Mon Aug 11, 2008 4:38 am
Projects: Arts... i hate arts -_-
Contact:

Re: variable dependent menu items

#4 Post by Aenakume »

i've never used overlays (or imagemaps ^_^), so i can't swear to anything...

... but i think you want "overlays = True", not "overlays = true".

Other than that, i don't think there is anything wrong.
“You can lead a fool to wisdom, but you cannot make him think.”

Post Reply

Who is online

Users browsing this forum: Ocelot