Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

L's Sound Macros And SugarCube - Play Sound On Click (Solved)

edited July 2014 in Help! with 1.x
So I've managed to get L's Sound Macros working with SugarCube, and even got the local files to play from another directory. Bellow is my StoryInit Passage.
<<set $Sounds = {
Map: {Open: 0, Close: 0},
Lighter: {Open: 0, Close: 0, Strike: 0},

}>>

<<set $Sounds.Lighter.Open = "Data/Audio/LighterOpen.wav"; $Sounds.Lighter.Close = "Data/Audio/LighterClose.wav"; $Sounds.Lighter.Strike = "Data/Audio/LighterStrike.wav">>
Using <<playsound $Sounds.Lighter.Open>> works fine, but the thing that I want to be able to do is play a sound once after hitting a link like so -
[[Open Lighter|Audio Test][playsound $Sounds.Lighter.Open; $Lighter = "Open"]]
If L's macro just wasn't coded to do this, then is there a possible work around to achieve the same effect? If not then what am I doing wrong? (I'm using SugarCube v0.9.9)

Comments

  • You cannot call macros like that.  While it is possible to call macros via a setter link, depending on the macro, it is generally not recommended to call macros "raw" like that (some macros you can get away with simply calling their handler, others require significant parameter setup).

    In this case, since you're using SugarCube, you can simply use the &lt;&lt;click&gt;&gt; macro.  Try this:

    <<click "Open Lighter" "Audio Test">><<set $Lighter to "Open">><<playsound $Sounds.Lighter.Open>><</click>>

    Also.  There shouldn't be a need to have your initialization separated as you've shown.  You can populate the objects with your sound files in one go.  For example:

    <<set
    $Sounds = {
    Map : {
    Open : "",
    Close : ""
    },
    Lighter : {
    Open : "Data/Audio/LighterOpen.wav",
    Close : "Data/Audio/LighterClose.wav",
    Strike : "Data/Audio/LighterStrike.wav"
    }
    }
    >>
  • TheMadExile wrote:

    You cannot call macros like that.  While it is possible to call macros via a setter link, depending on the macro, it is generally not recommended to call macros "raw" like that (some macros you can get away with simply calling their handler, others require significant parameter setup).

    In this case, since you're using SugarCube, you can simply use the &lt;&lt;click&gt;&gt; macro.  Try this:

    <<click "Open Lighter" "Audio Test">><<set $Lighter to "Open">><<playsound $Sounds.Lighter.Open>><</click>>

    Also.  There shouldn't be a need to have your initialization separated as you've shown.  You can populate the objects with your sound files in one go.  For example:

    <<set
    $Sounds = {
    Map : {
    Open : "",
    Close : ""
    },
    Lighter : {
    Open : "Data/Audio/LighterOpen.wav",
    Close : "Data/Audio/LighterClose.wav",
    Strike : "Data/Audio/LighterStrike.wav"
    }
    }
    >>

    I feel so stupid now, I have no clue why I didn't just use the click macro. Thanks again Exile. :)
Sign In or Register to comment.