Page 1 of 1

Button actions

Posted: Sun May 17, 2020 12:20 pm
by iDweadith
Hi I'm a bit confused

Is the screen action the right way to make a button doing something on click?

I mean, I'm using an imagebutton so when I click on it I want a text to appear, do I have to call a screen with the text in it?

Re: Button actions

Posted: Sun May 17, 2020 12:52 pm
by isobellesophia
iDweadith wrote:
Sun May 17, 2020 12:20 pm
Hi I'm a bit confused

Is the screen action the right way to make a button doing something on click?

I mean, I'm using an imagebutton so when I click on it I want a text to appear, do I have to call a screen with the text in it?

Code: Select all

screen menu():
text "Hello world!"

Code: Select all

label start:
show screen menu

Re: Button actions

Posted: Mon May 18, 2020 5:43 am
by iDweadith
I mean in order to make an imagebutton works is that below the right way?

Code: Select all


imagebutton: 
	action: Jump("text")

screen text():
text "Hello world!"

Also I'm not understanding the difference between Call and Jump

Re: Button actions

Posted: Mon May 18, 2020 5:56 am
by isobellesophia
Jump is for labels, call screen is used for calling screen before you continue to the novel.

https://www.renpy.org/doc/html/label.ht ... -statement
https://www.renpy.org/doc/html/label.ht ... -statement

Code: Select all

screen textx():
   imagebutton auto "button_&s.png" action Show("text") xpos 600
   
screen text:
   text "Hello world"

Code: Select all

label start:
    show screen textx

Re: Button actions

Posted: Mon May 18, 2020 6:55 am
by Alex
iDweadith wrote:
Sun May 17, 2020 12:20 pm
Hi I'm a bit confused

Is the screen action the right way to make a button doing something on click?

I mean, I'm using an imagebutton so when I click on it I want a text to appear, do I have to call a screen with the text in it?
That depends of what you trying to achieve.
This might be

Code: Select all

screen button_scr():
    imagebutton:
        align (0.3, 0.5)
        idle "idle_img.png"
        hover "hover_img.png"
        action ToggleScreen("my_scr")

    imagebutton:
        align (0.7, 0.5)
        idle "another_idle_img.png"
        hover "another_hover_img.png"
        action Show("another_scr")

screen my_scr():
    text "Hello world!" align (0.5, 0.1)

screen another_scr():
    timer 1.0 action Hide("another_scr")
    text "Hello world!" align (0.5, 0.15)

label start:
    "..."
    show screen button_scr
    "... ..."
    "?!"
https://www.renpy.org/doc/html/screen_actions.html#Show
https://www.renpy.org/doc/html/screen_a ... ggleScreen
https://www.renpy.org/doc/html/screen_actions.html#Hide
https://www.renpy.org/doc/html/screens.html#timer

Re: Button actions

Posted: Mon May 18, 2020 9:07 am
by iDweadith
Thank you guys! So can I do something like below?

Code: Select all

screen button_1():
    imagebutton:
        action Jump("hello_world")
       
label start:
    show screen button_1
    
label hello_world:
	"Hello World"

So in my code I made a little inventory every item is an imagemap, I want that when I click on an item it gives for example +1 in thirsty

Re: Button actions

Posted: Mon May 18, 2020 9:32 am
by Alex
iDweadith wrote:
Mon May 18, 2020 9:07 am
... So can I do something like below?...
While you can, take in mind that showing screen won't stop Ren'Py from executing your code farther. So, the exact code you've posted will show your button screen and immediately run the 'hello_world' label (the next line of code).

Check this thread - viewtopic.php?f=51&t=39572#p422964