What I’m trying to do is make it so that when I add this scene to a tree, it picks a random texture from an array. So far, I haven’t been able to even get it to select from the array. What am I doing wrong?
Here’s the code:
extends Node2D
var sweet_berries = “res://sweet-berries-sprite.jpg”
var bread = “res://bread-sprite.jpg”
var orders = Array([sweet_berries, bread])
func _ready():
var current_order = orders.pickrandom()
if current_order == sweet_berries:
print(“Sweet Berries have been ordered!”)
if current_order == bread:
print(“Bread has been ordered!”)
You could potentially put a lot more information in the dictionaries nested in orders, enough that you could just call a single generic function instead of having the per-entry specific functions.