Menu
Login
Language
DE EN FR ES IT CZ
Back

Audio files are not added into build standalone game

  • #1, by vanyanie Saturday, 02. January 2021, 14:55 5 years ago Quote
    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 SimonS Saturday, 02. January 2021, 14:57 5 years ago Quote
    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

    1622 Posts

  • #3, by vanyanie Saturday, 02. January 2021, 15:36 5 years ago Quote
    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 SimonS Saturday, 02. January 2021, 15:40 5 years ago Quote
    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

    1622 Posts

  • #5, by vanyanie Saturday, 02. January 2021, 17:08 5 years ago Quote
    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 sebastian Monday, 04. January 2021, 03:37 5 years ago Quote
    cant the table be built up dynamically as well? 

    Thread Captain

    2346 Posts