my screen has 3 imagebuttons, 2 of them can be activated only once and they will send the player to a specific label, after the label has ended the screen is shown again but the button pressed for that label needs to be deactivated, or better, it has to send a text message, while the third one needs to be always active. How do I do this? Thanks in advance
Setting up a variable for a single Imagebutton
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.
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.
-
Seekeroflight
- Newbie
- Posts: 3
- Joined: Tue Oct 29, 2019 5:26 pm
- Contact:
Setting up a variable for a single Imagebutton
Hi, I'm new to Ren'Py and I'm trying with no success to disable an imagebutton after it did it's thing.
my screen has 3 imagebuttons, 2 of them can be activated only once and they will send the player to a specific label, after the label has ended the screen is shown again but the button pressed for that label needs to be deactivated, or better, it has to send a text message, while the third one needs to be always active. How do I do this? Thanks in advance
my screen has 3 imagebuttons, 2 of them can be activated only once and they will send the player to a specific label, after the label has ended the screen is shown again but the button pressed for that label needs to be deactivated, or better, it has to send a text message, while the third one needs to be always active. How do I do this? Thanks in advance
-
rayminator
- Miko-Class Veteran
- Posts: 754
- Joined: Fri Feb 09, 2018 12:05 am
- Location: Canada
- Contact:
Re: Setting up a variable for a single Imagebutton
here is a example
Code: Select all
define mapdoctor = False
or
default mapdoctor = False
imagebutton idle im.Scale("images/doctor.jpg", 550, 250) hover im.Scale("images/doctor2.jpg", 550, 250) action [ Start("doctor"), SetVariable("mapdoctor", True) ]-
Seekeroflight
- Newbie
- Posts: 3
- Joined: Tue Oct 29, 2019 5:26 pm
- Contact:
Re: Setting up a variable for a single Imagebutton
I did try that way before
The code now looks like this
I also tried to define the variable and the button it's still active
The code now looks like this
Code: Select all
screen expNightKitchen():
add "exploration/nightad.jpg"
default kfirst = False
imagebutton:
idle "sprites/kitchen/kkarsprite.png"
hover "sprites/kitchen/kkarhover.png" focus_mask True
action [Jump("karaftdin"), SetVariable("kfirst", True)]
imagebutton:
idle "sprites/kitchen/knatsprite.png"
hover "sprites/kitchen/knathover.png" focus_mask True
action Jump("nataftdin")
imagebutton:
idle "sprites/kitchen/downkexit.png"
hover "sprites/kitchen/downkexithover.png" focus_mask True
action Show("expNightMainCorridor"), Hide("expNightKitchen")- deltadidirac
- Regular
- Posts: 123
- Joined: Fri Nov 30, 2018 5:00 am
- Projects: Artworks and Comics
- Tumblr: deltadidirac
- Deviantart: Deltadidirac67
- Location: Europe
- Contact:
Re: Setting up a variable for a single Imagebutton
I try an example:
before define your variable:
build your screen:
build the popup screen:
build your label:
perhaps all this could give you some ideas
before define your variable:
Code: Select all
default buttonvalue = 0Code: Select all
screen your_screen:
add "your image bg"
if buttonvalue ==0:
imagebutton:
idle "button1-idle"
hover "button1-hover"
action [Hide ("your_screen"), Jump ("your_label")]
xpos xxx
ypos xxx
imagebutton:
idle "button2-idle"
hover "button2-hover"
action [Hide ("your_screen"), Jump ("your_label")]
xpos yyy
ypos xxx
imagebutton:
idle "button3-idle"
hover "button3-hover"
action [Hide ("your_screen"), Jump ("your_label")]
xpos yyy
ypos xxx
elif buttonvalue ==1:
imagebutton:
idle "button1-idle"
hover "button1-idle"
action [Show ("popup")]
xpos zzz
ypos xxx
imagebutton:
idle "button2-idle"
hover "button2-hover"
action [Hide ("your_screen"), Jump ("your_label")]
xpos yyy
ypos xxx
imagebutton:
idle "button3-idle"
hover "button3-hover"
action [Hide ("your_screen"), Jump ("your_label")]
xpos yyy
ypos xxx
else:
imagebutton:
idle "button1-idle"
hover "button1-idle"
action [Show ("popup")]
xpos zzz
ypos xxx
imagebutton:
idle "button2-idle"
hover "button2-hover"
action [Show ("popup")]
xpos yyy
ypos xxx
imagebutton:
idle "button3-idle"
hover "button3-hover"
action [Hide ("your_screen"), Jump ("your_label")]
xpos yyy
ypos xxxCode: Select all
screen your_popup:
vbox:
xpos xxx ypos xxx
textbutton "here write your warning text about your buttons" action Hide ("popup")build your label:
Code: Select all
label your_label:
if buttovalue ==0:
scene your_bg
".........."
$ buttonvalue +=1
show screen your_screen
elif buttonvalue ==1:
scene your_bg
"..... ------- "
$ buttonvalue +=1
show screen your_screen
else:
scene your bg2
"........"
show screen your_screen
show screen your_screen-
Seekeroflight
- Newbie
- Posts: 3
- Joined: Tue Oct 29, 2019 5:26 pm
- Contact:
Re: Setting up a variable for a single Imagebutton
Ok I finally managed.
The screen.
And 2 separate labels.
That way the player can decide which one to execute first.
Thanks all for the help
Code: Select all
default buttonv = 0
default buttonb = FalseCode: Select all
screen myscreen():
add "image.jpg"
if buttonv ==0:
imagebutton:
idle "picture1.png"
hover "picture1hover.png" focus_mask True
action Jump("label1")
imagebutton:
idle "picture2.png"
hover "picture2hover.png" focus_mask True
action Jump("label2")
imagebutton:
idle "leave.png"
hover "leavehover.png" focus_mask True
action Show("screen2"), Hide("myscreen")
if buttonv ==1 and buttonb == False:
imagebutton:
idle "picture1.png"
hover "picture1hover.png" focus_mask True
imagebutton:
idle "picture2.png"
hover "picture2hover.png" focus_mask True
action Jump("label2")
imagebutton:
idle "leave.png"
hover "leavehover.png" focus_mask True
action Show("screen2"), Hide("myscreen")
elif buttonv ==1 and buttonb == True:
imagebutton:
idle "picture1.png"
hover "picture1hover.png" focus_mask True
action Jump("label1")
imagebutton:
idle "picture2.png"
hover "picture2hover.png" focus_mask True
imagebutton:
idle "leave.png"
hover "leavehover.png" focus_mask True
action Show("screen2"), Hide("myscreen")
else:
imagebutton:
idle "picture1.png"
hover "picture1hover.png" focus_mask True
imagebutton:
idle "picture2.png"
hover "picture2hover.png" focus_mask True
imagebutton:
idle "leave.png"
hover "leavehover.png" focus_mask True
action Show("screen2"), Hide("myscreen")Code: Select all
label label1:
"....text...."
window hide
$ buttonv += 1
call screen myscreen
$ renpy.pause(hard=True)
label label2:
"....text...."
window hide
$ buttonv += 1
$ buttonb = True
call screen myscreen
$ renpy.pause(hard=True)Thanks all for the help
Who is online
Users browsing this forum: Ocelot