this post was submitted on 09 May 2024
20 points (100.0% liked)

Godot

6007 readers
18 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 2 years ago
MODERATORS
 

I have tried myself at using Expressions for quickly throwing together some simple functionality right in the editor, without opening the script editor. I just export an array of Strings. But apparently assignment is not allowed in these expressions! Method calls are fine, but assignment doesn't seem to be okay. Here is what this looks like:

The method calls actually work perfectly fine here, but the assignments (with = in the line) do not seem to work. It seems to complain about there missing another = even though it is already there. Does someone have an idea on why this might happen?

top 5 comments
sorted by: hot top controversial new old
[–] stickyShift@midwest.social 6 points 7 months ago (1 children)

I am not familiar with the feature you're using, but an "expression" is just some code that evaluates to a value; in other words, it's the right side of the equals sign.

[–] Smorty@lemmy.blahaj.zone 5 points 7 months ago (1 children)

Oh yeah, that makes sense. In the documentation the only actual example they give for expressions is a math equasion, so I guess the code-executing features just came naturally... So I guess I will have to write methods for everything now...

[–] Maddier1993@programming.dev 1 points 7 months ago (1 children)

Or maybe try to have your methods as a left side.. example: Expression: print()

[–] Smorty@lemmy.blahaj.zone 1 points 7 months ago

This I dotn exactly understand. Do you mean it like this

print(Input.mouse_mode = Input.MOUSE_MODE_CAPTURED)

[–] popcar2@programming.dev 6 points 7 months ago* (last edited 7 months ago)

Most variables have setters for situations like this. Rather than using get_tree().paused = false, try get_tree.set_pause(false). There's also Input.set_mouse_mode(), you'll see them under the variable names in the docs.