Turn off dev mode in Renpy

CheekyGimp

Active Member
Donor
Game Developer
Mar 8, 2018
843
5,176
Hi - I turned on Dev mode in Renpy to help me during development, using
config.developer = ""true"

but, now I cannot turn it off. I changed this line to false, but when I create my build, it still allows the player to open up the Dev console. This line was only added in the script file (didn't change anything in options file).

Any ideas ?
 

UncleVT

Låt den rätta komma in
Moderator
Jul 2, 2017
9,439
102,491
See this:

Perhaps helps.

Edit: or somthing like this:
init 999 python:
config.developer = True
config.console = True
Changing True for False (cases are sensitive)
 
  • Like
Reactions: CheekyGimp

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,384
You don't want to use a string, you want to use a Python boolean.
Code:
config.developer = True
or
config.developer = False
not
Code:
config.developer = "true"
or
config.developer = "false"
The problem (if I'm remembering correctly) is that a non-None string is "truthy" in Python, so even the string "false" is treated as being True.
 
D

Dr PinkCake

Guest
Guest
If the problem persists, try force recompile while deleting the persistent data. I have had trouble with webm's not looping all of a sudden. This fixed that issue.
 
  • Like
Reactions: CheekyGimp

CheekyGimp

Active Member
Donor
Game Developer
Mar 8, 2018
843
5,176
You don't want to use a string, you want to use a Python boolean.
Code:
config.developer = True
or
config.developer = False
not
Code:
config.developer = "true"
or
config.developer = "false"
The problem (if I'm remembering correctly) is that a non-None string is "truthy" in Python, so even the string "false" is treated as being True.
Nailed it! Thanks a lot. Was driving me mad, because when I played around and checked the variables, it was telling me false when I expected false and true when expected true, but yet it always behaved as true. Fucking BOOLEAN!! And I studied Electronics !! :) (but not programming obviously !!)
Thanks Rich. As always - You know your shit!
 

CheekyGimp

Active Member
Donor
Game Developer
Mar 8, 2018
843
5,176
See this:

Perhaps helps.

Edit: or somthing like this:

Changing True for False (cases are sensitive)
Thanks. Yep the "" define a string. Should be a BOOLEAN as per Rich's inputs.
 
  • Like
Reactions: UncleVT

CheekyGimp

Active Member
Donor
Game Developer
Mar 8, 2018
843
5,176
It's crazy how much time gets lost on all this shit. I should be rendering today!!! I really should have spent 6 months reading tutorials before getting started, but just don't have the patience. I'm a learn-as-I-go person.
 
  • Like
Reactions: bas and UncleVT

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,384
This isn't specifically a Ren'py "thing," it's a "Python thing." (Ren'py being implemented in Python, of course.) Python (and JavaScript) try to be "nice", so they will silently convert from one data type to another. So when the code says "is config.developer true or false?", and if it's set to something other than a Boolean, Python will try to convert whatever it actually finds to a Boolean. The problem is the rules it uses - it doesn't try to transliterate the string (i.e. "false" -> False), it just says "if it's any non-empty string, I'll treat it as True. If it's set to None or an empty string, treat it as False." This lets programmers type
Code:
if someStringVariable:
and have it mean "is this variable set to any non-empty string?"

This is one of the pitfalls of "weakly typed languages," of which Python is one. In a "strongly typed" language, you would have gotten an error that said something like "config.developer should be set to a boolean, not a string." This flip side is that weakly-typed languages let you do some things easily that are hard in strongly typed languages. Tradeoffs.

Experienced Python-ers (of which I am NOT) don't have problems, but people new to the language get caught by this kind of thing.
 
  • Like
Reactions: bas and CheekyGimp

thecardinal

Latina midget, sub to my Onlyfans - cash for gash
Game Developer
Jul 28, 2017
1,491
4,431
Every time I feel like I finally understand Ren'py, something like this happens and I have no idea how to fix an issue. It's humbling.
 
  • Like
Reactions: bas

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,384
Every time I feel like I finally understand Ren'py, something like this happens and I have no idea how to fix an issue. It's humbling.
LOL. We've all been there. Nobody knows everything - that's why the rest of us are here... :)

(What expertise I have is mostly the product of banging my head against the wall for lo these many years...)
 
  • Like
