Can you use an adjustable bar on a variable within a class?[Solved]

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.
Post Reply
Message
Author
User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Can you use an adjustable bar on a variable within a class?[Solved]

#1 Post by namastaii »

I am not amazing at classes so I'm trying to understand them better. I also kind of need them for my project. Any guidance would be helpful. I'm trying to condense my code as much as possible. Do I have to use external variables for this or is there a better way?

How can I directly adjust the variable thing.myvar in this example?

Code: Select all

class element(object):
        def __init__(self, myvar):
            self.myvar = myvar
    class example(element):
        def __init__(self, myvar=None):
            self.myvar =myvar
    thing = example(myvar=50)

Code: Select all

screen forexample():
    hbox:
        bar value VariableValue("thing.myvar", 200)
It returns the error "value = getattr(self.object, self.fied) AttributeError: 'StoreModule' object has no attribute 'thing.myvar"
I can display the variable and even use it obviously, I just can't figure out the syntax to directly manipulate this variable or the extra steps I'm missing to make it possible. Thank you.

I can manipulate thing.myvar with SetVariable() just fine though. Just can't use a slider bar with it.. I also want to make sure this variable sticks as well though because I'll need it later
Last edited by namastaii on Tue Aug 20, 2019 12:07 pm, edited 1 time in total.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: Can you use an adjustable bar on a variable within a class?

#2 Post by Remix »

You probably want a different Bar Value object. Most likely

https://renpy.org/doc/html/screen_actio ... FieldValue
Frameworks & Scriptlets:

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Can you use an adjustable bar on a variable within a class?

#3 Post by namastaii »

I did try that, and I got the same error so I wasn't sure if it mattered what kind of value bar it was at this point haha

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Can you use an adjustable bar on a variable within a class?

#4 Post by namastaii »

I had typed something wrong in fieldvalue - it works now thank you!

I think I had FieldValue("thing", "myvar", 200) instead of FieldValue(thing, "myvar", 200)

Post Reply

Who is online

Users browsing this forum: Bing [Bot]