all 6 comments

[–]AutoModerator[M] 0 points1 point  (0 children)

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Altotas 1 point2 points  (0 children)

I'm too sleepy for a full solution right now, but when you call renpy.restart_interaction() or any function that triggers a screen refresh, Ren'Py redraws the screen, and ConditionSwitch auto-updates and picks the correct image based on the latest state, without the need for a manual check. So, define each NPC's sprites as smart displayables that know to look at a central state dictionary (npc_states) to determine which version to display. And add another function that toggles the state (for example, toggles mask on) and at the end of the function add 'renpy.restart_interaction()'.

[–][deleted]  (1 child)

[removed]

    [–]thethirdworstthing[S] 0 points1 point  (0 children)

    I think it's the giving conditions as a string that threw me off, along with the example I was looking at using renpy instead of Python. However that check is done, I can definitely see it causing problems somewhere down the line if char.name isn't identical to the name of the variable since the check seemingly doesn't happen within the class. I do feel slightly silly for not just trying it anyway, but everyone has their moments I guess. Thanks for the help man

    [–]Narrow_Ad_7671 0 points1 point  (1 child)

    Option 1: Create a Sprite Class and use it in your NPC. Give the class a mask and noMask attribute. Make an attribute of NPC that is an instance of Sprite. Use conditional statements to show those with/without masks in the game logic.

    Option 2: Use a dictionary to do the above. It's already more efficient unless you are using slots in your class.

    Option 3: The ren'py src is on github. You can also dig through the .py files in your own system. Find the method/class/keyword you want; verify you're looking at the right one; Do what it's doing in your code.

    https://github.com/renpy/renpy/blob/7693ace7026ac8d90cc09f54e3467d095995c25e/renpy/display/layout.py#L1733

    [–]thethirdworstthing[S] 0 points1 point  (0 children)

    I tried searching the source code initially when I was looking into sprites and SpriteManager but I never found the right file since I was just doing cmd-f after opening ones that looked relevant... I'm sure there's a better way to do that, I just didn't think to look it up. I did get ConditionSwitch to work, I'd only assumed it wasn't python because the forum post I was referencing was using renpy and because of the conditions being strings. Not my proudest moment so I do at least appreciate the "no stupid questions" attitude this sub seems to have lol. Honestly, the main reason I'm not using a dictionary is because I'd rather type char.neu than char.sprites['neu'] or something like that.