Constant placeholder for constant string in preload()

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lebostein

For example I preload my footstep sounds in a dictionairy to pick them randomly from the list depending on the ground:

onready var stepsounds = {
	"wood":[
		preload("res://data/sounds/steps/step_wood_1.ogg"),
		preload("res://data/sounds/steps/step_wood_2.ogg"),
		preload("res://data/sounds/steps/step_wood_3.ogg"),
		preload("res://data/sounds/steps/step_wood_4.ogg"),
		preload("res://data/sounds/steps/step_wood_5.ogg"),
		preload("res://data/sounds/steps/step_wood_6.ogg"),
	],
	"stone":[
		preload("res://data/sounds/steps/step_stone_1.ogg"),
		preload("res://data/sounds/steps/step_stone_2.ogg"),
		preload("res://data/sounds/steps/step_stone_3.ogg"),
		preload("res://data/sounds/steps/step_stone_4.ogg"),
		preload("res://data/sounds/steps/step_stone_5.ogg"),
		preload("res://data/sounds/steps/step_stone_6.ogg"),
	],
	.... and so on....
}

it is possible to replace the string part "“res://data/sounds/steps/” with a constant placeholder?

It’s possible with load() but not preload(). You can drag and drop an item from the file system tab of your editor into your code window to give you the path to that item as text, if that improves your workflow at all.

timothybrentwood | 2021-09-24 19:06

:bust_in_silhouette: Reply From: Wakatta

No it is not possible or any other workarounds.

Accepting this fact now will save you time and a mental breakdown.