renpy.restart_interaction AFTER a Return?
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.
- lking22
- Regular
- Posts: 50
- Joined: Sun Dec 03, 2017 3:33 am
- Projects: Grey Feather
- itch: freefall-games
- Contact:
renpy.restart_interaction AFTER a Return?
I have an inventory screen where a player can select an item, and that item is then 'in use'. I would like to have it so that new options show up in the choice screen when certain items are in use, which is working... mostly. It detects the in use item, but only if I use it at least one interaction before the choice screen. I'd like to be able to refresh the choice screen when exiting the inventory menu so that the new choice shows up even if the item wasn't in use before that screen.
So far it looks like 'renpy.restart_interaction' is my best bet, but I can't figure out how to get it to run when selecting and item, AFTER returning to the game. Putting it before just locks up the whole game whenever I entire the inventory screen.
Sorry about the lack of details on this one, it's sort of doing my head in and I don't even know where to start looking right now, or if I'm even on the right track with the functions I need to use.
So far it looks like 'renpy.restart_interaction' is my best bet, but I can't figure out how to get it to run when selecting and item, AFTER returning to the game. Putting it before just locks up the whole game whenever I entire the inventory screen.
Sorry about the lack of details on this one, it's sort of doing my head in and I don't even know where to start looking right now, or if I'm even on the right track with the functions I need to use.
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3795
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: renpy.restart_interaction AFTER a Return?
Have you tried setting the selected item to the _return variable via using Return(item or string) as an action
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- lking22
- Regular
- Posts: 50
- Joined: Sun Dec 03, 2017 3:33 am
- Projects: Grey Feather
- itch: freefall-games
- Contact:
Re: renpy.restart_interaction AFTER a Return?
Sorry, I might just be being dumb (or sleep-deprived) but I don't really know what that means?
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3795
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: renpy.restart_interaction AFTER a Return?
I'm assuming this is some kind of inventory, right?
How are you currently working out which item is selected?
I was suggesting you make use of the return function as documented here.
https://www.renpy.org/doc/html/screen_a ... tml#Return
How are you currently working out which item is selected?
I was suggesting you make use of the return function as documented here.
https://www.renpy.org/doc/html/screen_a ... tml#Return
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- lking22
- Regular
- Posts: 50
- Joined: Sun Dec 03, 2017 3:33 am
- Projects: Grey Feather
- itch: freefall-games
- Contact:
Re: renpy.restart_interaction AFTER a Return?
Yeah, it's an inventory screen. Right now it's like this:
The variable 'item' indicates which item is in use. The choice menu is really basic:
It works, but only if the item is selected before the choice menu is shown. I would really like for the player to be able to pause, select an item, and then have the new option show up when they unpause.
Code: Select all
init -1 python:
import renpy.store as store
import renpy.exports as renpy # we need this so Ren'Py properly handles rollback with classes
from operator import attrgetter # we need this for sorting items
inv_page = 0 # initial page of teh inventory screen
item = None
class Player(renpy.store.object):
def __init__(self, name, max_hp=0, max_mp=0, element=None):
self.name=name
self.max_hp=max_hp
self.hp=max_hp
self.max_mp=max_mp
self.mp=max_mp
self.element=element
player = Player("Derp", 100, 50)
class Item(store.object):
def __init__(self, name, player=None, hp=0, mp=0, element="", image="", cost=0):
self.name = name
self.player=player # which character can use this item?
self.hp = hp # does this item restore hp?
self.mp = mp # does this item restore mp?
self.element=element # does this item change elemental damage?
self.image=image # image file to use for this item
self.cost=cost # how much does it cost in shops?
class Inventory(store.object):
def __init__(self, money=10):
self.money = money
self.items = []
def add(self, item): # a simple method that adds an item; we could also add conditions here (like check if there is space in the inventory)
self.items.append(item)
def drop(self, item):
self.items.remove(item)
def buy(self, item):
if self.money >= item.cost:
self.items.append(item)
self.money -= item.cost
showitems = True
screen inventory:
tag menu
use game_menu(_("Inventory"), scroll="viewport"):
style_prefix "inventory"
$ i = 0
$ sorted_items = sorted(inventory.items, key=attrgetter('element'), reverse=True)
vpgrid:
cols 3
spacing gui.slot_spacing
side_xalign 0.5
for item in sorted_items:
$ pic = item.image
imagebutton idle pic action [SetVariable("item", item), Return()]
Code: Select all
menu:
"Yes":
$ persistent.tw = True
"No":
$ persistent.tw = False
"A third option" if item == Storybook:
pass
Re: renpy.restart_interaction AFTER a Return?
Tried this with no avail?
imagebutton idle pic action [SetVariable("item", item), renpy.restart_interaction, Return()]
imagebutton idle pic action [SetVariable("item", item), renpy.restart_interaction, Return()]
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.
10 ? "RENPY"
20 GOTO 10
RUN
10 ? "RENPY"
20 GOTO 10
RUN
- lking22
- Regular
- Posts: 50
- Joined: Sun Dec 03, 2017 3:33 am
- Projects: Grey Feather
- itch: freefall-games
- Contact:
Re: renpy.restart_interaction AFTER a Return?
No, it doesn't seem to have any effect.
Re: renpy.restart_interaction AFTER a Return?
Try to name your in-game menu, store its name in variable, jump to this menu if your inventory screen was opened while in menu.
viewtopic.php?f=8&t=57948&p=524422#p524422
https://www.renpy.org/doc/html/menus.html
viewtopic.php?f=8&t=57948&p=524422#p524422
https://www.renpy.org/doc/html/menus.html
- lking22
- Regular
- Posts: 50
- Joined: Sun Dec 03, 2017 3:33 am
- Projects: Grey Feather
- itch: freefall-games
- Contact:
Re: renpy.restart_interaction AFTER a Return?
Using Jump looks like it works at first, but turns out it's still in the 'pause screen' for lack of a better word. If I hit esc while in the 'updated' menu it goes right back to the old version without the updated options.Alex wrote: ↑Wed Feb 19, 2020 2:59 pm Try to name your in-game menu, store its name in variable, jump to this menu if your inventory screen was opened while in menu.
viewtopic.php?f=8&t=57948&p=524422#p524422
https://www.renpy.org/doc/html/menus.html
Re: renpy.restart_interaction AFTER a Return?
How do you show your inventory screen - using ShowMenu action? If so change it to Show action.
https://www.renpy.org/doc/html/screen_a ... l#ShowMenu
https://www.renpy.org/doc/html/screen_actions.html#Show
https://www.renpy.org/doc/html/screen_a ... l#ShowMenu
https://www.renpy.org/doc/html/screen_actions.html#Show
- lking22
- Regular
- Posts: 50
- Joined: Sun Dec 03, 2017 3:33 am
- Projects: Grey Feather
- itch: freefall-games
- Contact:
Re: renpy.restart_interaction AFTER a Return?
The inventory screen uses the game menu, the same way a save or load screen does. Do I need to build a whole new screen for it instead to make the show thing work?Alex wrote: ↑Wed Feb 19, 2020 7:23 pm How do you show your inventory screen - using ShowMenu action? If so change it to Show action.
https://www.renpy.org/doc/html/screen_a ... l#ShowMenu
https://www.renpy.org/doc/html/screen_actions.html#Show
Re: renpy.restart_interaction AFTER a Return?
You can use the screen you have, but show it with Show action to stay in a game context.
Who is online
Users browsing this forum: No registered users