• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Playing a sound from a GUI-created string variable?

Status
Not open for further replies.
Level 10
Joined
May 31, 2019
Messages
139
I'm able to play a sound with the JASS PlaySound function just fine. but i want to be able to pass it a GUI string variable. I tried passing it udg_mySoundString instead of "the\\sound\\filename.wav" but it doesn't seem to work. I don't want to use the SoundEditor since i'll have multiple maps and don't want to add the same sounds for each one.

At Elapsed GameTime = 0.00 i run
Code:
call Preload(udg_mySoundString)
but it doesn't seem to help.
The variable is not surrounded by ""s.
 
Last edited:
Level 4
Joined
Jun 28, 2012
Messages
23
Can you link your map ? Or atleast the code.

vJASS:
private function onInit takes nothing returns nothing
    set udg_mySoundString ="the\\sound\\filename.wav"
    call PlaySound(udg_mySoundString)
endfunction
Should work 🤔
 
Level 10
Joined
May 31, 2019
Messages
139
Huh, that DOES work.
I wonder what the difference is then, between setting the variable in jass and with the Set mySoundString = the\\sound\\filename.wav GUI action?
I did both a GUI and JASS text message to check, and sure enough string set by the GUI action displays the proper file path.
 
Last edited:
Status
Not open for further replies.
Top