Zini So, the reason I had the two lines is in order to make the buttons invisible when the ship isn't active, and visible when active. If I wrote it as you suggested wouldn't it make it visible as long as arr_ship isn't empty. Which wouldn't work since there will be times it isn't empty that I don't want the buttons visible.

  • Zini replied to this.

    xRegnarokx Nope. My code does exactly what you describe. The visibility state is set to the active state (either true or false). Booleans are no different from any other variable or value. You can assign them just as easy as an int for example.

      DaveTheCoder Thanks! With the is_empty and active to combine those would mean I'd have to duplicate is_empty in order to initiate a reset func that I have in place, so for me it is best to keep those seperate but to streamline them like you suggested. Thanks so much!

      Zini The last example isn't correct. The else branch still accesses the array.

      No, the else branch does not access the array.

      Here's another way:

      var active: bool = not arr_ship.is_empty() and arr_ship[i].active
      accel.visible = active
      decel.visible = active
      turn_l.visible = active
      turn_r.visible = active
      • Zini replied to this.

        @xRegnarokx You could benefit from taking a basic programming course, preferably one that's focused on Python programming language whose syntax is very similar to GDScript. I'm saying this because it seems like you constantly struggle with fundamental logic and control flow of your program. Focusing only on those basic aspects without the burden of game engine features/concepts may lead to quicker improvement in your overall coding skills.

          Zini I understand that aspect of boolean, but the question is what makes it become invisible again? If you set visible = true, won't it just stay true?

          • Zini replied to this.

            xyz That is a good suggestion. The issue is I struggle learning when I don't have a concrete objective, and I have yet to find a programming course that does that. Also I tend to learn better by doing/seeing the results than just taking a course. But, I'll do some research to see if I can find a foundational Python course.

            • xyz replied to this.

              xyz I'm interested on good tutorials in python as well! "automate the boring stuff with python" proceeds to not automate any boring task, and basically teach python syntax as usual. I'm interested on finding a good hands-on teaching python courses for our juniors, I did a quick search last year but was left unconvinced. Does anybody have some gold tutorials in mind? Maybe my expectations are unrealistic.

              I love the way tiangolo documents for example. And fowler is another icon.

              • xyz replied to this.

                quimnuss I'm interested on good tutorials in python as well! "automate the boring stuff with python" proceeds to not automate any boring task, and basically teach python syntax as usual.

                It's full of practical examples and the second half is literally just projects that automate boring tasks, but it's a book not a tutorial. The majority preference for "quick and easy" tutorials is precisely what got as where we are - a lot of people lacking the most fundamental knowledge while attempting to execute relatively ambitious projects.

                There's an ages old wisdom. If you want to learn something proper - read a book about it. It takes time but it works 🙂

                  xyz aaah i see, i scrolled down to read the table of contents, which is the TOC of the udemy course, not the book! I'll definetely check it out