Unsolved Variable with other text

Discussion in 'Mod Support' started by TC203, May 8, 2021.

  1. TC203

    TC203
    Expand Collapse

    Joined:
    Sep 9, 2020
    Messages:
    133
    Code:
        ],
        "soundscape": [
            ["name", "src"],
            ["siren", "radio/1.ogg"],
    Does anyone know how to replace the "1" with a variable so I can select between multiple tracks?
     
  2. S.Ali.M

    S.Ali.M
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    1,079
    It depends on your mod. If your siren are selectable, just write several parts.
    Like this:
    Code:
    "X1":{
    ...
    ...
    ...
    "soundscape": [
            ["name", "src"],
            ["siren", "radio/1.ogg"],
    ...
    ...
    },
    "X2":{
    ...
    ...
    ...
    "soundscape": [
            ["name", "src"],
            ["siren", "radio/2.ogg"],
    ...
    ...
    },
    "X3":{
    ...
    ...
    ...
    "soundscape": [
            ["name", "src"],
            ["siren", "radio/3.ogg"],
    ...
    ...
    },
    "X4":{
    ...
    ...
    ...
    "soundscape": [
            ["name", "src"],
            ["siren", "radio/4.ogg"],
    ...
    ...
    },
    
    But if your sirens aren't selectable, I recommended you to write your these codes in your:
    In the jbeam:
    Code:
    "soundscape": [
    ["name", "src"],
    ["siren", "radio/1.ogg"],
    ["siren", "radio/2.ogg"],
    ["siren", "radio/3.ogg"],
    ["siren", "radio/4.ogg"],
    And in your lua:
    Code:
    local siren1 = nil
    local siren2 = nil
    local siren3 = nil
    local siren4 = nil
    local function onInit()
        siren1 = siren1 or sounds.createSoundscapeSound("siren1")
        siren2 = siren2 or sounds.createSoundscapeSound("siren2")
        siren3 = siren3 or sounds.createSoundscapeSound("siren3")
        siren4 = siren4 or sounds.createSoundscapeSound("siren4")
    --- Post updated ---
    If you do it, you'll have several tracks and you can use them
     
  3. TC203

    TC203
    Expand Collapse

    Joined:
    Sep 9, 2020
    Messages:
    133
    I don't have a lua file, I would make one but I don't know the code. I'm just using the soundscape with the default lightbar function. Can I not use variables then?
     
  4. S.Ali.M

    S.Ali.M
    Expand Collapse

    Joined:
    Jan 12, 2021
    Messages:
    1,079
    Try something like this in .jbeam file. It will make several parts in a slot.
    Code:
    "X1":{
    
    ...
    ...
    ...
    "soundscape": [
           ["name", "src"],
           ["siren", "radio/1.ogg"],
    ...
    ...
    },
    "X2":{
    ...
    ...
    ...
    "soundscape": [
           ["name", "src"],
           ["siren", "radio/2.ogg"],
    ...
    ...
    },
    "X3":{
    ...
    ...
    ...
    "soundscape": [
           ["name", "src"],
           ["siren", "radio/3.ogg"],
    ...
    ...
    },
    "X4":{
    ...
    ...
    ...
    "soundscape": [
           ["name", "src"],
           ["siren", "radio/4.ogg"],
    ...
    ...
    },
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice