Attention | Topic was automatically imported from the old Question2Answer platform. | |
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