Hello everyone. I have one little question....
I want to make simple screen with 7 Lamps.... When you click on lamp 1 lamp 1 start shine.... but only when you have light bulbs in your possesion.... then when you click on lampt 3 lamp 3 will shine if you have bulb and lamp 1 still shine if you dont turn it off before...
What is the best way to make that screen???
Thanks
Screen with on off buttons
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.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3791
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Screen with on off buttons
Some simple conditionals and the very basic python is all you need.
Start by building a screen. I will assume you want it to take up the whole game screen. I also assume your game is 1280x720.
For simplicity, I will use a vpgrid.
Add your lamps and include a python variable.
Be aware that whilst using a vpgrid, all elements inside it are pre-sized to the first object. If you want to add other stuff, consider a vbox or some other screen element.
Start by building a screen. I will assume you want it to take up the whole game screen. I also assume your game is 1280x720.
For simplicity, I will use a vpgrid.
Code: Select all
screen lamps():
tag menu
style_prefix "lamps_menu"
add "my background.png"
vpgrid:
xmaximum 700
xfill True
xpos 0
ypos 0
cols 1
spacing 20
draggable False
Code: Select all
if lamp == 0:
add imagebutton idle "lamp_off.png" hover "lamp_off.png" focus_mask True action SetVariable(lamp, 1)
else:
add magebutton idle "lamp_on.png" hover "lamp_on.png" focus_mask True action SetVariable(lamp, 0)
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Re: Screen with on off buttons
Thank you very much.. but what if i need only that imagebutton - lamp png is same size as screen but only lamp is on specific place with 'blank' background
Re: Screen with on off buttons
affter some tries it still give me same result:
is there any possibiltieis with imagebuttons or imagemap?
Code: Select all
I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.
File "game/script.rpy", line 39: end of line expected.
add imagebutton idle "Jessie.png" hover "Jessie.png" focus_mask True action SetVariable(lamp, 1)
^
File "game/script.rpy", line 41: end of line expected.
add magebutton idle "Jessie.png" hover "Jessie.png" focus_mask True action SetVariable(lamp, 0)
^
Ren'Py Version: Ren'Py 6.99.12.4.2187
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3791
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Screen with on off buttons
I forgot about the requirement to have a bulb in your posession.
I also made a typo.
I left out the i in "imagebutton"
If you want the image as part of the game background, it might be better to use an imagemap, but can be done with either.
I'm afraid I have never tried to do this yet so can't offer further help. Everything I posted so far is just based on past experience with programming and what I could learn by reading the documentation.
I also made a typo.
Code: Select all
else:
add imagebutton idle "lamp_on.png" hover "lamp_on.png" focus_mask True action SetVariable(lamp, 0)
If you want the image as part of the game background, it might be better to use an imagemap, but can be done with either.
I'm afraid I have never tried to do this yet so can't offer further help. Everything I posted so far is just based on past experience with programming and what I could learn by reading the documentation.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Who is online
Users browsing this forum: Google [Bot]