Show Python Function At Right? [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
QotC
Regular
Posts: 54
Joined: Thu Feb 17, 2011 8:53 pm
Contact:

Show Python Function At Right? [Solved]

#1 Post by QotC »

So, I managed to make buttons that allow you to turn to the right or the left:

Code: Select all

    def rb(place, active = True):
        active = active
        place = place
        if active == True:
            ui.imagebutton("button_right.PNG", "button_right.PNG", clicked = ui.jumps(place))

    def lb(place, active = True):
        active = active
        place = place
        if active == True:
            ui.imagebutton("button_left.PNG", "button_left.PNG", clicked = ui.jumps(place))               
 
#...

label north:
    scene bg wall1
    show door closed at center
    $rb("east")
    $ui.interact()

label east:
    scene bg wall2
    $lb("north")
    $ui.interact()

Not the most efficient model (and if anyone can help with that, I'm all ears), but it apparently works. The problem is, I need to put these buttons on opposite sides of the screen, and I can't for the life of me figure out how to move them. :(

I've tried show $rb("east") at right - It says "expected name not found."
Show expression $rb("east") at right - "expected 'simple_expression' not found."

I've even tried putting it inside a vbox and moving the vbox:

Code: Select all

label north:
    scene bg wall1
    show door closed at center
    vbox(xanchor = right, xpos =1):
        $rb("east")
    $ui.interact()
It says "expected statement". (Incidentally, the wiki has virtually nothing to say about vboxes and hboxes, and the manual that came with renpy doesn't seem to adress my needs. -__-)

Can anyone give me some insight?
Last edited by QotC on Fri Aug 12, 2011 12:04 pm, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 3095
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Show Python Function At Right?

#2 Post by Alex »

The problem is, I need to put these buttons on opposite sides of the screen
Just add the position properties to the buttons, like

Code: Select all

ui.imagebutton("button_right.PNG", "button_right.PNG", clicked = ui.jumps(place), xpos=700, ypos=50, xalign=0.5, yalign=0.5)
I've even tried putting it inside a vbox and moving the vbox:
Code:
label north:
scene bg wall1
show door closed at center
vbox(xanchor = right, xpos =1):
$rb("east")
$ui.interact()

It says "expected statement".
I think, that <vbox:> is a screen language statement and should be used inside screens. Inside labels and functions you can use <ui.vbox> and <ui.close()> http://www.renpy.org/wiki/ui.vbox
So, it may looks like

Code: Select all

init python:
    def rb(place, active = True):
        active = active
        place = place
        if active == True:
            ui.vbox(xalign = 0.9999, xanchor = "right")
            ui.imagebutton("button_right.PNG", "button_right.PNG", clicked = ui.jumps(place))
            ui.close()

    def lb(place, active = True):
        active = active
        place = place
        if active == True:
            ui.imagebutton("button_left.PNG", "button_left.PNG", clicked = ui.jumps(place))

#...

label north:
    scene bg wall1
    show door closed at center
    $rb("east")
    $ui.interact()

label east:
    scene bg wall2
    $ ui.vbox (ypos=300, xpos=100)
    $lb("north")
    $ ui.close()
    $ui.interact()

QotC
Regular
Posts: 54
Joined: Thu Feb 17, 2011 8:53 pm
Contact:

Re: Show Python Function At Right?

#3 Post by QotC »

Thanks, Alex! :)

Post Reply

Who is online

Users browsing this forum: Google [Bot], Sirifys-Al