Welcome to the forums @jsprenkle!
@jsprenkle said:
Continuation
Can statements be spread over multiple lines? What delimits then end of a 'statement'?
Generally a new line defines the end of the statement. You can extend statements across multiple lines in ways similar to Python though if/when you need it. Here's a few examples:
var single_line = "hello world"
var multi_line_one = (
"hello" + " world"
)
# I think this works, but I haven't tested it without a semi-colon at the end...
var multi_line_two = "hello" + \
"world"
Flow of control
Flow of control statements seem to be separated from the statement(s) they control by a colon.
What delimits the block of statements?
As an example:
while true:
print "huh"
Is the controlled statement indicated by indention or position?
If I want more than one statement what delimits where the controlled block ends?
The first un-indented statement? A blank line?
Correct, control statements are defined by the use of a colon at the end. After the colon, indentation is what determines the block that is executed. Position does not affect the control. Spaces or tabs can be used for indentation. Here's an example:
# example condition
if (2 > 0):
print ("2 is more than 0")
# another example
var i = 0
while i < 10:
i += 1
print ("I is: ", i)
If I am understanding correctly what you are meaning by "delimits where the controlled block ends" correctly, you mean having multiple conditions/control statements, correct?
For multiple statements, you can just go down a level of indentation and then use another control block:
var times_more_than_five = 0
for i in range(0, 10):
print ("I is: ", i)
if (i > 5):
print ("I is more than 5!")
times_more_than_five += 1
if (times_more_than_five > 0):
print ("I was more than five at least once")
Operators
In logical comparison does it use 'and' or '&&' or '&'?
Are binary operators available?
You can use either in Godot 3.x. I tend to use and
and or
over &&
and ||
simply because I find it a little easier to read, but whatever is your preference is fine to use.
In Godot 4.0 I believe you will only be able to use and
and or
, as &&
and ||
are removed to make the parser easier. I could be wrong though, so please take this with a grain of salt!
I'm not sure on the binary operators. I'm sure they probably exist, but I haven't really needed to use them so I do not know right off.