Say I have a method I use via action Function() in a screen. I want to use the return value that the method returns. How do I get the return value (list of strings) so that I can display them, either in the screen or with a say?
button:
text "Test" size 40
action Function(myObject.method)
I started learning renpy yesterday, so if there are better ways of interacting with buttons and python, please do tell me. I know you can do something like 'action [Function(myObject.method), some other action, some other action], but I haven't fully grasped it.
Thanks!
How to access button action Function()'s return value?
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.
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: How to access button action Function()'s return value?
I also wanted to do it, but couldn't find any way. So I'm using global variables instead of return value. If you change global variables by the Function statement, then it'll update screens immediately.
Re: How to access button action Function()'s return value?
I see. I'm trying out just using menus for what I want to do, although I still do want to find out how to do this. I'll try out globals too! Thanks!
- Pando
- Regular
- Posts: 29
- Joined: Wed Oct 08, 2014 7:57 am
- Projects: Crossfire
- Organization: Agape Studios
- IRC Nick: Pando
- Github: Scylardor
- Contact:
Re: How to access button action Function()'s return value?
FYI, also wanted to do that once. Also ended up using globals.
- nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
- Contact:
Re: How to access button action Function()'s return value?
This seems working, though I think using globals is efficient.
Code: Select all
screen test():
default t="default"
textbutton t action SetScreenVariable("t", test())
init python:
def test():
return "changed"
Re: How to access button action Function()'s return value?
Oh, that's interesting. I'm gonna try that, but you're right about globals. I felt dirty using them at first, but I'm liking them more and more. Thanks!