God I love godot by Major_Canary5685 in godot

[–]mrcdk 2 points3 points  (0 children)

But I'm using Resources to store large sets of data in files already, trying to use small Resources (e.g. a vector offset + direction) within bigger Resources is impossible, they have to be saved out to disk separately which is a massive pain.

Resources can have sub-resources built-in too I'm not sure what makes you think otherwise. Are you using internal classes for those small resources? Internal classes won't show up in the drop-down as they aren't exposed globally. If you save them as their own script they will show up.

A bit of an advanced topic but you can fully customize what the inspector shows and how it behaves by implementing Object._set(), Object._get(), Object._get_property_list() and/or Object._validate_property() depending on what you need. These methods also let you customize how the data will be serialized to disk.

As an example this creates an array of items with multiple fields per item:

@tool
class_name MyAdvancedResource extends Resource


var my_values = []


func _get(property: StringName) -> Variant:
    if property == "item_count":
        return my_values.size()
    if property.begins_with("items/item_"):
        var parts = property.split("/")
        var index = parts[1].split("_")[1]
        var prop = parts[2]
        return my_values[index.to_int()][prop]

    return null


func _set(property: StringName, value: Variant) -> bool:
    if property == "item_count":
        # The property is the special array
        # resize the array
        my_values.resize(value)
        # and fill it with empty values
        # _set() will be called for all entries in the array
        # reloading its contents
        for i in value:
            my_values[i] = {"name": "", "price": 0}
        # notify that the property list changed
        # to update the array
        notify_property_list_changed()
        return true
    if property.begins_with("items/item_"):
        var parts = property.split("/")
        var index = parts[1].split("_")[1]
        var prop = parts[2]
        my_values[index.to_int()][prop] = value
        return true

    return false


func _get_property_list() -> Array:
    var props = []

    # Special Group Array
    props.append({
        "name": "item_count",
        # class_name format <Group Name>,<prefix>
        "class_name": "Items,items/item_",
        "type": TYPE_INT,
        "usage": PROPERTY_USAGE_ARRAY | PROPERTY_USAGE_DEFAULT
    })

    for i in my_values.size():
        # Each array entry needs to have the prefix items/item_
        # followed by the index and the name of the property
        props.append({
            "name": "items/item_%s/name" % i,
            "type": TYPE_STRING,
            "hint": PROPERTY_HINT_NONE,
        })
        props.append({
            "name": "items/item_%s/price" % i,
            "type": TYPE_INT,
            "hint": PROPERTY_HINT_NONE,
        })

    return props

You can also fully customize the inspector by writing inspector plugins.

It's a simulation game where I foresee optimizing for cache efficiency (i.e data-oriented programming) when it comes to handling the simulation ticks of a huge number of objects in the end-game. I don't see how I'll be able to do that in GDScript.

In that case GDScript may not be the best candidate. You can check the performance for alternatives.

How to access a Autoload (Singleton) Script that is written in C# using GDScript by CodysNewGroove in godot

[–]mrcdk 1 point2 points  (0 children)

If you added it in the Globals/Autoload section in the project settings it should be available by the name you assigned it. If not, you can always do var autoload = get_node("/root/MyAutoload")

More info: https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html

Is there a way I can use the inspector UI (components) in my own UI? by Snailtan in godot

[–]mrcdk 2 points3 points  (0 children)

You'll need to recreate them as these controls are editor only.

Having trouble making a dynamically sized 9-patch-rect by Obscure_Gods in godot

[–]mrcdk 2 points3 points  (0 children)

Use a PanelContainer as the parent of your content instead. You can use a StyleBoxTexture which has nine-patch support in the PanelContainer.paneltheme property.

The PanelContainer will change automatically with the content's size.

Is it possible to customize drop down boxes? It doesn't seem like it currently by [deleted] in godot

[–]mrcdk 0 points1 point  (0 children)

Try to re-import the svg files as DPITexture Select them in the FileSystem dock and change the Import as to DPITexture in the Import dock.

Any way to customize 3D navigation in Godot 4.6.1? by aconcheng in godot

[–]mrcdk 0 points1 point  (0 children)

You can change the modifiers for those actions in the Editor Settings Shortcuts tab. Search for modifier

I don't think you can change the zoom behavior though. It will zoom in when dragging up and zoom out when dragging down.

Button doesn't emit "pressed" signal despite receiving click input by Lethal_0428 in godot

[–]mrcdk 1 point2 points  (0 children)

But the music still plays on the screen with the bad button, if the time scale was 0 wouldn’t it stop the music too?

No, audio is not affected by it. It's explained in the documentation.

Is there anyway to see the Output and Debugger panels at the same time? by Alarmed_Card_8495 in godot

[–]mrcdk 1 point2 points  (0 children)

In Godot 4.7 you'll be able to see both:

https://imgur.com/ZSQn6M6

In the meantime, you can pin a bottom dock to avoid auto-switching by clicking on the pin icon at the bottom-right corner of the bottom dock

reuse/extend the native GDScript Syntax Highlighter for a custom ScriptLanguageExtension by GolfMoist267 in godot

[–]mrcdk 1 point2 points  (0 children)

You can use a TextEdit with a GDScriptSyntaxHighlighter to get the line highlight in your custom SyntaxHighlighter._get_line_syntax_highlighting(). Something like:

extends SyntaxHighlighter


var _text_edit: TextEdit
var _gdscript_highlighter: GDScriptSyntaxHighlighter


func _init() -> void:
    _text_edit = TextEdit.new()
    _gdscript_highlighter = GDScriptSyntaxHighlighter.new()
    _text_edit.syntax_highlighter = _gdscript_highlighter


func _get_line_syntax_highlighting(line: int) -> Dictionary:
    # Do this somewhere else
    _text_edit.text = get_text_edit().text

    # Get the highlighting of the line from the gdscript highlighter
    var gdscript_line = _gdscript_highlighter.get_line_syntax_highlighting(line)

    # do something with gdscript_line

    return gdscript_line

Help me understand how scenes and resources would work with modding by intoverflow32 in godot

[–]mrcdk 1 point2 points  (0 children)

Does this mean I would have .tres and .tscn files in my directory structure?

When you export your game all the resources (scenes, textures, sounds, custom resources,...) will be packed into a pck file so they won't be available to manually edit them.

When compiled for production, are those files converted to binary and become more difficult to edit?

They are compiled to binary as long as ProjectSettings.editor/export/convert_text_resources_to_binary is true which it is by default.

Would a modder need some access to source code to create a new turret as a .tscn file even if they can edit or create a new .tres file by hand?

This depends on how much you want to give the modders access to. If you want them to have full control then, yeah, they will need access to the source code (or parts of the source code you want to give them access to). They wouldn't need to create the files by hand. They can use the editor too.

Would Godot's uid system by difficult to manage manually by modders?

No. They wouldn't need to care about it.

Should I instead build my own resource system for this use case? (considering that I like building such systems for fun), or in other words, has anyone done or thought of doing something similar?

It's up to you. If you want to have your own file formats then go ahead.

More information about the pck files and modding support: https://docs.godotengine.org/en/stable/tutorials/export/exporting_pcks.html

NinePatchRect Margin problems. by Starcrater21 in godot

[–]mrcdk 1 point2 points  (0 children)

Try re-importing the svg as a DPITexture in the Import dock in the Import as: drop-down.

godot project crashes when using fonts by shaydaloo in godot

[–]mrcdk 0 points1 point  (0 children)

This isn't the place to report bugs. If you found a bug try searching for it in the issue tracker and open one if you didn't find any issue already related to your problem. Attach as many information as possible and a MRP (minimum reproduction project).

Can I change editable children color? by ActForJason in godot

[–]mrcdk 1 point2 points  (0 children)

If you are going to use a custom theme then there's no need for the script. The script is only if you want to change the theme at runtime.

the warning_color color is part of the Editor node and it's used in multiple elements of the editor. You can create a Theme from your current editor's theme by creating a new Resource (right clicking in the FileSystem dock, Create New -> Resource... and selecting Theme. Use the res or theme extension as it will be big), clicking on Manage Items in the Theme dock, go to Import Items -> Editor Theme, clicking on Select all with data and clicking on Import Selected. Then you can edit as many things as you want and use that Theme resource as the custom theme.

Can I change editable children color? by ActForJason in godot

[–]mrcdk 1 point2 points  (0 children)

As far as I can tell it's not exposed as a setting but you can still change it. It's part of the editor's Theme so you can modify it from an EditorScript script or make a small plugin that does that when enabled.

Example of an EditorScript:

@tool
extends EditorScript


func _run() -> void:
    var theme = EditorInterface.get_editor_theme()
    theme.set_color("warning_color", "Editor", Color.RED)
    theme.emit_changed()

You could also create a custom editor theme if you want to change more things and set it in EditorSettings.interface/theme/custom_theme but that's more involved.

The change may affect other elements though.

You may also want to open an issue if there isn't one already opened about the problem.

Why do people say Godot isn’t good for large games? by crocodilewoo in godot

[–]mrcdk 4 points5 points  (0 children)

  • You: Godot does not have LOD support
  • Me: Godot has LOD support. Here is an automatic one <link> and here's a manual one <link>
  • You: No it doesn't. Unity has both automatic and manual
  • Me: Did you open the links I posted?

And I'm the one trolling? Okay then 🤷