Hey there,
I'm using Godot3.1 Beta3. I have a "Loot" object that can be either a folder or a suitcase. I created a function to change the loot sprite on ready based on a exported variable and it works fine but I can only see the selected sprite when the game runs.
To "fix" that, I tried using the keyword tool
at the top of the script, here is the code:
tool
extends Area2D
var player
export(String, "Folder", "Suitcase") var type = "Folder" setget set_loot_type
func _ready():
if not Engine.is_editor_hint():
player = Global.player
#Sets the sprite and collision shape
func set_loot_type(type):
if type == "Folder":
$Sprite.texture = load("res://images/png/Loot/folder.png")
$Sprite.scale = Vector2(0.3, 0.3)
$Collision.shape = CircleShape2D.new()
$Collision.shape.radius = 30
if type == "Suitcase":
$Sprite.texture = load("res://images/png/Loot/suitcase.png")
$Sprite.scale = Vector2(0.3, 0.3)
$Collision.shape = CircleShape2D.new()
$Collision.shape.radius = 30
#Signal body entered
func collected(body):
if not Engine.is_editor_hint():
queue_free()
player.collect_loot(type)
After I added the tool
keyword, even after restarting the editor, when I change the variable on the editor, it does not change (see it here: https://youtu.be/VWOqgzgBNqY).
If I delete the keyword tool
, it works just fine.