Page 1 of 1
[SOLVED] define, default, $ xxx =
Posted: Sat Dec 25, 2021 6:16 pm
by felsenstern
Hiya,
what is the difference between:
define bob = "bob the builder"
and
$ bob = "bob the builder"
or
define kate = Character("kate"...)
and
$ kate = Character("kate"...)
? is there any explanation when to use what or if there is something behind define that $ = doesn't do, or the other way around? Must say for all the time I use Renpy until one or two months ago, I didn't even had the idea that "define bob = Character("bob"...)" would just put a class reference into the bob variable, I just knew that I could use bob afterwards as a say command imagining that define would do something more...
Re: define, default, $ xxx =
Posted: Sat Dec 25, 2021 6:46 pm
by Ocelot
Did you read documentation?
https://www.renpy.org/doc/html/python.html
define x = y is completely equivalent to
Code: Select all
init python:
x = y
# or
init:
$ x = y
And should be used for variables you don't change during the game
default is more complex, one main difference is that defaulted variables are always saved, so it solves some problems with saving of complex objects.
Re: define, default, $ xxx =
Posted: Sun Dec 26, 2021 4:50 am
by felsenstern
I read the documentation and more than once, but why would I find "Statement Equivalents" not on the page that was named so but on a page named "Python Statements" that I would consider having a Reference of Python Statements valid inside of Ren'py eludes my very simple mind. Not to forget that variable definition would be the first thing you would learn in any other language. So any sane person would expect to learn on how to set a variable up in the earliest and most basic part of a documentation. Here instead we learn about $ bob = ... and define bob = ... without any word that both things are doing the same or what define is really doing. But thanks anyway I wouldn't have found it on my own.
Re: define, default, $ xxx =
Posted: Sun Dec 26, 2021 5:14 am
by Ocelot
felsenstern wrote: ↑Sun Dec 26, 2021 4:50 am
Not to forget that variable definition would be the first thing you would learn in any other language. So any sane person would expect to learn on how to set a variable up in the earliest and most basic part of a documentation. Here instead we learn about $ bob = ... and define bob = ... without any word that both things are doing the same or what define is really doing.
The variable definition is technically in quickstart documentation, which is the first thing you read.
Knowledge that "define is for characters, default for flags/counters/other variables declaration and $ x is for ingame changes" is enough for majority of games made in RenPy. In-depth knowledge of what it is doing is needed if you are going to heavily rely on Python, in which case you would have to read whole Python chapter of documentation. If you just want to know for sake of curiosity, documentation search (or using keyword reference page in documentation) usually works well.
Re: [SOLVED] define, default, $ xxx =
Posted: Mon Dec 27, 2021 4:23 am
by felsenstern
Yes, there are many ways to search, many ways to spend time just to search for one information that could have been provided in just a few words or even lines and in so many cases. Ren'Py is full of it and everyone who learned Ren'Py is aware of this crap so what are we talking about? How many developers jumped ship and starting over in Unity, not because they would use any 3D-Function there, no - same 2D game but with less digging and searching for the next command for the next understanding how to use a simple command, that yeah is anyway so obvious to use, why waste a word or line more to make things clear, when you can have fun with those people begging on the Newbie forum again and again, to get another bit and always with the RTFM comment... thank you very much!