Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Matthew Hazlett |
I am new so forgive me if this is a silly question.
I created a tool in a tscn file with an exposed property called SpriteIndex. I created a setter that updates the sprites frame property in the editor. It works, but whenever I save my project it gives me the error (times the number of tiles I have)
res://Tiles.gd:14 - Invalid set index ‘frame’ (on base: ‘Nil’) with value of type ‘int’.
(Line 14 is sprite.frame = value)
The code I have is very simple:
tool
extends StaticBody2D
export(int) var SpriteIndex setget setNdx
onready var sprite = $Spritefunc _ready():
sprite.frame = SpriteIndexfunc setNdx(value):
SpriteIndex = value
if Engine.editor_hint:
sprite.frame = value
Can anyone tell me what the error is and how to get rid of the error?
It works in the editor and when I launch the project.