0 votes

Hello, I'm new to Godot

I have this dictionary in the MapTiles script:

const centerMaterials : Dictionary = {
"Empty": preload("res://Assets/MapTiles/empty/Center.material"),
"Blue": preload("res://Assets/MapTiles/blue/Center.material"),
"Green": preload("res://Assets/MapTiles/green/Center.material")

I define this function to change the material of a MeshInstance in another script:

func changeCenter(newCenter : str):
    $Circle.set_surface_material(1, MapTiles.centerMaterials[newCenter])

When in a third script I call this function:


I get the error: Expected a type for an argument

If I change func changeCenter(newCenter : str): to func changeCenter(newCenter): it works

Why is this happening?

Godot version 3.2.3
in Engine by (244 points)

1 Answer

+1 vote
Best answer

The signature of your function should be changeCenter(newCenter : String):. str is a function the returns a String, but the actual type is String.

If you struggle to find a type, you can use a default value to infer it from : changeCenter(newCenter := ""):.

by (2,634 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.