1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice
  3. Before reporting issues or bugs, please check the up-to-date Bug Reporting Thread for the current version.
    0.30 Bug Reporting thread
    Solutions and more information may already be available.

How would I make sparks come from a vehicle with lua?

Discussion in 'Troubleshooting: Bugs, Questions and Support' started by IAchievedBacon, Jun 3, 2018.

  1. IAchievedBacon

    IAchievedBacon
    Expand Collapse

    Joined:
    Jul 3, 2017
    Messages:
    2,821
    I am wanting to learn more and more about modding in this game but I just need help. I am trying to have sparks with a toggle button for a special skin for the CRD. I was wondering if there is a tutorial or something that can help.
     
  2. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    Code:
    obj:addParticleByNodes(node1, node2, particle_velocity, particle_id, particle_width, particle_number)
    node1 : Id of the first node
    node2 : id of the last node (where the particle will exit)
    particle_velocity: speed of the particle (can be -1)
    particle_id : particle_id (the spark is 1)
    particle_width: how much they randomly spread apart
    particle_number: how many you spawn in one call

    I do suggest you have a look at the jato controller in the citybus to know how to have parameters in jbeam,
     
    • Informative Informative x 2
  3. IAchievedBacon

    IAchievedBacon
    Expand Collapse

    Joined:
    Jul 3, 2017
    Messages:
    2,821
    Would I need to know jbeam too?
     
  4. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    yes, but it's really basic stuff.
    You would need only to declare one new skin and this skin will specify a controller to load (your script that will make sparkles)
     
    • Like Like x 1
    • Agree Agree x 1
  5. IAchievedBacon

    IAchievedBacon
    Expand Collapse

    Joined:
    Jul 3, 2017
    Messages:
    2,821
    How would I do the lua? Like set it up?
     
  6. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    722
    So you need to create a lua file here /vehicles/CRD/lua/controller/fireworkCRD.lua (path may not be correct because of vehicle name)

    This is a template for the lua file
    Code:
    local M = {}
    M.type = "auxilliary"
    M.relevantDevice = nil
    M.defaultOrder = 1000
    
    local function updateGFX(dt)
      --spawn the particle here
    end
    
    local function init(jbeamData)
      -- you will get some parameters to save here
    end
    
    M.init = init
    M.initSecondStage = initSecondStage
    M.reset = reset
    M.updateGFX = updateGFX
    
    return M
    
    this code is untested !! May have some error to fix (like missing init2 and reset )

    this what you need to add to the jbeam part that define your skin
    Code:
        "controller": [
            ["fileName"],
            ["fireworkCRD"],
        ],
      "fireworkCRD": {
        "fireworks":[
          ["node1","node2"
         ],
      },
    
     
    • Like Like x 1
  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