Audio files are not added into build standalone game

  • #1, by vanyanieSaturday, 02. January 2021, 14:55 3 years ago
    My character has an action that calls a Lua script to play different footstep sounds on different areas:
    local v = getObject("Values[FootstepSound]"):getStr(VValueString)
    local r = math.random(1,5)
    startSound("vispath:sounds/steps/" .. v .. r .. ".ogg", {flags=1, volume=20})
    

    The audio files are in the folder "sounds/steps" in my project folder (see picture)

    It workes very well when starting my game within Visionaire but when I build my game the output says "Missing sound/steps" (see picture) and the footstep audios are not play in the standalone game.

    How to fix that?

    Newbie

    10 Posts


  • #2, by SimonSSaturday, 02. January 2021, 14:57 3 years ago
    Visionaire needs to now the files at build time, it can't runs these scripts and see what's coming out.

    So you need to have the paths like this:

    "vispath:sounds/steps/11.ogg", "vispath:sounds/steps/12.ogg", "vispath:sounds/steps/13.ogg"

    and select some of this table.

    Thread Captain

    1580 Posts

  • #3, by vanyanieSaturday, 02. January 2021, 15:36 3 years ago
    I understand the problem, but not how to fix it.  The script part

    "vispath:sounds/steps/" .. v .. r .. ".ogg"

    creates something like "sounds/steps/stone5.ogg"
    When I understand right, Visionare don't know the files bc it's not a fixed string, it's a string build on runtime. But how to tell VS there are files in folder x you need?

    What do you mean with "select some of this table"?

    Newbie

    10 Posts

  • #4, by SimonSSaturday, 02. January 2021, 15:40 3 years ago
    You need to build up a table with all options in advance. Example:

    local soundtable = {
      stone = {
         "vispath:sounds/steps/stone1.ogg",
         "vispath:sounds/steps/stone2.ogg" ,
         "vispath:sounds/steps/stone3.ogg" ,
         "vispath:sounds/steps/stone4.ogg"
      },
      wood {
         "vispath:sounds/steps/wood1.ogg",
         "vispath:sounds/steps/wood2.ogg" ,
         "vispath:sounds/steps/wood3.ogg" ,
         "vispath:sounds/steps/wood4.ogg"
      }
    }

    local v = getObject("Values[FootstepSound]"):getStr(VValueString)
    local r = math.random(1,5)
    startSound(soundtable[v][r], {flags=1, volume=20})

    Thread Captain

    1580 Posts

  • #5, by vanyanieSaturday, 02. January 2021, 17:08 3 years ago
    Ok, I wanted to avoid to work with a table like this but I see it's nessasary.
    Thank you, it workes.

    Newbie

    10 Posts

  • #6, by sebastianMonday, 04. January 2021, 03:37 3 years ago
    cant the table be built up dynamically as well? 

    Thread Captain

    2346 Posts