Hi, I would like to ask how to fill a newly created variable with current value of existing one.
What I am trying to achieve: I want to record an exact day (in-game one) when a player returned a book and fill a new variable with that value. I am counting them as simple numbers. No week system involved. So the next event will be available in a few days automatically.
I tried to write it in code, googled it but didn´t figure out what to do. Thanks to anyone who can help me.
QueenBee
[Solved] Fill variable with value of another variable
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.
- QueenBee
- Newbie
- Posts: 6
- Joined: Mon Jul 26, 2021 10:08 am
- Projects: Sweet Sweet Adventure
- Organization: Honey Beer Games
- Deviantart: honeybeergames
- Discord: QueenBee#2285
- Contact:
[Solved] Fill variable with value of another variable
Last edited by QueenBee on Mon Dec 06, 2021 7:08 pm, edited 1 time in total.
Creating a fantasy sandbox adult game: Game Overview.
- Ocelot
- Lemma-Class Veteran
- Posts: 2402
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
- Contact:
Re: Fill variable with value of another variable
Assuming current_day is a simple number:
Code: Select all
$ book_returned = current_day
< < insert Rick Cook quote here > >
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Fill variable with value of another variable
day_book_returned = current_day
You might want to default it as zero though, then just adjust it to match current day when the book return event occurs.
You might want to default it as zero though, then just adjust it to match current day when the book return event occurs.
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
Re: Fill variable with value of another variable
I hesitate to throw this in and muddy the waters since it sounds like you're very new to programming, but we ought to at least mention that there is kind of a trap lying just next door to the question you asked. It's a Python trap, nothing specifically to do with Ren'py.
The key is, Ocelot's comment about "assuming it's a simple number" is *extremely important*. If your variables are all just numbers, booleans (True/False) or strings, that's all you need to know. But if you are trying to save a copy of a *list*, *dictionary*, or *object* (instance of a Class), you need to learn the difference between "copy by value" and "copy by reference". Here's an introduction for newbies: https://www.afternerd.com/blog/python-copy-list/
The key is, Ocelot's comment about "assuming it's a simple number" is *extremely important*. If your variables are all just numbers, booleans (True/False) or strings, that's all you need to know. But if you are trying to save a copy of a *list*, *dictionary*, or *object* (instance of a Class), you need to learn the difference between "copy by value" and "copy by reference". Here's an introduction for newbies: https://www.afternerd.com/blog/python-copy-list/
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
- QueenBee
- Newbie
- Posts: 6
- Joined: Mon Jul 26, 2021 10:08 am
- Projects: Sweet Sweet Adventure
- Organization: Honey Beer Games
- Deviantart: honeybeergames
- Discord: QueenBee#2285
- Contact:
Re: Fill variable with value of another variable
Thank you all for help and kind responses. I solved it. I think that I was trying to use $ also after = assuming that othervise it will just be set to text "day'.
I will definitely read "copy by value" and "copy by reference", didn't know that there is some difference.
I will definitely read "copy by value" and "copy by reference", didn't know that there is some difference.
Creating a fantasy sandbox adult game: Game Overview.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot]