[SOLVED]textbutton syntax?

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
UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

[SOLVED]textbutton syntax?

#1 Post by UselessCoder » Thu Jul 28, 2016 6:44 am

I've tried different bracketing for this but I still can't figure out what's wrong... :(

Code: Select all

I'm sorry, but an uncaught exception occurred.

  File "game/screens/my_screens.rpy", line 449, in keywords
    textbutton _("Bad E") action [NullAction(), hovered [Show("tooltip", tooltip=skill_tooltip, my_tt_ypos=693)], unhovered [Hide("tooltip")], SensitiveIf(rank_b==True and not rank_d)]
  File "<screen language>", line 449, in <module>
NameError: name 'hovered' is not defined

Last edited by UselessCoder on Thu Jul 28, 2016 12:01 pm, edited 1 time in total.

User avatar
andrewngn13
Regular
Posts: 65
Joined: Thu Nov 13, 2014 2:41 pm
Projects: Recast
Skype: andrewngn13
Location: Glued to my desktop
Contact:

Re: textbutton syntax?

#2 Post by andrewngn13 » Thu Jul 28, 2016 7:38 am

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/screens.rpy", line 177, in execute
    screen main_menu():
  File "game/screens.rpy", line 177, in execute
    screen main_menu():
  File "game/screens.rpy", line 187, in execute
    frame:
  File "game/screens.rpy", line 192, in execute
    has vbox
  File "game/screens.rpy", line 199, in execute
    textbutton _("Bad E") action NullAction() hovered Show("navigation") unhovered [Hide("tooltip"), SensitiveIf(rank_b==True and not rank_d)]
  File "game/screens.rpy", line 199, in keywords
    textbutton _("Bad E") action NullAction() hovered Show("navigation") unhovered [Hide("tooltip"), SensitiveIf(rank_b==True and not rank_d)]
NameError: name 'rank_b' is not defined
I did some syntax editing and messed with Show to get it into some manner of progress. Unfortunately my random piecing of coding knowledge ends here.
*I didn't look at sensitiveif in the renpy documentation, but removing it compiles the statement.

Anyhow, I don't have the same things as you defined, so this is my best final answer at the moment.

Code: Select all

        textbutton _("Bad E"): 
            action NullAction() 
            hovered [Show("tooltip", tooltip=skill_tooltip, my_tt_ypos=693)]
            unhovered [Hide("tooltip")], SensitiveIf(rank_b==True and not rank_d)]
"Feel feel to idea-bounce off me."
No, like seriously, just send a pm and I'll respond what I think. I'm open to reading anything.

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: textbutton syntax?

#3 Post by UselessCoder » Thu Jul 28, 2016 8:41 am

andrewngn13 wrote:

Code: Select all

        textbutton _("Bad E"): 
            action NullAction() 
            hovered [Show("tooltip", tooltip=skill_tooltip, my_tt_ypos=693)]
            unhovered [Hide("tooltip")], SensitiveIf(rank_b==True and not rank_d)]
thanks andrew, but that didn't work either...there was an extra "]" at the end of your code, anyway...however, the error I get now is "SensitiveIf" is not a valid textbutton argument.
But like I said, thanks for trying ;)

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: textbutton syntax?

#4 Post by UselessCoder » Thu Jul 28, 2016 9:27 am

I've finally found a working fix:

Code: Select all

action[ SensitiveIf(rank_b==True and not rank_d)] hovered [Show ("tooltip", tooltip=skill_tooltip, my_tt_ypos=693)]unhovered [Hide("tooltip")]

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: textbutton syntax?

#5 Post by xavimat » Thu Jul 28, 2016 11:43 am

The [ ] are only needed to make lists of actions.
In your former examples, there are errors because there are brakets not closed or not opened or closed twice.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: textbutton syntax?

#6 Post by UselessCoder » Thu Jul 28, 2016 12:00 pm

xavimat wrote:The [ ] are only needed to make lists of actions.
In your former examples, there are errors because there are brakets not closed or not opened or closed twice.
Yes xavimat, thanks...I've found out myself by making mistakes over mistakes. The thing is I was considering "hovered" and "unhovered" as "stand-alone" actions, while they are to be considered as parts of an action...Thanks for taking your time to answer this, tho.

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: textbutton syntax?

#7 Post by xavimat » Thu Jul 28, 2016 12:15 pm

UselessCoder wrote:The thing is I was considering "hovered" and "unhovered" as "stand-alone" actions, while they are to be considered as parts of an action...Thanks for taking your time to answer this, tho.
No, no. You were right.
  • "action" is triggered when the button (or textbutton/imagebutton/hotspot) is clicked (or touched in a touch screen, etc.)
  • "hovered" is triggered when the button gains focus (hovered with the mouse, touched in a touch-screen...).
  • "unhovered" is triggered when the button loses focus.
  • "alternate" is triggered whith the "alternate click" (secondary button of the mouse, long touch in touch-screen...)
All four are independent and can have one action or a list of actions (using [ ] ).

Doc: https://www.renpy.org/doc/html/screens.html#button
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: [SOLVED]textbutton syntax?

#8 Post by UselessCoder » Thu Jul 28, 2016 12:30 pm

Ok, so...I'm totally clueless about how on earth that last attempt worked. lol
Seriously, especially in regard of "action[SensitiveIf"...I mean, how can a button sensitive/non-sensitive status be considered an "action"? :? (but still...somehow it worked.. :? )

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: [SOLVED]textbutton syntax?

#9 Post by xavimat » Thu Jul 28, 2016 5:01 pm

Well, you are right again.
I said that the four "triggers" are independent, but with an exception: if action is None (or not defined), then the others (hovered, unhovered and alternate) can't work, because the button is insensitive. This is the reason why the empty NullAction() exists (to have a button that does nothing on click but is able to trigger the others).
In your example you have used SensitiveIf that is originally intended to work in a list with other actions https://www.renpy.org/doc/html/screen_a ... ensitiveIf , you don't have other actions in that list but there are other actions in other "triggers", and SensitiveIf does its work.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

UselessCoder
Regular
Posts: 96
Joined: Sun Jan 24, 2016 6:51 am
Projects: undisclosed...
Contact:

Re: [SOLVED]textbutton syntax?

#10 Post by UselessCoder » Thu Jul 28, 2016 5:27 pm

xavimat wrote:Well, you are right again.
I said that the four "triggers" are independent, but with an exception: if action is None (or not defined), then the others (hovered, unhovered and alternate) can't work, because the button is insensitive. This is the reason why the empty NullAction() exists (to have a button that does nothing on click but is able to trigger the others).
In your example you have used SensitiveIf that is originally intended to work in a list with other actions https://www.renpy.org/doc/html/screen_a ... ensitiveIf , you don't have other actions in that list but there are other actions in other "triggers", and SensitiveIf does its work.
Now this makes a lot of sense! Thanks for this explanation Xavi. tbh I've red the docs you've linked before opening the topic, but I didn't get much of it before you took your time to explain in depth. Docs can be helpful, but are probably written for those who know python syntax basics already...Definitely not my case. :oops:

Thanks again! :)

Post Reply

Who is online

Users browsing this forum: No registered users