Outdated Waypoints (paths) for cars - v1.0.7

Discussion in 'Programming' started by Incognito, Aug 16, 2013.

  1. ZeroDexter

    ZeroDexter
    Expand Collapse

    Joined:
    Aug 16, 2013
    Messages:
    3
    Re: Waypoints (paths) for cars

    I made a quick test on the small island map, the path recording works great!

    Maybe we should start sharing waypoint files? :cool:

    Here's mine, if anyone wants it ;)
     

    Attached Files:

  2. mccartercar

    mccartercar
    Expand Collapse

    Joined:
    Aug 11, 2013
    Messages:
    47
    Re: Waypoints (paths) for cars

    Im receiving a fatal lua error.
     
  3. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: Waypoints (paths) for cars

    I'm not psychic and I cant find out what kind of error you got. Maybe, you can attach the screenshot?
     
  4. mccartercar

    mccartercar
    Expand Collapse

    Joined:
    Aug 11, 2013
    Messages:
    47
    Re: Waypoints (paths) for cars

    Sorry about that.
    It was a case problem.
     
  5. Dredastttarm

    Dredastttarm
    Expand Collapse

    Joined:
    Aug 24, 2013
    Messages:
    5
    Re: Waypoints (paths) for cars

    Your computer wizardry amazes me, keep up the good work. So if the bot misses a waypoint does it turn around and try to get to it? Also, I hope to see the advancement of this mod where eventually we can see races and cars reacting to others... :)
     
  6. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: Waypoints (paths) for cars

    Yes, but now I'm testing the skip point function. That is, if the bot missed the fifth point (for example, flew off the track) and him closer to go to the seventh point, then he will not go back to the fifth, and immediately run to the seventh point.
     
  7. mccartercar

    mccartercar
    Expand Collapse

    Joined:
    Aug 11, 2013
    Messages:
    47
    Re: Waypoints (paths) for cars

    I'm having fun challenging the AI to follow me along rough paths. They only occasionally have weird logic and go in circles. Great Fun. Thanks Incognito.
     
  8. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: Waypoints (paths) for cars

    Update (27.08.2013):
    • Added skipping points.
    • Fix to work with the latest version.
     
  9. Phoenixx

    Phoenixx
    Expand Collapse

    Joined:
    Aug 6, 2013
    Messages:
    8
    Re: Waypoints (paths) for cars

    Hi, this is pretty cool and I've been trying to get all the AI cars to start at the same time using the code below.

    I've got 2 AI cars id nos 1&2

    I've loaded the waypoints for AI no 1 then run the command wayPoints.runCars()

    I get the following error:

    Attempting to run all cars
    Attempting to run car 0
    Attempting to run car 1
    ERR fatal lua error: lua/system/waypoints.lua:483: attempt to index global 'CarCanRun' (a nil value)
    Stack Traceback
    ==========
    (2) lua field 'runCars' at file 'lua/system/waypoints.lua:483
    ^local variables
    ^ (for index) = number 1
    ^ (for limi <i'm guessing there should be something after this but nothing is printed

    What's wrong? - < Problem solved CanCarRun[carId] should be canCarRun[carId] - stupid case sensitive variables!

    Code:
    local function runCars()
        print("Attempting to run all cars")
        for carId = 0 , 2 do
            print("Attempting to run Car "..carId)
            if ( wayPoints[carId] ~= nil ) then
                CanCarRun[carId] = 1
                print("Car "..carId.." was run!")
            end
        end
    end
    
     
    #29 Phoenixx, Aug 31, 2013
    Last edited: Aug 31, 2013
  10. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: Waypoints (paths) for cars

    Your mistake: the use of an array CarCanRun, that is not declared. I assume you would need to use an array canCarRun.
    Cars can be more than three, so use a loop with a fixed number of steps is not very good.

    - - - Updated - - -

    So it will be better:
    Code:
    local function runCars()
        print("Attempting to run all cars")
        for key in pairs(wayPoints) do
            runCar(key)
        end
    end
     
  11. Phoenixx

    Phoenixx
    Expand Collapse

    Joined:
    Aug 6, 2013
    Messages:
    8
    Re: Waypoints (paths) for cars

    Awesome, that code is so much better, although I've no idea how the pairs command works!

    I wanted to make it so that I could load the waypoints for a level into all AI at the same time, then run them at the same time instead of doing it one at a time.

    Is there a way of finding out how many cars there are on a level and which one is the player?

    Thanks for the help.
     
  12. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: Waypoints (paths) for cars

    Roughly speaking, the "wayPoints" table - is a dictionary (key-value) where the key is the index of the vehicle.
    pairs() iterates over all keys (and indexes, as ipairs()) in a table.
     
  13. medion

    medion
    Expand Collapse

    Joined:
    Jan 27, 2013
    Messages:
    85
    Re: [WIP] Waypoints (paths) for cars

    what the hell is the carid for the grand marshall because when i try to do it i type wayPoints.addPoint(fullsize,20)
    and it does nothing i dont understand this
     
  14. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: [WIP] Waypoints (paths) for cars

    Attentively read documentation.
    Use wayPoints.printCurrentCarId() to get the current vehicle id.
     

    Attached Files:

    • qGVcUzVn.png
    • qGVcUzVp.png
  15. siebeiscool

    siebeiscool
    Expand Collapse

    Joined:
    Feb 3, 2013
    Messages:
    71
    Re: Waypoints (paths) for cars

    i need a bit of help.
    heres a video witch will explain everything.


    - - - Updated - - -

    u wanna turn up the volume tough.
    my mic was acting weird so its not very loud
     
    #35 siebeiscool, Aug 31, 2013
    Last edited by a moderator: Oct 21, 2015
  16. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: Waypoints (paths) for cars

    siebeiscool, this video is private.
     
  17. siebeiscool

    siebeiscool
    Expand Collapse

    Joined:
    Feb 3, 2013
    Messages:
    71
    Re: Waypoints (paths) for cars

    it is?
    let me change that sorry

    - - - Updated - - -

    fixed the video
     
  18. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: Waypoints (paths) for cars

    To save/load paths, need to specify just file name, no "game_folder/Waypoints/SomeWay". Just a:
    Code:
    wayPoints.loadWayPoints(1, "SomeWay")
    Where SomeWay - the name of the file that is in the game_folder/WayPoints .
     
  19. siebeiscool

    siebeiscool
    Expand Collapse

    Joined:
    Feb 3, 2013
    Messages:
    71
    Re: Waypoints (paths) for cars

    aaaaah ok thank yuo very much
     
  20. Eggtooth

    Eggtooth
    Expand Collapse

    Joined:
    Aug 6, 2013
    Messages:
    55
    Re: Waypoints (paths) for cars

    Does not work. When I try to record LUA in console there is a message that waypoints is a nil value. I've pasted evertyhing from Waypoints1.02 archive and still nothing. Does it work with enable ai mod?
     

    Attached Files:

    • Bez tytułu.jpg
  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