AI path "Zones"

Discussion in 'Ideas and Suggestions' started by krallopian, Feb 28, 2019.

  1. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    Ahhhhhhhhhh. Do not save after packing the prefab, the prefab is made in the level, but saved as a separate thing outside of the level, so once you've packed it, I guess you should just quit the level and reload it if you want to edit it further. This makes sense then, "PACK" really doesn't mean GROUP it means, "write a file saying what to load into this level" and UNPACK means, "Now import all of the stuff into this level where it should be." Tricky tricky. Off topic sry =D
    --- Post updated ---
    Yeah triggering slomo shouldn't be an issue I've seen it mentioned many times. Also certainly can trigger left or right blinkers, I popped a video in here just up a few posts showing a car using it's blinker as per the lua I've also posted =)
     
    • Like Like x 1
  2. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    Yes just looked at the video, wow all the stuff that can be done with this. so great work again :)
    --- Post updated ---
    Have you tried a trigger inside a bigger trigger, do that work? Or do they cancel each other out.
     
    • Like Like x 1
  3. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    Yah they work np =)
     
    • Like Like x 1
  4. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    I`m having some trouble with the blinker code, can it be made to be on as long as I am inside the trigger box? or can it just be turned on and blink on a timer, then turn of by it self, it seems like that is how it works now. :)
     
  5. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    As for possibilities.. I'm hoping someone makes a rolling drag strip. Ai rolls at 30 or 50 to the line then floors it. You just have to match it. Or you have two way.. Four way.. Ai races! All possible. Even with honk.. Honk.. honk.. GO
    --- Post updated ---
    with my blinker code it will blink while you are in the trigger zone. Toggles on when you enter and toggles off when you exit.
     
  6. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    what trigger mode do you use?
     
  7. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    Three default works best!

    Box.. Middle.. Corners.

    Can't remember really though. I'm in bed trying to get an early night for the first time this year haha! I'll get back as soon as possible though! =)
    --- Post updated ---
    *the default
     
  8. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    when I drive into the box, it turns on then off, and on again when I leave the box
     
  9. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    Is the box duplicated?
     
  10. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    Okay, we can try again tomorrow :)
    --- Post updated ---
    yes
     
  11. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    Make a default lua trigger. In the lua field just put:

    Code:
    local function flashLeft(tdata)
    be:getObjectByID(tdata.subjectID):queueLuaCommand('electrics.toggle_left_signal(1)')
    end
    flashLeft
    That will trigger when you enter and when you exit.
    --- Post updated ---
    There's no need to have the blinker triggered twice in the same spot. . only need one.
     
  12. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    Do I have a to big trigger box?
     
  13. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    The blinker will only be on while you are within the box. So if it's two feet long it won't be on long compared to 200feet long.
     
  14. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    I will upload a video :)
    --- Post updated ---
    This is what happens
     
  15. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    Ahhh sleep's overrated! Hopefully I'm catching you when you're still up:

    Watching that video I can't see any reason why it would do that based on my experience. Here's a shot of the size of my trigger box and it works flawlessly with 1 or 8 cars:
    --- Post updated ---
    Just to be sure, I've made it WAY bigger and still. . no issue!

    The only thing I can say is that you have yours somehow duplicated in the same spot. Or that you have two "toggle_xxx_signal" triggers within the same space, and that would do what you're seeing. I have no idea otherwise, it isn't programmed to do that and it can't do it on its own!?
    --- Post updated ---
    Watching it a few more times, maybe just MAYBE it's not low enough down? So as the car dips down off the pavement it's "center" leaves the zone and thus triggers to turn off and since the default tick rate is 100, there isn't enough time to catch it coming back up into the trigger to turn on again MEANING: Try running that same scenario in your video, but in slow motion, I'm betting it will be different.
    --- Post updated ---
    A problem I've found with this is that when you use the ETK or other similar car that has "emergency stop" 4-ways, they will interfere. If you enter the trigger it turns on your blinker, then you leave, it turns it off. BUT if you're in it with your blinker on and slam on the brakes and the 4-ways come on, now your blinker is no longer actually on, so when you LEAVE it triggers it back on. WHICH brings me back to, "not a very clean way of doing this" so hopefully I can figure out how to get the car to say, "set left blinker to activate, then activate while in trigger, and set left blinker to deactivate if already activated when leaving" and so far the code hasn't worked for that.
    --- Post updated ---
    Oh man this code is hurting my damn head, I HATE "not" in programming:

    Code:
    local function toggle_left_signal(tdata)
      if not signalWarnState then
        signalLeftState = not signalLeftState
      else
        signalLeftState = true
      end
      if signalLeftState then
        signalRightState = false
        signalWarnState = false
        sounds.playSound(indStartSnd)
        automatic_indicator_stop = manage_automatic_indicator_stop
      end
      if not signalLeftState then
        sounds.playSound(indStopSnd)
        automatic_indicator_stop = nop
      end
    end
    In English that reads: "If signalWarnState isn't SignalWarnState then signalLeftState is now no longer signalLeftState otherwise signalLeftState is now true. Now, if signalLeftState is true then that means that both signalRightState and signalWarState aren't true so now play the indicator flash sound. Now if signalLeftState isn't signalLeftState anymore then play the sound of it stopping, and set automatic_indicator_stop to "nop" and that's it.

    . . .

    So what I gather from that is, "if the 4-ways aren't on then change the left blinker state from what it was to the opposite (like a toggle(this is saying, "I don't care if it was on or off, just change it from what it was to the opposite either on or off because someone said "blinkerLeft")) otherwise the signalLeftState is now true. So now if the signalLeftState . . . . WHAT. . then make it so the 4ways and right blinker aren't on. The rest is where I need to keep looking but it seems that, "automatic_indicator_stop" can either be "manage_automatic_indicator_stop" OR "nop" which I guess would be the routine for running the blink sequence or not.

    I hate that this is more complicated than it needs to be in my head. I'd love to see, "If you press blink left and left is already on, then turn it off, otherwise blink it and set the left blinker and 4ways to off as well."
    --- Post updated ---
    **AHAH!**

    I've discovered why your blinker is turning off. It's because the steering wheel has turned. Just like a real car, the programming says, "If you've turned the wheel away from your blinker direction, disengage the blinker." Hahaha uh yi yi something so simple. It's a feature not a bug. So you are setting the left blinker on, then steering, then unsteering, which turns off the blinker. @Crash Hard 01
    --- Post updated ---
    Giving this more thought now I realize, the blinker trigger box only needs to be small enough to trigger the toggle. The blinker will turn off once you've finished the turn. So if you make it simply say "on enter toggle blinker" then it will turn off naturally once you've either steered and returned to center, or if you've counter steered! This whole time I've been worried about setting the blinker STATE to on or off, when really I just need to toggle it regardless because it has an "auto off" feature!!

    Well then.
    --- Post updated ---
    So here's the code to make it work as it should:

    Code:
    local function blinky(kdata)
    if kdata.event == 'enter' and kdata.triggerName == 'blinkRight1' then
    be:getObjectByID(kdata.subjectID):queueLuaCommand('electrics.toggle_right_signal()')
    end
    end
    blink
    The ONLY thing to add to this is that now you need to name your trigger. In this case the trigger is called, 'blinkRight1" so each trigger will have to have customized names and code, but. . . so what =D

    Case. Closed.
    --- Post updated ---
    Alright well I've found that the blinker doesn't ALWAYS turn off well enough, so I had to figure out how to turn it off. Basically if you want to use the blinker to shift lanes, it won't automatically turn off because there wasn't enough steering input.

    There are a couple options here.

    1.) Place one trigger with this code to turn the blinker one when you hit the trigger named "blinkRight1" in this case:

    Code:
    local function blinky(kdata)
    if kdata.event == 'enter' and kdata.triggerName == 'blinkRight1' then
    be:getObjectByID(kdata.subjectID):queueLuaCommand('electrics.toggle_right_signal()')
    end
    end
    blinky
    Then place another trigger where you want the blinker to stop and use this code with a trigger named "blinkRight1Stop":

    Code:
    local function blinky(kdata)
    if kdata.event == 'enter' and kdata.triggerName == 'blinkRight1Stop' then
    be:getObjectByID(kdata.subjectID):queueLuaCommand('electrics.set_warn_signal(0)')
    end
    end
    blinky


    2.) Make one large box as I had originally planned and have an "on enter" and "on exit" on a trigger in this case called "blinkRight1" as follows:


    Code:
    local function blinky(kdata)
    if kdata.event == 'enter' and kdata.triggerName == 'blinkRight1' then
    be:getObjectByID(kdata.subjectID):queueLuaCommand('electrics.toggle_right_signal()')
    end
    if kdata.event == 'exit' and kdata.triggerName == 'blinkRight1' then
    be:getObjectByID(kdata.subjectID):queueLuaCommand('electrics.set_warn_signal(0)')
    end
    end
    blinky
    


    And there we have it! Want left blinker, just change right to left. Tested and works great!
    --- Post updated ---
    Also, regarding about your slowmotion question just use, "bullettime.set(valueGoesHere)" so for instance in this code, when you enter the trigger named 'horny4' it will honk the horn, and go into 5x slow motion, then when you leave it will stop honking the horn and set simulation speed back to normal! =)


    Code:
    local function honkHonk(data)
    if data.event == 'enter' and data.triggerName == 'horny4' then
    be:getObjectByID(data.subjectID):queueLuaCommand('electrics.horn(1);bullettime.set(5)')
    end
    if data.event == 'exit' and data.triggerName == 'horny4' then
    be:getObjectByID(data.subjectID):queueLuaCommand('electrics.horn(horn);bullettime.set(1) ')
    end
    end
     honkHonk
     

    Attached Files:

    • workingBlinks.jpg
    • blinksWorking2.jpg
    • Like Like x 1
  16. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    I can not get this to work at all.
    Code:
    local function blinky(kdata)
    if kdata.event == 'enter' and kdata.triggerName == 'blinkRight1' then
    be:getObjectByID(kdata.subjectID):queueLuaCommand('electrics.toggle_right_signal()')
    end
    if kdata.event == 'exit' and kdata.triggerName == 'blinkRight1' then
    be:getObjectByID(kdata.subjectID):queueLuaCommand('electrics.set_warn_signal(0)')
    end
    end
    blinky
     
    • Like Like x 1
  17. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    Did you make the trigger correctly?
    --- Post updated ---
    Sorry stupid phone. I meant NAME it correctly.
    --- Post updated ---
    I only tested that with the etk and marauder, though that shouldn't matter :)
     
    • Like Like x 1
  18. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    hehe, no i did not :p It works now, thank you :)
     
    • Like Like x 1
  19. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    789
    Np man, super stoked about this stuff! Have fun =)
     
    • Like Like x 1
  20. CrashHard

    CrashHard
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    1,579
    Yes me to, :D
    If you want to look into some more stuff, I have something for you :)
    Breaking breakgroups with triggers (like a bumper or door falling off when driving into the trigger :D
     
  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