How to set multiple variables with text button?

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
User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

How to set multiple variables with text button?

#1 Post by Luxliev »

Can you make textbutton set multiple variables? Example in python:

Code: Select all

def func(a, b):
    a += 3
    b += 4
    return a, b

z = 1
x = 2
z, x = func(z, x)
I can't use action SetVariable(), SetVariable() because I use function first and then when I try to SetVariables after that I have this annoying issue that button always lags one click behind (and it flashes white)

Code: Select all

textbutton "EQUIP":
        action Function(ui_inv_equip, swap_item, compared_item), SetVariable('swap_item', None), SetVariable('compared_item_item', None), 
Attachments
2017-07-30.png
2017-07-30.png (1022 Bytes) Viewed 2040 times
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: How to set multiple variables with text button?

#2 Post by Remix »

Can you not recode ui_inv_equip to set the variables itself and just do the one function action?
Alternatively, maybe a utility function that calls ui_inv_equip then sets both variables...
Frameworks & Scriptlets:

User avatar
Luxliev
Veteran
Posts: 242
Joined: Sat Feb 07, 2015 11:01 am
Soundcloud: Luxliev
Contact:

Re: How to set multiple variables with text button?

#3 Post by Luxliev »

I found that using Jump gives you opportunity to do pretty much whatever you want but won't this create any problems? Example:

Code: Select all

imagebutton auto equipment.imgd.inventory:
    action SetVariable('swap_item', equipment), Jump('background')

label background:
    $ citem, ditem = set_ci(citem, ditem)
    $ renpy.pause()
    jump background
Newest classical cover: Advance Wars - Sami Theme: https://www.youtube.com/watch?v=657Jt7hJRVc

Forum with my music: http://luxliev.proboards.com/

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot]