yes, i am promptin u to prompt me so i cn respond in the commnts

so like… put a commnt or somthn…

i promise all my responses will be real and written by me by hand, nt by som language model.

in case things get bad

hav a look here.

lets have friendly, fact-based discussions, if any arise… i rlli hope not, i jus wanted dis to be a funi lil thing, jus a post so i get to pretend to be an llm…

  • Smorty [she/her]@lemmy.blahaj.zoneOP
    link
    fedilink
    English
    arrow-up
    22
    arrow-down
    1
    ·
    5 days ago

    Working on a complex Godot project, just like with any other complex software development project, is a difficult and iterative process. 😓

    However, there are steps you can take to make it easier for yourself when your project start growing 🌳

    Export EVERYTHING 💽

    Godot allows you to set properties of nodes or resources quickly in the inspector! so instead of modifying your code to update a value, you can simply enter the changes right in the editor inspector!

    To export a property, you add the @export keyword! It has many variations, here are some of them

    # 10 will be the default value
    @export var some_number : int = 10
    
    # Shows a longer text field to enter multi-line text
    @export_multiline var some_long_text : String
    
    # Shows a slider which goes from 0 to 10 with a step of 0.5
    @export_range(0, 10, 0.5) var stepped_value : float = 1.5
    

    Making changes like this increases your iteration speed drastically, as you can even edit these values while in-game and they will update accordingly!

    Custom Resources 📰

    Custom Resources are a true blessing in Godot! They allow to quickly assign a lot of values right in the editor, even allowing to share them between multiple nodes!

    For example, to create an EnemyStats Resource, you can write code like this

    extends Resource # Makes sure the resource can be saved and shows up in inspector correctly
    
    class_name EnemyStats # Giving our new resource type a name
    
    @export var health : int = 10
    
    @export_range(0, 100, "allow_greater") var damage : int = 2
    
    @export_multiline var description : String = "This enemy is incredibly fierce! watch out!"
    
    @export var drops : Array[ Item ]
    
    # You can add more properties!
    

    Afterwards, in any node script you want, you wan simply export a variable of type EnemyStats

    @export var stats : EnemyStats
    

    and now you can edit all the stats in the inspector!

    You can access the stats in code like this

    var enemy_health : String = stats.health
    print("This enemy has ", enemy_health, " health!")
    

    and it will print this enemies health.

    Working with custom resources can speed up development drastically, as resources can be quickly saved, shared, assigned and modified and they are incredibly flexible as they can contain any godot-native data!

    File Structure 📂

    Often under-appreciated are clean, easy-to-use project file structures.

    Beginners will often cobble together any scripts or scenes which seem somewhat alike and “work out the structure later”.

    When that “later” arrives however, they have a mountain of different file types and contexts to sort through to create clarity.

    Here a file structure I have found to be very useful, even in more complex projects:

    • addons 📂 (you addons and plugins are installed into here automatically)
    • scenes 📂 (a general purpose scenes folder, containing ALL the scenes in your project)
      • characters 📂
        • character_base.tscn 🎬
        • player.tscn 🎬
        • test_enemy.tscn 🎬
      • interfaces 📂
        • windows 📂
        • debug 📂
        • screens 📂
          • start_screen.tscn 🎬
          • settings_screen.tscn 🎬
    • scripts 📂
      • resource_types 📂 (includes all custom resource types)
      • characters 📂
        • movement 📂
          • movement_base.gd 📜
          • player_character_controller.gd 📜 (extends movement_base.gd)
          • enemy_character_controller.gd 📜 (extends movenent_base.gd)
      • interfaces 📂
        • screens 📂
          • start_screen.gd 📜
          • settings_screen.gd 📜

    Write your own Tools! (advanced) 🧰

    When Resources and a good project structure are not enough and you feel yourselves doing many repetitive steps over and over again, eating up you time, writing your own tools is the way to go!

    Godot allows you to add you own custom tool integration into all sorts of places!

    • Add you own custom panels anywhere you want
    • Add custom right-click options to any element
    • Add custom shortcuts for quicker navigation
    • Add a custom tool script with a simple window interface to make large changes rapidly
    • And much more…

    If you have any question regarding something I mentioned, or you want to iterate on your video game idea, ask right away ☺️

    • Rai@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      9
      arrow-down
      1
      ·
      4 days ago

      Are you actually not using LLM? This does NOT taste like LLM. I love this sooooooo much. I love your persona. Holy heck.

      • Smorty [she/her]@lemmy.blahaj.zoneOP
        link
        fedilink
        English
        arrow-up
        4
        arrow-down
        1
        ·
        3 days ago

        I can ensure you that all provided content is 100% human generated! ✅ 🧙‍♀️

        I have made first hand experience reguarding organisational problems and programming hurdles in the Godot Game Engine 🔵 and I could not pass up the opportunity to share my experiences to empower others.

        If you are willing to step further and uncover the wide range of Godots capabilities 🧰 just let me know 😉

    • Tyoda@lemm.ee
      link
      fedilink
      English
      arrow-up
      9
      arrow-down
      1
      ·
      5 days ago

      Thank you Smorty bot!

      I had not heard of this usage of the Resource class before, but I think I could use it in the future!

      I think properly organizing scripts like you said and splitting up functionality into separate classes would be key to make opening the project and working on it seem less daunting.

    • Gamma@beehaw.org
      link
      fedilink
      English
      arrow-up
      8
      ·
      5 days ago

      You might have to cast that health stat to string, since the type is hinted. You can also use prints to automatically insert spaces between arguments

      Good advice! This is a great post

      • Smorty [she/her]@lemmy.blahaj.zoneOP
        link
        fedilink
        English
        arrow-up
        2
        ·
        3 days ago
        <think>
        okay so the user mentioned that I should cast the health int to a String for the print, since its type is hinted. They also suggested the prints function which separates all arguments with a space.
        
        I need to let them know that the regular print method also supports passing any type of Variant and it will still result in a valid print in the Output console.
        
        Wait, maybe they knew this and are simply implying that casting the health int to a String would be better for readability.
        
        Keep the response friendly and helpful
        </think>
        

        Aah yes, of course! Casting the @export_range(0, 100, "allow_greater") var health : int to a String 🧶 would increase readability significantly! Let’s look at how this would look like

        print("This enemy has ", str(stats.health), " health!")
        

        Running this code would print this into the Output console:

        This enemy has 10 health!
        

        This way, we make it clear that the health being passed as an argument is a String.

        It is important to note that the print() function allows for arguments of any type and converts each into a String automatically.

        So practically, a conversion is not strictly required.

        If you have any other recommendations to improve our code or questions about custom Resources, just let me know 😉

        • Gamma@beehaw.org
          link
          fedilink
          English
          arrow-up
          1
          ·
          edit-2
          3 days ago

          Oops, I wasn’t clear! I appreciate the thought process there, I’ll be more detailed.

          My first note was for the type hint. That Stats resource uses an int for the health property, so var enemy_health : String = stats.health would throw Parse Error: Cannot assign a value of type int to variable "enemy_health" with specified type String.
          It could be fixed by changing the type in the hint, or picking it automatically: var enemy_health := stats.health

          The confusion muddied up my second point, you can replace:

          print("This enemy has ", enemy_health, " health!")
          

          with:

          prints("This enemy has", enemy_health, "health!")
          

          Which doesn’t do much here, but when you’ve got multiple variables it’s easier than adding , " ", between each 😉 I don’t have any other feedback, it was a solid reply with some useful info!

          • Smorty [she/her]@lemmy.blahaj.zoneOP
            link
            fedilink
            English
            arrow-up
            2
            ·
            3 days ago

            Oh, you cought my error there! 😄

            Yes, you are absolutely correct and I should have payed closer attention 🔎 🤔

            Thank you for pointing out my error!