Unsolved Lua Function Question

Discussion in 'Mod Support' started by Occam's Razer, Sep 21, 2017.

  1. Occam's Razer

    Occam's Razer
    Expand Collapse

    Joined:
    Aug 7, 2013
    Messages:
    1,152
    Not too long ago I released a small scenario pack called "Cops and Robbers: Maple Leaf Credit Union." The car chase in the second scenario has a police car that uses a detection loop to allow the robber to lose, and to re-engage, the police.

    So, here's the issue: I want to add a second police car to the chase, but don't want to just duplicate all of the code I've written for the first. The detection loop, as well as the crash detector and respawn system, use functions in order to operate and can be assigned to either car, but it seems that I can only use any given function once within a particular frame, pretty well defeating the purpose. Alternating between one car using the function and the other doesn't seem to pan out.

    Attached is the current release version of the Lua file. I can provide any clarification if needed.
     

    Attached Files:

  2. meywue

    meywue
    Expand Collapse
    Administrator
    BeamNG Team

    Joined:
    Nov 19, 2015
    Messages:
    340
    Hey,

    can you provide us the modified lua file either here or in a pm so we can have a closer look at it?! :)
     
  3. Occam's Razer

    Occam's Razer
    Expand Collapse

    Joined:
    Aug 7, 2013
    Messages:
    1,152
    It seems I've lost some of the older working versions, so this will probably have to do. It's basically just the same script, but with the updatePolice() function run twice each frame to refer to both police cars. Obviously it wouldn't work for the timer-based stuff, since those are the same variable between the two vehicles, so those would need further modification.
     

    Attached Files:

  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