Announcement

Collapse
No announcement yet.

Why This code is not working??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why This code is not working??

    Why tf is my code not working for the current playing audio??
    Code:
    ca = ComboBox.GetSelected("ComboBox1")
    
    if ca == 1 then
    -- DO NOTHING
    elseif ca == 2 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 20)
    elseif ca == 3 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 50)
    elseif ca == 4 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 70)
    elseif ca == 5 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 90)
    elseif ca == 6 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 120)
    elseif ca == 7 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 150)
    elseif ca == 8 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 180)
    elseif ca == 9 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 210)
    elseif ca == 10 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 235)
    elseif ca == 11 then
    Audio.SetVolume(CHANNEL_BACKGROUND, 255)
    end

  • #2
    Assuming there's at least 11 items in your ComboBox, then it works just fine, as is.

    But there's better, less repetitious ways to do the same thing.
    Try this instead:

    Code:
    tCA = {
        "",
        "20",
        "50",
        "70",
        "90",
        "120",
        "150",
        "180",
        "210",
        "235",
        "255"
    };
    
    nIndex = ComboBox.GetSelected("ComboBox1");
    
    for k,v in pairs (tCA) do
        if nIndex == 1 then
        -- do nothing
        else
            if nIndex == k then
                Audio.SetVolume(CHANNEL_BACKGROUND, v);
            end
        end
    end

    Comment


    • #3
      Originally posted by BioHazard View Post
      Assuming there's at least 11 items in your ComboBox, then it works just fine, as is.

      But there's better, less repetitious ways to do the same thing.
      Try this instead:

      Code:
      tCA = {
      "",
      "20",
      "50",
      "70",
      "90",
      "120",
      "150",
      "180",
      "210",
      "235",
      "255"
      };
      
      nIndex = ComboBox.GetSelected("ComboBox1");
      
      for k,v in pairs (tCA) do
      if nIndex == 1 then
      -- do nothing
      else
      if nIndex == k then
      Audio.SetVolume(CHANNEL_BACKGROUND, v);
      end
      end
      end
      sry still not workin, but thanks for gettin touched with my posts

      Comment


      • #4
        Works perfectly. Test your code properly.
        Apz Demo is attached.

        Demo tested in:
        AMS v8.0.5.0
        AMS v8.5.0.0
        AMS v8.5.2.0

        All working, no problemo.

        Nb. There's a known bug with the ComboBox in some of the earlier builds of AMS v8.0.0.0 thru 8.3.0.0
        Try a different version, if you're still having trouble.
        Attached Files

        Comment


        • #5
          working on my test..

          Comment


          • #6
            Originally posted by BioHazard View Post
            Works perfectly. Test your code properly.
            Apz Demo is attached.

            Demo tested in:
            AMS v8.0.5.0
            AMS v8.5.0.0
            AMS v8.5.2.0

            All working, no problemo.

            Nb. There's a known bug with the ComboBox in some of the earlier builds of AMS v8.0.0.0 thru 8.3.0.0
            Try a different version, if you're still having trouble.
            Thanks Fussy but there's sumthin Wierd?? , it works on your project but when i add it to my project nuthing happens??

            Comment


            • #7
              So upload the .apz file. Can't debug code I can't see.

              Comment

              Working...
              X