Reactions: bas

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,979
16,236
[...] Python will try to convert whatever it actually finds to a Boolean. This lets programmers type
Code:
if someStringVariable:
and have it mean "is this variable set to any non-empty string?"
Sort of yes, but no. In fact the line you wrote mean, "has someStringVariable have a value" ; with either False, None and 0 meaning "no value", and everything else meaning a value.
Using this syntax to test a Boolean value come from older languages which don't have a Boolean type. In these languages, 0 mean False and any other value mean True. So, in these language, this line is legit, even if still an error. But with Python, and so Ren'py, it's just an error since Python have a Boolean type.
Code:
    $ a = 0
    if type( a ) is bool:
        pass
    else:
        "The variable is NOT a boolean."
    if not a:
        "The test pass"
    if a is False:
        pass
    else:
        "It's NOT a false value."
    $ a = False
    if type( a ) is bool:
        "The variable is a boolean."
    if not a:
        "The test pass"
    if a is False:
        "It is a false value."


This is one of the pitfalls of "weakly typed languages," of which Python is one.
Sorry, but Python is not weakly typed. It's a language.

The type of each attribute is defined at its creation and can NOT be changed nor seen like being from another type. This is due to the fact that each attribute is in fact an object. When you assign a value to an attribute, Python don't store the value somewhere in memory, but create an object which will handle this value.
Open the console :
Code:
a = 0
dir( a )
In the same time, Python is also dynamically typed ; you don't have to declare the type of the attribute like you usually do with strongly typed language, Python will do it itself.
Open the console :
Code:
a = 0
type( a )
b = "abc"
type( b )
And finally, the attribute are immutable. Each time you change the value of an attribute, whatever by direct assignation ( v = something) or by indirect one (v += 1), you don't update the value, but create a completely new object. "v += 1" doesn't translate to, "add 1 to the value of v", but to, "take the value of v, add 1 then store the result in an attribute named 'v' which will overwrite the previous 'v' attribute".
Open the console :
Code:
a = 0
id( a )
a += 1
id( a )
If you put the dynamically typed and immutability together, it let's Python looks like a weakly typed language, because you have the impression that you can assign a string to what was an integer. But it's all, it "looks like", just looks, not acts. You also can't do what's possible with weakly typed languages, like, by example, taking an array and performing string manipulations on it, or taking an integer and adding a string at the end of it. If you try it, Python will complain :
Code:
a = "abc"
a += 1
It will lead to :"TypeError: coercing to Unicode: need string or buffer, int found"
 
  • Like
Reactions: bas

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,384
Sorry, but Python is not weakly typed. It's a language.
Matter of semantics, I guess. In Python, variables/references are not strongly typed, although values are. I'm OK with "dynamically typed" as a name for that middle ground. Compare that with Java, where variable types cannot be altered. _That_ is "strongly typed" in my book. :) But I fully acknowledge that there's actually a continuum here...
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,979
16,236
Compare that with Java, where variable types cannot be altered.
You can't either with Python. It's the immutability which trick the user into thinking that the typing is weak, because the container/attribute is deleted then recreated each time its value change ; contrary to Java which keep the container/variable. And like it's a whole new attribute, its type can be whatever you want, not necessarily the previous one.
When you wrote (in Python) :
Code:
  a += 1
what happen in reality is the equivalent (in Java) to :
Code:
  int tmp = a;
  a = null;
  [The garbage collector act immediately]
  int a = tmp + 1;
And it's the exact same process for any kind of assignation (Python):
Code:
 a = 1
 a = "abc"
is in fact (Java) :
Code:
  a = null;
  [The garbage collector act immediately]
  int a = 1;
  a = null;
  [The garbage collector act immediately]
  string a = "abc";
[Note: my Java is really rusty, hope I wrote it correctly]

That why Python will not complain that you try to assign a value of a wrong type, because the type of the recreated attribute will depend of the said assigned value. But in the same time, it will complain anytime you try to mix the type. By example, you can't change the string "123" into the int 123 without explicitly converting it, like it's the case with a weakly typed languages :
Code:
a = "123"
a +=1
will raise a TypeError exception with Python, while it'll lead to "a = 124" with a weakly typed languages.