Rakugo-Dialogue-System icon indicating copy to clipboard operation
Rakugo-Dialogue-System copied to clipboard

Support for `in` keyword in RakuScript

Open Jeremi360 opened this issue 2 years ago • 9 comments

I think we should add support for in keyword or its alternative, but for only easier writing if, I think that rakuscript don't need loops.

# gdscript
if true in [x, y, z]:
# is same as gdscript
if x or y or z:
# rakuscript
orif x, y, z:

# gdscript
if not (false in [x == 1, y == 2]):
# is same as gdscript
if x == 1 and y == 2:
# rakuscript
andif x == 1, y == 2:

Jeremi360 avatar Apr 12 '22 16:04 Jeremi360

What you think @theludovyc and @MatteoPiovanelli-Laser ??

Jeremi360 avatar Apr 13 '22 16:04 Jeremi360

I haven't dug in rakuscript enough to really weigh in on this. Personally, I never use the in keyword in if clauses, because I've been writing ifs without it for too long, but it's just a matter of habit.

What is your reasoning against loops?

MatteoPiovanelli-Laser avatar Apr 13 '22 20:04 MatteoPiovanelli-Laser

I haven't dug in rakuscript enough to really weigh in on this. Personally, I never use the in keyword in if clauses, because I've been writing ifs without it for too long, but it's just a matter of habit.

in in ifs are allows to write complied conditions with many ands or ors easier.

if true in [x, y, z]:
# is same as gdscript
if x or y or z:

What is your reasoning against loops?

RakuScript is aim to write branching dialogs, if you really need loops RakuScript supports gdscript blocks with which you can write almost any gdscript code.

Jeremi360 avatar Apr 13 '22 20:04 Jeremi360

So you are saying to have a base rakuscript that does what the scripting in renpy does, and is easy to parse by a non programmer into one (or several) text files for the dialogues and scenes (as in, not necessarily godot's scenes, but a story's scenes). If someone has to put complex logic into them, then they have the option to use gdscript directly. Right? I can support that.

MatteoPiovanelli-Laser avatar Apr 13 '22 21:04 MatteoPiovanelli-Laser

So you are saying to have a base rakuscript that does what the scripting in renpy does, and is easy to parse by a non programmer into one (or several) text files for the dialogues and scenes (as in, not necessarily godot's scenes, but a story's scenes). If someone has to put complex logic into them, then they have the option to use gdscript directly. Right? I can support that.

Yes.

Jeremi360 avatar Apr 13 '22 21:04 Jeremi360

as possible counterpoints to what I just said:

  • the syntax with gdscript should allow mixing gdscript and rakuscript clearly, so that it's possible for example, to have a character say a line 10 times by looping 10 times.
  • renpy has an explicit while statement to avoid having to mix syntaxes per my previous point.

MatteoPiovanelli-Laser avatar Apr 13 '22 21:04 MatteoPiovanelli-Laser

the syntax with gdscript should allow mixing gdscript and rakuscript clearly, so that it's possible for example, to have a character say a line 10 times by looping 10 times.

Sorry for some reason I had some block in my mind I could think about loops only in case of every advanced code, but you are right in this case loop would be useful, so I no longer against it.

renpy has an explicit while statement to avoid having to mix syntaxes per my previous point.

I didn't know that renpy has loops I didn't saw it in any renpy code I saw, and if it is in their docs I miss it.

Jeremi360 avatar Apr 14 '22 07:04 Jeremi360

To be fair, I can see not needing loops in 99% of "normal" vns. But there are several things a while statement can make nicer. For example, a character describing their clothes/inventory in a dialogue, by iterating over them. Link to renpy's while statement: https://www.renpy.org/doc/html/conditional.html#while-statement Honestly, I've never seen it in the wild, but I've never looked too hard for it.

MatteoPiovanelli-Laser avatar Apr 14 '22 10:04 MatteoPiovanelli-Laser

renpy has an explicit while statement to avoid having to mix syntaxes per my previous point.

You are wrong here @MatteoPiovanelli-Laser, every programming language has while loop, but is not used so often.

I moved this discussion about loops to separated issue #64

Jeremi360 avatar May 04 '22 07:05 Jeremi360

This issue is should closed a long time ago, as our if to check its condition uses Godot's Expression class. A class that allows you to execute the GDScript code given in string, and GDScript supports in so our RakuScript too. So I closing it @theludovyc .

Jeremi360 avatar May 26 '23 06:05 Jeremi360