0 votes

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?

in Engine by (65 points)

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.

1 Answer

0 votes

No it is not possible or any other workarounds.

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

by (5,020 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.