How to use a variable defined in Renpy to Pygame?
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.
How to use a variable defined in Renpy to Pygame?
I have a variable defined at my labels in Renpy and I added a minigame wherein I imported the pygame module. This variable represents something as a guide in my game so that when the pygame is exited, it would go right back to the labels and I would know which label to jump to.
Since I'm fairly new to Renpy language, I was hoping to find some help here. I can't seem to get that variable. Can I somehow pass it from label to pygame or vice versa? I tried using the same variable name however it seems like it created its own variable depending whether you are at the labels or at the pygame.
Any help and suggestions are appreciated!
Since I'm fairly new to Renpy language, I was hoping to find some help here. I can't seem to get that variable. Can I somehow pass it from label to pygame or vice versa? I tried using the same variable name however it seems like it created its own variable depending whether you are at the labels or at the pygame.
Any help and suggestions are appreciated!
Re: How to use a variable defined in Renpy to Pygame?
To make it clearer, I'll give an example:
So I have a variable counter in my labels called "ctr" and it contains a value. From this label, i jump to another label that initiates the pygame. While I am inside pygame, I would like to check the value of the variable ctr and if possible, change it as well if it meets certain conditions.
I somehow can't seem to get variable ctr in pygame, any suggestions?
So I have a variable counter in my labels called "ctr" and it contains a value. From this label, i jump to another label that initiates the pygame. While I am inside pygame, I would like to check the value of the variable ctr and if possible, change it as well if it meets certain conditions.
I somehow can't seem to get variable ctr in pygame, any suggestions?
- PyTom
- Ren'Py Creator
- Posts: 16093
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: How to use a variable defined in Renpy to Pygame?
You can do:
Code: Select all
import renpy.store
def update():
renpy.store.ctr +=1
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: How to use a variable defined in Renpy to Pygame?
it works!!! thanks a lot!!! I finally got it to work ^^
By the way, I have another question: Can you use the renpy.store for calling labels and images from renpy too or is it just used for variables?
By the way, I have another question: Can you use the renpy.store for calling labels and images from renpy too or is it just used for variables?
- PyTom
- Ren'Py Creator
- Posts: 16093
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: How to use a variable defined in Renpy to Pygame?
It's probably a bad idea to do so. Ren'Py runs code - even Python code in an init python block - in very specific ways. You may confuse Ren'Py if you try to call Ren'Py functions from Python code. It's best to just put Python code in init python blocks, perhaps in namespaces.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: How to use a variable defined in Renpy to Pygame?
Ohh.. alright. Thanks for your help~!
Re: How to use a variable defined in Renpy to Pygame?
One last question, let's say you're in pygame then after checking the variable, you would want to jump to a label however you can't do that in python code. What can you suggest to fix this?
- PyTom
- Ren'Py Creator
- Posts: 16093
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: How to use a variable defined in Renpy to Pygame?
You can jump to a label from python code. Do:
This works for many of the renpy.whatever functions in the documentation - they all live in the renpy.exports module.
Code: Select all
import renpy.exports
renpy.exports.jump("labelname")
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Re: How to use a variable defined in Renpy to Pygame?
Ohh, I see thanks a lot for answering my questions!
Re: How to use a variable defined in Renpy to Pygame? [Solve
Sorry for asking again PyTom but I have a question ^^; I've been working on the label to where it will jump from pygame. And now that it's ready to be connected I tried using renpy.exports.jump() but it would just simply do nothing. I can still see the pygame window but nothing happens. I can hear the music playing in the label it should have jumped but the image and dialogues are not there. There are no errors shown so I'm not sure of the problem ><. Any tips?
EDIT: I think I should make a new post for this since this was already solved a few days ago, and my question is different from the title XD
EDIT: I think I should make a new post for this since this was already solved a few days ago, and my question is different from the title XD
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]