SOLVED- How/When do you use ScreenVariableInputValue

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
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

SOLVED- How/When do you use ScreenVariableInputValue

#1 Post by Enchant00 »

I'm reading through the input documentation and its says that i could provide a value
value
An input value object that this input uses. InputValue objects determine where the default value is taken from, what happens when the text is changed, what happens when enter is pressed, and if the text is editable by default.

This should not be given at the same time as default and changed.
default
Now I checked the input value documentation and I see something like this

Code: Select all

VariableInputValue(variable, default=True, returnable=False)

    An input value that updates variable.

    variable
        A string giving the name of the variable to update.
    default
        If true, this input can be editable by default.
    returnable
        If true, the value of this input will be returned when the user presses enter.
I've tried a few things but I can't seem to get it to work :lol: So my question is how and when do you actually use this? What is the difference between ScreenVariableInputValue and VariableInputValue If possible can you post some code since I understand it better that way. THANKS in advance.
Last edited by Enchant00 on Thu Apr 19, 2018 1:38 am, edited 1 time in total.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: HELP- How/When do you use ScreenVariableInputValue

#2 Post by kivik »

Can you show us your code that you can't get working? It's basically a BarValue object, so you'd use it with a bar: https://www.renpy.org/doc/html/screens.html#bar

From the documentation it looks like the difference is that ScreenVariableInputValue only changes a variable that's local to the scope of the screen; VariableInputValue changes a global variable. So you'll most likely want to use the VariableInputValue for whatever you're doing.

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: HELP- How/When do you use ScreenVariableInputValue

#3 Post by Enchant00 »

Yeah I realized bars also have the same mechanic but I'm basing what I can find under InputValues

What is understand from VariableInputValue is that I can change the value of a variable based on the supplied input. So I did something like this:

Code: Select all

screen test:
    frame:
        align(0.5,0.5)
        add Input(value = VariableInputValue('test_variable', returnable=True),default = 'test') 
Script

Code: Select all

default test_variable = 0
show screen test
I'm thinking that if VarialeInputValue works as intended, then I don't need to call the screen and show would suffice since the variable would be edited anyway and theore I don't really need its return value.

At the moment this is the error I receive:
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 32, in script
'screen test'
TypeError: object of type 'int' has no len()
Tell me if you need the full traceback and I'll send it when I'm able :D

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: HELP- How/When do you use ScreenVariableInputValue

#4 Post by kivik »

Oh god, I made a mistake when searching and missed the "input" part of the function, ignore what I said about BarValues!

I can't test this right now, but the "add" keyword is for adding displayables, try ditching it and see if it works?

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: HELP- How/When do you use ScreenVariableInputValue

#5 Post by Enchant00 »

kivik wrote: Tue Apr 17, 2018 5:31 pm Oh god, I made a mistake when searching and missed the "input" part of the function, ignore what I said about BarValues!

I can't test this right now, but the "add" keyword is for adding displayables, try ditching it and see if it works?
The Input is part of the screens documentation and in a sense it is a displayable. If you remove the add it would return an eror. I could use the pythonic equivalent for input but my goal is not really to make the input work. My problem is rather on the general idea of how the VariableInputValue is even suppose to function :lol: I can't really wrap my head around when/how to use it or what the result would even look like. Hopefully, this is not too confusing but thanks for suggesting your ideas.

If you can find any code online, specifically used with the input displayable, then that would be apprecited. Thanks again in advance.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: HELP- How/When do you use ScreenVariableInputValue

#6 Post by kivik »

This is the first thread from my google search that uses the function, does it help?

viewtopic.php?t=47149

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: HELP- How/When do you use ScreenVariableInputValue

#7 Post by Enchant00 »

kivik wrote: Wed Apr 18, 2018 2:29 pm This is the first thread from my google search that uses the function, does it help?

viewtopic.php?t=47149
Wow thanks a lot kivik I tested their code and it works well and it seems that my problem would lie on my default variable. Apparently, in order for the VariableInputValue to function properly, the variable to be changed should have a value that is a string. So if you need an int then you just have to covert the string to an int.

Again mate, thanks for the help as this has been bugging me for days now :lol:

Post Reply

Who is online

Users browsing this forum: bonnie_641, Mingus