I've been using Godot for 48 hours, so to say I'm a newbie is an understatement. . .
Trying to make a simple application that randomly generates 3 planets. I have 3 sprites on the viewport called Planet0, Planet1, and Planet2. They are duplicated, not instanced. I want to randomly generate each planet's type and change the texture of the sprite accordingly. Here's the code I'm using, which is on the parent node all 3 sprites share:
var MapFertile = preload("../Planets/Fertile.png")
var MapBarren = preload("../Planets/Barren.png")
var Planets = ["Barren", "Barren", "Fertile"]
var Length = Planets.size()-1
for i in range(3):
var Ref = round(rand_range(0, Length))
var Planet = Planets[Ref]
var PlanetPic = str("Map",Planet)
var PlanetRef = "Planet" + str(i)
The error message I get is:
"Invalid type in function 'set_texture' in base 'Sprite'. Cannot convert argument 1 from String to Object."
The code works if I replace the last line with:
But then of course all 3 will be the same texture and it defeats the point.
Please help a poor soul who hasn't learned a new language since Actionscript 2. . .