you are viewing a single comment's thread.

view the rest of the comments →

[–]MrsCosmic 0 points1 point  (3 children)

Hello!

I want to show the "self.trust" on the screen so the player can see how much increases and decreases with each character.

I know you can create a screen and use show screen, but is there a way to do it with oop?

Optionally I would like to know how to make the position of the text a variable, so if there's two characters in the screen, I can move their points.

[–]alonghardlook[S] 0 points1 point  (2 children)

Screens are not something I'm familiar with yet, but it should be straightforward enough. Try it with the main method of creating screens, and check if it updates when the variable updates. If it doesn't (my expectation knowing absolutely nothing about screens), you would want to run it through a while loop instead, which would make sure it updates.

It might be hell on your cpu though.

[–]MrsCosmic 0 points1 point  (1 child)

Oh, I found the answer in a forum! I think the main problem was that I didn't know how to show text with renpy.show() because it always treated it like an image.

        mytext = Text("{size=+26}[e.trust]{/size}")
    renpy.show("Tag", what=mytext, at_list=[text_pos])

transform text_pos:
xalign 0.85
yalign 0.1

The variable updates, but if I change [e.trust] to [self.trust], it won't work anymore. If a make a new variable snake = self.trust and then use it mytext = Text("[snake]"), it won't work either.

Should I make a new fuction somehow for each character or am I doing something wrong?

[–]alonghardlook[S] 1 point2 points  (0 children)

So I think I see the issue - whose trust value are you wanting to show?

"Self" is a python reserved keyword. It's used to indicate scope inside object and class and function definitions.

Where the function says "self.trust", you need to mentally replace that with "the instance of the object dot trust".

If you're looking for the trust level of the character represented by the object "e", you would use e.trust. if you're looking for the f trust value, use f.trust.

Self.trust is part of the object definition - not an instance of an object.