Skip to content

Set non exported values #167

Answered by Ark2000
eldegende asked this question in Q&A
Mar 29, 2024 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

unfortunately you can not directly modify a non-object's property by a single expression, but you can achieve this by a wrapper function like this:

func set_anything(variable, property:String, val):
	if typeof(variable) == TYPE_VECTOR2:
		if property == "x":
			variable.x = val
		elif property == "y":
			variable.y = val
	return variable

now, you can change a vector2's property by

# a is a sprite2d
current.a.set("position", current.set_anything(current.a.position, "x", 100))

this is indeed inconvenient, need more work on command parser in the future work.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@eldegende
Comment options

Answer selected by eldegende
Comment options

You must be logged in to vote
1 reply
@pewcworrell
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Feature✨ New feature or request Improvement✒
3 participants