Skip to content

cannot make gd.StringName work #8

Answered by Splizard
ardawan asked this question in Q&A
Discussion options

You must be logged in to vote

It doesn't look like the Godot Environment class has an add_resource method?
https://docs.godotengine.org/en/4.2/classes/class_environment.html

I regards to StringName, this is a Godot defined reference type, it can be initialised via an available gd.Context. You can create a gd.String and call the StringName method on it. The value will be valid for the lifetime of the context.

func (w *World) Ready(godot gd.Context) {
    var name = godot.StringName("Go string that will become a StringName")

    // do something with name
}

Note that for any godot reference types (including string names & classes), the zero value is not valid, ie. it is essentially nil. So passing gd.Environment{} does…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ardawan
Comment options

@Splizard
Comment options

Answer selected by Splizard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants