Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
-
Michael Regal
- Newbie
- Posts: 11
- Joined: Fri Mar 25, 2022 11:38 pm
-
Contact:
#1
Post
by Michael Regal » Fri Apr 01, 2022 7:25 pm
Please help. This might be a simple solution but I'm having problems. I have this:
which is a function inside a class here:
Code: Select all
def take(self, item, qty=1):
if self.qty(item):
item_location = self.check(item)
self.inv[item_location][1] += qty
else:
self.inv.append([item,qty])
But I want to call it from a textbutton. How do I do this?
Please help!
Last edited by
Michael Regal on Sat Apr 02, 2022 2:06 pm, edited 1 time in total.
-
Michael Regal
- Newbie
- Posts: 11
- Joined: Fri Mar 25, 2022 11:38 pm
-
Contact:
#3
Post
by Michael Regal » Sat Apr 02, 2022 5:51 am
Yes, I know this much. But I don't know the syntax beyond "action Function(args...)"
It's fine though. I've about given up on this

-
Ocelot
- Eileen-Class Veteran
- Posts: 1883
- Joined: Tue Aug 23, 2016 10:35 am
- Github: MiiNiPaa
- Discord: MiiNiPaa#4384
-
Contact:
#4
Post
by Ocelot » Sat Apr 02, 2022 6:43 am
Did you read reference? It explains syntax:
Function(callable, *args, **kwargs)
This Action calls callable with args and kwargs.
callable
Callable object.
That means you place what you call (the thing before brackets) as callable:
Function(player_inv.take ...
args
position arguments to be passed to callable.
Since you are using a single positional argument, you place it here:
Function(player_inv.take, potion)
< < insert Rick Cook quote here > >
-
Michael Regal
- Newbie
- Posts: 11
- Joined: Fri Mar 25, 2022 11:38 pm
-
Contact:
#5
Post
by Michael Regal » Sat Apr 02, 2022 2:06 pm
Ocelot wrote: ↑Sat Apr 02, 2022 6:43 am
Did you read reference? It explains syntax:
Function(callable, *args, **kwargs)
This Action calls callable with args and kwargs.
callable
Callable object.
That means you place what you call (the thing before brackets) as callable:
Function(player_inv.take ...
args
position arguments to be passed to callable.
Since you are using a single positional argument, you place it here:
Function(player_inv.take, potion)
Thank you!