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.
In my game I use a function that displays a small animation and changes the amount of the player's resources. However, players are saying they want to see a numerical value pop up next to the resource amount. I tried adding a text displayable that has a variable substitution in it. It fades in, stays on screen for 3 seconds and fades out. The code works otherwise, but for some reason instead of the number it just shows "0".
The problem probably is that for some reason the game is using the original value I set for the variable instead of the current "wealthaddsum". I tried fixing this by defining the text displayables as DynamicImages but it isn't helping. Does anyone know how I should go about doing this?
DynamicImage("[variable]") should be provided a variable to interpolate that is the name of another displayable, not another displayable directly. There are a lot of ways to pop up text on the screen, but if you're set on doing it from a function you can simply use renpy.show('wealth', what=Text("[weathaddsum_variable]")). The first argument can be any non-empty string and will act as the displayable's tag.
My I ask why you aren't using renpy.notify to show your number?
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
You're kinda declaring your variables twice, one with default, and again in your init python block. Could that be related to the problem? And isn't it better to just use a screen for this?
trooper6 wrote: ↑Thu Feb 08, 2018 2:55 pm
My I ask why you aren't using renpy.notify to show your number?
Because I didn't know renpy.notify existed :'D It seems like it'd suit my purposes well! I'd have to change the notify code somehow tho, since I want the numbers to be displayed next to the resource that's changing. Not sure how to do that, but I guess I'll look into it? Or create a new screen that's similar to the notify screen and show that instead?
ReDZiX wrote: ↑Thu Feb 08, 2018 5:00 pm
You're kinda declaring your variables twice, one with default, and again in your init python block. Could that be related to the problem? And isn't it better to just use a screen for this?
I don't think declaring them twice causes it because the problem was there even before I had declared them twice, I think? I need to declare them twice because this is for a patch for the game so I need to set them with default so that if someone has a save from before the patch they can keep using that save (hopefully). But I think I also need to define them in init or otherwise renpy will show an error message... I think. I'm not 100% sure anymore, but I think that's why I declared them twice.
As for the screens issue, maybe it'd be good to use one? I think I didn't use a screen because ATL doesn't work with screens and I wanted a dissolve effect, but I guess there's some way to use dissolve with a screen since the notify screen seems to be using it. I need to look into it.
screen wealth_text:
if wealthaddsum_variable > 0:
text "{size=-10}{font=Cinzel-Black.ttf}{color=#ceff93}+[wealthaddsum_variable]{/color}{/font}{/size}" at atwealth2, fadeinout2
else:
text "{size=-10}{font=Cinzel-Black.ttf}{color=#f46d44}[wealthaddsum_variable]{/color}{/font}{/size}" at atwealth2, fadeinout2
timer 2.5 action Hide("wealth_text")
It wasn't beyond my capabilities to make this work, but I just hadn't realized screens were the way to go. Thank you so much for the help, everyone!
Now the text is also red or green depending on if you lose or gain resources so it's pretty neat.
Aviala wrote: ↑Thu Feb 08, 2018 2:31 pm
Thanks, but when I changed the function to this I can no longer see the text at all; not even the 0 that showed up before: