What's the best way to create options in scenarios?

Discussion in 'Programming' started by Gamergull, Nov 24, 2018.

  1. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    Question in title. I love coding custom Lua scenarios, and I was thinking about improving the player experience by allowing them to change variables in my scenarios. For example, I want the player to enable or disable the tracking beacons in my Catch Them All scenarios. I've been trying to wrap my head around methods I can use to do this. Here's what I have in my WIP test scenario:

    partconfig-help.jpg

    The player can drive into the race markers to switch the scenario between Race and Chase modes. It works great (and it's quite fun), but I feel that it's too clunky to use in a proper scenario.

    I've also been reading up on input actions, but I can't figure them out; I had no success in getting key presses to change anything in my scenario. I would like to use this idea, though.

    Perhaps I could make a little UI app, but I've never done that before. I could try.

    Thoughts?
     
  2. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    I guess I'm answering my own thread. Here's a nifty way to do it!

    be:getPlayerVehicle(0):queueLuaCommand("obj:queueGameEngineLua('eventHorn = ('..electrics.values.horn..')')")
    if eventHorn == 1 then

    core_environment.setTimeOfDay({time = 0.5})
    end

    This creates a global variable called "eventHorn" with a value of 0 (horn off) or 1 (horn on). You can use this in an onRaceTick() function. In this case, honk your horn to change the time of day in the scenario. You can make it do whatever you want. I think that headlights and blinkers can also be used for pseudo options. Clever, eh?
     
    • Like Like x 1
  3. fufsgfen

    fufsgfen
    Expand Collapse

    Joined:
    Jan 10, 2017
    Messages:
    6,782
    Hmm, that jolts my memory about this, maybe you can find some use for this?
    https://wiki.beamng.com/Modding_input_bindings
     
  4. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    I tried that before, I couldn't figure it out. But maybe I was feeling dumb, I'll play around with it soon.
     
  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