[SOLVED] What does "call ... from ..." do?
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.
-
felsenstern
- Regular
- Posts: 62
- Joined: Tue Jul 11, 2017 2:13 am
- Contact:
[SOLVED] What does "call ... from ..." do?
Hiya,
can someone explain me what the following line does?
call visitor from _call_visitor
(This comes from code that was generated by a rpg-maker to renpy converter. I found the label inside a file named custom_menus.rpy. But what I don't understand is everything that starts with the "... from ..." part and why the generator created that part, since it doesn't look like RenPy needs it because when I remove it, the game works just as fine.)
can someone explain me what the following line does?
call visitor from _call_visitor
(This comes from code that was generated by a rpg-maker to renpy converter. I found the label inside a file named custom_menus.rpy. But what I don't understand is everything that starts with the "... from ..." part and why the generator created that part, since it doesn't look like RenPy needs it because when I remove it, the game works just as fine.)
Last edited by felsenstern on Sun Jan 03, 2021 4:53 pm, edited 1 time in total.
---
Yes, I've Read The F*cking Manual
Yes, I've used the f*cking search function
Yes, I've used a site search
No, I don't need a reminder that search functions exist
No, I don't need your astonished outbreak that I couldn't find the information
No, I don't need your answer if you can't just give it without all the BS around it
Yes, I've Read The F*cking Manual
Yes, I've used the f*cking search function
Yes, I've used a site search
No, I don't need a reminder that search functions exist
No, I don't need your astonished outbreak that I couldn't find the information
No, I don't need your answer if you can't just give it without all the BS around it
Re: What does "call ... from ..." do?
It sets a label that is used as a return point for loading saved games. This is used to retain compatibility with saved games from a different version of the same script.
-
felsenstern
- Regular
- Posts: 62
- Joined: Tue Jul 11, 2017 2:13 am
- Contact:
Re: What does "call ... from ..." do?
Now I am completely confused. My labels change when I make different versions of the same script? Is RenPy doing this? Let's say when I have a label like:
label wolf_event:
how would the call look like to stay compatible no matter what version of the script I use?
label wolf_event:
how would the call look like to stay compatible no matter what version of the script I use?
---
Yes, I've Read The F*cking Manual
Yes, I've used the f*cking search function
Yes, I've used a site search
No, I don't need a reminder that search functions exist
No, I don't need your astonished outbreak that I couldn't find the information
No, I don't need your answer if you can't just give it without all the BS around it
Yes, I've Read The F*cking Manual
Yes, I've used the f*cking search function
Yes, I've used a site search
No, I don't need a reminder that search functions exist
No, I don't need your astonished outbreak that I couldn't find the information
No, I don't need your answer if you can't just give it without all the BS around it
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3636
- Joined: Mon Dec 14, 2015 5:05 am
- Location: Your monitor
- Contact:
Re: What does "call ... from ..." do?
Your label names shouldnt change, but renpy regularly adds "from <label>" to your calls when compiling rpyc files. It is intended behaviour and call label is just shorthand for the same thing.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Free Android GUI - Updated occasionally
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Re: What does "call ... from ..." do?
Whenever you call (not jump to) a label, the the return address is pushed on the stack. When a return statement is encountered, it then pops the address off the stack to know where to go to. This works the same as a function in any programming language really.felsenstern wrote: ↑Sun Jan 03, 2021 3:27 amNow I am completely confused. My labels change when I make different versions of the same script? Is RenPy doing this? Let's say when I have a label like:
label wolf_event:
how would the call look like to stay compatible no matter what version of the script I use?
But a problem arises, when saving between a call and a return. In a later version, the return address might be different (you can think of it as simply the line number where the call is made). So, if you then have multiple calls to the same function, renpy doesn't know where to return to. The from clause simply adds a label, so Renpy always knows where to return. So, in this case:
Code: Select all
main_function:
call some_function_where_the_user_might_save()
"Looks like you're still playing..."
call some_function_where_the_user_might_save()Code: Select all
main_function:
call some_function_where_the_user_might_save() from pointA
"Looks like you're still playing..."
call some_function_where_the_user_might_save() from pointB-
felsenstern
- Regular
- Posts: 62
- Joined: Tue Jul 11, 2017 2:13 am
- Contact:
Re: What does "call ... from ..." do?
Thanks a lot Imperf3kt and emanuel for the answers so far. Let me put all your answers together and let me know if I am wrong please!
...from <name>
1. serves as a label for the call when it reaches return.
2. this is done internally, using a stack
3. it can be given by the coder.
4. if not pre-defined, RenPy generates this label when it compiles the program.
so all in all, it's a nice to have when it's given but not necessary at all.
...from <name>
1. serves as a label for the call when it reaches return.
2. this is done internally, using a stack
3. it can be given by the coder.
4. if not pre-defined, RenPy generates this label when it compiles the program.
so all in all, it's a nice to have when it's given but not necessary at all.
---
Yes, I've Read The F*cking Manual
Yes, I've used the f*cking search function
Yes, I've used a site search
No, I don't need a reminder that search functions exist
No, I don't need your astonished outbreak that I couldn't find the information
No, I don't need your answer if you can't just give it without all the BS around it
Yes, I've Read The F*cking Manual
Yes, I've used the f*cking search function
Yes, I've used a site search
No, I don't need a reminder that search functions exist
No, I don't need your astonished outbreak that I couldn't find the information
No, I don't need your answer if you can't just give it without all the BS around it
Re: What does "call ... from ..." do?
Renpy will generate labels, but there is no guarantee that the labels will get the same generated names in future versions of the same script. In fact, Renpy simply numbers the labels. Thus, if you add a call in a later version, the generated labels will be different. You need to define them manually to be sure that the game returns to the point where you intend it to return to. If you want players of older versions to be able to load their savegames in newer versions that is. Otherwise, you can forget about it.felsenstern wrote: ↑Sun Jan 03, 2021 4:04 pmThanks a lot Imperf3kt and emanuel for the answers so far. Let me put all your answers together and let me know if I am wrong please!
...from <name>
1. serves as a label for the call when it reaches return.
2. this is done internally, using a stack
3. it can be given by the coder.
4. if not pre-defined, RenPy generates this label when it compiles the program.
so all in all, it's a nice to have when it's given but not necessary at all.
-
felsenstern
- Regular
- Posts: 62
- Joined: Tue Jul 11, 2017 2:13 am
- Contact:
Re: What does "call ... from ..." do?
Thanks a lot!
---
Yes, I've Read The F*cking Manual
Yes, I've used the f*cking search function
Yes, I've used a site search
No, I don't need a reminder that search functions exist
No, I don't need your astonished outbreak that I couldn't find the information
No, I don't need your answer if you can't just give it without all the BS around it
Yes, I've Read The F*cking Manual
Yes, I've used the f*cking search function
Yes, I've used a site search
No, I don't need a reminder that search functions exist
No, I don't need your astonished outbreak that I couldn't find the information
No, I don't need your answer if you can't just give it without all the BS around it
Who is online
Users browsing this forum: Bing [Bot]