RaceTimer [WIP]

Discussion in 'User Interface Apps' started by deject3d, Jun 26, 2014.

  1. deject3d

    deject3d
    Expand Collapse

    Joined:
    Sep 3, 2013
    Messages:
    250
    hey, i've slapped together a proof of concept race timer. i'd like to get some testing and feedback, so i'm going to release it as it stands right now. it probably has some bad bugs and usability issues, i want people to find them.

    note: this is very experimental !

    it looks like this


    (imported from here)

    it saves the best lap time you've made and can optionally send your laptimes to a scoreboard on the internet. while i have the scoreboard working on my own machine, i don't have a web server to put the scoreboard on the internet for testing and it would just get ruined by people who look at the javascript and send fake times anyway. it needs more features and probably some game-engine functionality to make it a little harder to cheat, so i'm leaving it out of this initial release.

    in the attachment, i have included a .mis file for a race around Small Island. this .mis file should contain all the necessary checkpoints to complete a race on Small Island, assuming i've made it correctly. after installing the .mis file and loading up the addon, you should be able to drive left from the spawn and the race around the perimeter will begin slightly down the road, as depicted in the screenshot below.

    wishlist:

    - better way to figure out which vehicle is being used
    - a way to know what track is loaded
    - knowing what part configuration is currently loaded
    - built in methods of hashing car setups to help deter tampering
    - a way to display to the user "a checkpoint is right here" or "this is a start/finish line" on the maps themselves

    some extra details:
    - best lap times are saved per-car through the persistance system and loaded when you hit the first checkpoint that begins a race
    - yes the code for the online leaderboard is in there, if you enable it through the app settings it might fail and i don't really care. use it as a websocket example if you want.

    making your own races
    you can make your own races, and multiple races per map should be supported but i haven't tested it. you just need to add the checkpoints with the editor.

    to start making a map in the map editor, you'll want to use the scene tree menu on the right. go to library -> level -> beamng and double click on "beamNG trigger"

    place the trigger wherever you want and change the scale to be whatever size you like. this trigger acts as a checkpoint

    set the TriggerCmdMode of the trigger to "JSCustom"

    double click on "enterCommand" to define what code should be executed when you travel through this trigger. checkpoint #1 is the most important for this addon because it sets up variables used for that particular race. you'll want something like this:

    Code:
    RaceTimer.prototype.max_checkpoints = 8; // this is not used currently
    RaceTimer.prototype.current_race_id = 1; // the unique race ID for this map
    RaceTimer.prototype.current_race_name = "Small Island Perimeter Reverse"; // the name of the race that this first checkpoint will start
    RaceTimer.prototype.current_race_type = "sprint"; // the type of the race - currently only "sprint" is supported
    
    RaceTimer.prototype.onCheckpointHit(1, 1); // the first '1' is the ID of the race, and the second '1' is the number of this checkpoint
    
    it should look something like this;


    (imported from here)

    for additional checkpoints throughout the race, you will follow the same procedure except the only enterCommand code you need is the following:

    Code:
    RaceTimer.prototype.onCheckpointHit(1, 2); // again, the first 1 is the raceID and the second 1 is the checkpoint index. of course the checkpoint index is in order, so the first checkpoint should be 1, the second checkpoint should be 2, etc
    
    when you're done adding checkpoints, you can add a finish line like this:

    Code:
    RaceTimer.prototype.onCheckpointHit(1, 8, true); // race id 1, checkpoint 8, "true" designates a finish line
    
    you'll also want to setup a reset trigger somewhere on top of the spawn sphere so that resetting your car will stop the race. the process is exactly the same, it's just a trigger with slightiy different code:

    Code:
    RaceTimer.prototype.resetRace();
    
    right now there is no way to reset an individual race, so if you're going to have multiple races on one map try to make sure that people will not drive through a reset zone when you're setting up your checkpoints. i can add this pretty easily if necessary.

    once you've added your reset zone + all of your checkpoints sequentially, made sure all of the TriggerCmdModes are set to "JSCustom", and your checkpoints are all in the correct order, you simply drive through checkpoint #1 to start a race and it's over when you hit the last checkpoint.

    let me know if anything's screwed up!
     

    Attached Files:

    #1 deject3d, Jun 26, 2014
    Last edited: Jun 28, 2014
    • Like Like x 1
  2. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,683
    You could make a bunch of coordinates and say if within x radius checkpoint hit then checkpoint++

    Code:
    var points = [{x:45, y:64,z:25},
                  {x:56, y:98,z:31},
                  {x:23, y:44,z:32}];
    
    for(var i = 0; i < points.length; i++) {
         var point = point[i];
        //point.x, point.y, point.z are parameters
        
    }
    
    
     
  3. deject3d

    deject3d
    Expand Collapse

    Joined:
    Sep 3, 2013
    Messages:
    250
    i'm not sure i'm understanding: what would this accomplish? the checkpoints i have using triggers work fine.
     
  4. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,683
    Oh I misunderstood, I thought you were putting that code as a wishlist type thing for triggers to work ,Great to see they actually do.
     
  5. rt389g@hotmail.c

    rt389g@hotmail.c
    Expand Collapse

    Joined:
    Jun 9, 2014
    Messages:
    111
    This looks interesting, I was hoping something like this would be in the update. I guess not. I will try it this weekend if I have time. I am going to release a map level mod soon. If this works can I just included in my level? I can give you credit of course. Thanks.
     
  6. deject3d

    deject3d
    Expand Collapse

    Joined:
    Sep 3, 2013
    Messages:
    250
    here's a new version with a slight bugfix and more races:

    corkscrew mountain
    (screenshot not necessary just drive down the hill. i converted the old checkpoints to my system)

    industrial site

    (imported from here)

    and for good measure here is the screenshot of small island rally which is still included, in case the race layout is confusing anybody... just drive around the perimeter.
    http://i.imgur.com/wNQPIfg.jpg


    to download: see updated attachment in original post

    just unzip the two folders into your beamng folder and merge any changes - it should install fine. no idea what will happen if you don't actually have corkscrew mountain installed.

    i tried to do a dry rock island track as well but i found that the map already has some checkpoints built into it (probably race update stuff). it looks incomplete so i won't try converting them to my system for now. also, when i try to edit the level with the world editor it seriously lags me, so i didn't bother.

    here's a video showing that it does indeed work:



    if you want to race with the checkpoints visible, you have to open the world editor and select each checkpoint object. if you close the editor while the objects are selected, they will still be visible in-game.


    i'm working on borrowing a friends server to get an initial version of the online scoreboard on the internet, as well. it's pretty basic but it's something.

    it's very easy to add your own races, i promise :). if you run into any issues, let me know. no credit is necessary. take it, update it, make it better, re-release it on russian websites, the more the merrier.
     
    #6 deject3d, Jun 28, 2014
    Last edited by a moderator: Oct 21, 2015
  7. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,683
    deject3d : Releasing the race update, before the race update :p
     
  8. gmaksi83

    gmaksi83
    Expand Collapse

    Joined:
    Aug 5, 2013
    Messages:
    348
    Small Island with Ibishu Covet Rally 1:44:143


    BeamNG Race Timer
    Map: Small Island with race timer
    Car: Ibishu Covet ver.Rally
    Steering: Logitech G27
    Lap time: 1:44:143:)
    Thanks for the Race Timer!!!
     
    #8 gmaksi83, Jul 2, 2014
    Last edited by a moderator: Oct 21, 2015
  9. deject3d

    deject3d
    Expand Collapse

    Joined:
    Sep 3, 2013
    Messages:
    250
    Re: Small Island with Ibishu Covet Rally 1:44:143

    i'm glad it actually works for someone else!

    as a short progress update, i've got an idea on how to secure the laptimes at least a bit. i'm working on implementing it, getting a basic scoreboard up, then polishing the app itself.

    and that was a very fast lap, i'll have to try to beat that one later... :p
     
  10. jammin2222

    jammin2222
    Expand Collapse

    Joined:
    Sep 15, 2013
    Messages:
    386
    I love it! I have got it working on my map. I managed to set up 2 races (one in each direction) It seems to work just fine. I'm not sure if you can make it say the name of the race you have started somehow? I gave each race a unique name but It only says "[Sprint] Race Started" and not the name I gave it. Did I do it wrong?
    No big deal either way but it would be cool to know what race was started.

    Thank you

     
    #10 jammin2222, Aug 24, 2014
    Last edited by a moderator: Oct 21, 2015
  11. jammin2222

    jammin2222
    Expand Collapse

    Joined:
    Sep 15, 2013
    Messages:
    386
    I don't suppose you could tell me how to reset my best time?
     
  12. deject3d

    deject3d
    Expand Collapse

    Joined:
    Sep 3, 2013
    Messages:
    250
    times are stored in the "persistence" system which is handled by the UI system. i think you might be able to edit/delete your times by opening persistence.json, but if not then maybe someone else can answer where it's stored. i don't have the game installed right now or i would check, sorry.
     
  13. jammin2222

    jammin2222
    Expand Collapse

    Joined:
    Sep 15, 2013
    Messages:
    386
    I just had a look in the persistence.json file but there doesn't seem to to be anything in there relating to the race timer at all. I'm not a programmer but I did see references for a few of the other ui apps, sadly not the timer, or anything that looks like my best time. I guess there should be a few times saved for the various vehicles I have driven. Oh well hopefully someone else will know.
    Cheers anyway
     
  14. theshark

    theshark
    Expand Collapse

    Joined:
    Aug 5, 2012
    Messages:
    137
    just remove the app and add it again.
    Persistence is on a per app basis, so removing the app deletes the data.
     
  15. metalmuncher

    metalmuncher
    Expand Collapse

    Joined:
    Aug 6, 2012
    Messages:
    257
    The persistence system uses localstorage, I think the files for this are in mydocs/BeamNG.drive/cache/html-cache (experimental), but they are raw binary, so non-human readable. Deleting these files will reset everything that uses persistence, including app position and unit preference storage, and probably the lap times for this app. AFAIK the settings in persistence.json are loaded when the html cache doesn't exist.

    edit: welp, shark made a better answer before me :|
     
  16. Przemoo Kotlubaj

    Przemoo Kotlubaj
    Expand Collapse

    Joined:
    Sep 14, 2014
    Messages:
    1
    Big thanks for this app!
    My Bajarama hotlap
     
    #16 Przemoo Kotlubaj, Sep 18, 2014
    Last edited by a moderator: Oct 21, 2015
  17. deject3d

    deject3d
    Expand Collapse

    Joined:
    Sep 3, 2013
    Messages:
    250
    bump because there's still no race update and this addon is still an attempt at creating some community competition in the game.

    if pressurewheels turn out good i'll finish it
     
  18. NistingurA

    NistingurA
    Expand Collapse

    Joined:
    Nov 22, 2013
    Messages:
    2,092
    Help please :( I dont know how to change the CmdMode to JSCustom. I dont find it there
     
  19. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,683
    not supported anymore
     
  20. deject3d

    deject3d
    Expand Collapse

    Joined:
    Sep 3, 2013
    Messages:
    250
    are you on experimental? it may have been changed. any dev want to comment? have the options simply changed names?
     
  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