random background

  • #1, by CamouflageMonday, 22. June 2015, 12:08 5 years ago
    Hi, I want to have one of x backgrounds randomly selected and displayed when I'm in the scene. I got a cockpit and i don't want always the same weather (background) when I'm in the scene ... It's my first project with visionaire studio, so i don't have a clue yet. I would really appreciate it if someone could help me.

    Newbie

    15 Posts


  • #2, by SimonSMonday, 22. June 2015, 12:12 5 years ago
    Hi, use an object for each of the backgrounds and change conditions of the accordingly. You can also change the background via Lua, but that's more difficult.

    Thread Captain

    1369 Posts

  • #3, by CamouflageMonday, 22. June 2015, 13:00 5 years ago
    The images are in the foreground, when I use an object for each of the images.. additionally I have to script somehow, so always one image is shown randomly. But I don't know how to set up these things in the first place. Like i said, I'm really a visionaire newbie. :/

    Edit: fixed the foreground problem.

    Newbie

    15 Posts

  • #4, by sebastianMonday, 22. June 2015, 14:00 5 years ago
    create an object for each Background. sort them to be at the most bottom in the objects list of the scene. set the object center if the bg objects high so that all other (normal) objects and characters are above the bg objects.

    define for every bg object a condition.

    on scene enter randomize a variable and for each output set a condition to true and the others to false

    Thread Captain

    2337 Posts

  • #5, by CamouflageMonday, 22. June 2015, 15:05 5 years ago
    first of all thx for the tipps. I did the first part. I understand the logic from the last part, but i don't know how i set images visible or invisible.
    I didn't find a good lua manual yet.. and setting only the condition of the image to false has obviously no effect.
    - Edit: i guess i got it running, i forgot something in the options . smile
    - Edit²: Can someone tell me how to set up a script, that it starts when i press F9 (start the game) ?

    Newbie

    15 Posts

  • #6, by sebastianMonday, 22. June 2015, 16:12 5 years ago
    you can define a start"script" in the game options tab. It runs all the actions you defined there at the beginning

    Thread Captain

    2337 Posts

  • #7, by CamouflageMonday, 22. June 2015, 17:04 5 years ago
    I created a script and then added a new action, where i say when the scene starts the script starts too. i just told the test script that the condition is false, so i don't see the background anymore. it isn't working..

    Newbie

    15 Posts

  • #8, by sebastianMonday, 22. June 2015, 17:37 5 years ago
    you can set the conditions initial state directly in the condition itself.
    just call the "change condition" when needed and set 1 condition to true and the others to false

    Thread Captain

    2337 Posts

  • #9, by CamouflageSunday, 28. June 2015, 17:16 5 years ago
    its somehow not working.. i always see the same background
    Edit: or the background changes to a black one...

    Newbie

    15 Posts

  • #10, by CamouflageSunday, 28. June 2015, 18:31 5 years ago
    got it. looks like using else is necessary

    Newbie

    15 Posts

  • #11, by afrlmeSunday, 28. June 2015, 20:16 5 years ago
    Yep otherwise it will iterate through the entire block line by line & if you change the value in previous block then it might end up triggering value of next block if value is same as whatever you just changed it to.

    P.S: you need to close off the if queries with end if action parts. There should be the same amount of end if as there are if. Where you put the end if action parts depends on the query. In this case you need to add them all to the end of the query.

    Imperator

    6842 Posts

Write post