textbutton with multiple actions?

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
DrathFox
Regular
Posts: 25
Joined: Tue Sep 06, 2011 12:59 am
Projects: DrathFox Project (fighter/adventure)
Location: Utah, US
Contact:

textbutton with multiple actions?

#1 Post by DrathFox »

Is there a way to create a textbutton to perform 2 or more 'actions' at once? such as playing a sound / music / voice and changing the background or such? If not what kind of 'button' would I need to use? Currently I have something like this but want to add another action.

Code: Select all

textbutton _("Menu Theme") action mr.Play("menu.ogg")

Mild Curry
Regular
Posts: 107
Joined: Fri Jul 02, 2010 3:03 pm
Projects: That's The Way The Cookie Crumbles
Organization: TwinTurtle Games
Contact:

Re: textbutton with multiple actions?

#2 Post by Mild Curry »

Very simple. All buttons accept lists of actions. Looks like this.

Code: Select all

textbutton _("Menu Theme") action [mr.Play("menu.ogg"), SetVariable("background", "trees"), Play("voice", "Bob")]
Just enclose all the actions in brackets and put commas in between them.

Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: textbutton with multiple actions?

#3 Post by Soraminako »

Mild Curry wrote:Very simple. All buttons accept lists of actions. Looks like this.

Code: Select all

textbutton _("Menu Theme") action [mr.Play("menu.ogg"), SetVariable("background", "trees"), Play("voice", "Bob")]
Just enclose all the actions in brackets and put commas in between them.
Thank you! :D *isn't the OP but is also having the same problem*

Just one problem though, when I did that it crashed saying that "'module' object has no attribute 'background'". How do I go about making it understand what to do to background?

We're both using grids, if that helps. :?

I did this, but it didn't work:

Code: Select all

                textbutton _("song") action [mr.Play("song.mp3"), SetVariable("background", "bg01.jpg")]

# So I tried this, after defining the image in an init, but that didn't work either.
                textbutton _("song") action [mr.Play("song.mp3"), SetVariable("background", "bg 01")]
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

DrathFox
Regular
Posts: 25
Joined: Tue Sep 06, 2011 12:59 am
Projects: DrathFox Project (fighter/adventure)
Location: Utah, US
Contact:

Re: textbutton with multiple actions?

#4 Post by DrathFox »

Mild Curry wrote:Just enclose all the actions in brackets and put commas in between them.
Oh thanks! I understand now :D
Last edited by DrathFox on Sun Sep 25, 2011 12:11 am, edited 1 time in total.

Mild Curry
Regular
Posts: 107
Joined: Fri Jul 02, 2010 3:03 pm
Projects: That's The Way The Cookie Crumbles
Organization: TwinTurtle Games
Contact:

Re: textbutton with multiple actions?

#5 Post by Mild Curry »

@DrathFox: No problem. :)


@Soraminako: Haha, "background" is just a variable I made up for illustration. It's not going to work unless you set up something for it.

You'd probably want to make the background a ConditionSwitch or something if you were going to use that.

Soraminako
Veteran
Posts: 277
Joined: Sun Sep 04, 2011 1:36 am
Projects: A thingie without a title. With messy code.
Contact:

Re: textbutton with multiple actions?

#6 Post by Soraminako »

It's moments like those where I am reminded so deeply of the feelings motivating the drawing of my avatar. XD lol
Coding is so very hard! ^^;
(I drew my avatar especially to express the scary feeling I get from the code as I type it... XD)

Post Reply

Who is online

Users browsing this forum: No registered users