I found myself stuck when trying to do some coding on imagebuttons and I thought that maybe asking for some help could be right thing to do.
I know that maybe it is something not really complicated but since I am not a programmer, I can't really make it work the way I want it to.
I apologize if what i am asking is a bit too silly but i just don't know what to do! >.<
So I've been working on a Visual Novel and I decided to add a screen where you can choose which chapter to read. What I want to do is that if the player hasn't seen the chapter already, the button that says 'Chapter 2' will be locked. And as soon as they read this particular chapter in the game, and they go back to this screen the button is now sensitive.
I managed to acomplish this somehow but when the button is locked, instead of showing the 'insensitive' image i made, it becomes invisible.
It works perfectly but my problem is that, as I said, i would like it to actually show but you can't click on it until you 'unlock' the chapter.
This is how my screen looks like:
- The button that says 'Chapter 1': Idle image
- The button that says 'Chapter 2': Hover image
- The button that says 'Chapter 3, 4, and so on': Insensitive image
And this is the code I am using for this screen:
[*]Init
Code: Select all
#---check for unlocked chapters---
$ persistent.ch1 = False
$ persistent.ch2 = False
$ persistent.ch3 = False
$ persistent.ch4 = False
$ persistent.ch5 = False
$ persistent.ch6 = False
Code: Select all
#---- Chapter Select screen ----
screen chapters():
tag menu
#tooltip
default ta = Tooltip(None)
default td = Tooltip(None)
default te = Tooltip(None)
default tf = Tooltip(None)
add "ch_bg.png"
#chapters ##BUTTONS DISSAPEAR WHEN CH IS FALSE. I WANT THEM TO SHOW AS INSENSITIVE INSTEAD.
if persistent.ch1:
imagebutton auto "ch1_%s.png" xpos 354 ypos 48 focus_mask None action Start('ch1') hovered ta.Action('ch_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
if persistent.ch2:
imagebutton auto "ch2_%s.png" xpos 354 ypos 158 focus_mask None action Null hovered ta.Action('ch_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
if persistent.ch3:
imagebutton auto "ch3_%s.png" xpos 354 ypos 268 focus_mask None action Null hovered ta.Action('ch_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
if persistent.ch4:
imagebutton auto "ch4_%s.png" xpos 354 ypos 378 focus_mask None action Null hovered ta.Action('ch_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
if persistent.ch5:
imagebutton auto "ch5_%s.png" xpos 354 ypos 488 focus_mask None action Null hovered ta.Action('ch_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
if persistent.ch6:
imagebutton auto "ch6_%s.png" xpos 354 ypos 598 focus_mask None action Null hovered ta.Action('ch_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
#other
imagebutton auto "back_%s.png" xpos 1134 ypos 592 focus_mask None action ShowMenu('menulobby') hovered td.Action('ch_back_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
imagebutton auto "next_%s.png" xpos 1024 ypos 324 focus_mask None action Null hovered te.Action('ch_page_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
imagebutton auto "prev_%s.png" xpos 96 ypos 324 focus_mask None action Null hovered te.Action('ch_page_info.png') activate_sound "select.wav" hover_sound "cursor8.wav"
add ta.value xpos 5 ypos 615
add td.value xpos 5 ypos 615
add te.value xpos 5 ypos 615
add tf.value xpos 5 ypos 615 #show only when ch is not unlocked and 'chapter locked' button is being hovered (ch_unlock_info.png)
Code: Select all
label ch1:
#Unlocks chapter1
$ persistent.ch1 = True
...
Oh! I almost forget! I am using renpy's latest version.
I hope someone can help me :<