Released Speedometer V0.3

Discussion in 'Utilities and programming' started by GregBlast, Sep 19, 2013.

  1. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Information

    This is a speedometer I made that gives you all required info about...well your speed.
    It comes with a GUI that lets you configure different visual aspects and also switch between MPH and KMH.


    Video & Pics


    Beta 1 release


    Beta 2 release
    Total miles / kilometers driven
    BeamNG 2013-09-22 22-13-50-63.png

    Color switch via hexadecimal values (somebody tell me how to use a color picker if available through LUA ? ;))
    BeamNG 2013-09-23 00-40-31-40.png

    Beta 3 release
    Configuration files (loading / duplicating / saving / defaulting)



    Notes


    For the moment I can't move or resize the entire canvas by code. This means that by default it will probably be too large and wrongly positioned. Just press F10 to open the gui editor and move / resize the canvas by hand. You will have to do it each time you start the game though.

    For any question or suggestion don't hesitate to comment.


    Beta 1, 2 - Installation

    Alright first release is available below.
    To install:
    • extract the file gauges.lua into [game path]\lua\system
    • open [game path]\lua\system\main.lua
    • after all other require statements add the following code:
      Code:
      gauges    = require("gauges")
    • a little below right after the commented line that read --initCanvas() add:
      Code:
      gauges.init()
    • go down and locate the graphicsStep function and at the bottom of it add:
      Code:
      gauges.update( dt )

    That's it !

    Note:
    [game path] is the folder containing the executable file you run to launch the game. As you probably run from a shortcut you may still be wondering where it is. Then put your mouse cursor over your shortcut and wait for the tooltip to pop up. It will tell you where it points (aka the game's root folder).


    Beta 3 - Installation

    For the version 0.3 and later please do the following:

    • in the zip file you will find a folder named the same as the zip file (gauges-v0.3)
    • extract the contents of that folder inside the the game's root folder
    • you could be asked to overwrite a file added by Incognito with his Waypoints mod (table.save-1.0.lua). Your file could be more recent than the one I'm providing so in that case do not overwrite.

    After that follow the instructions from Beta 1, 2 - Installation above except for the extraction part.


    How to use the GUI (v0.1 and later)



    • to use the GUI you can either open your console and select mode BNGS and then type gauges.showGUI()
    • or you can edit your [game path]\scripts\client\inputmaps\keyboard.inputmap.cs file and add a bind like %mm.bindSLuaCmd(keyboard, "alt u", "gauges.showGUI()", "" ); if you wish to open it with alt+u



    Changing colors (v0.2 and later)

    To change colors you must enter the hexadecimal value (sorry no better way now). Use 6 character hex strings only. If you're not comfortable with hex strings use this website to find your colors:
    http://www.color-hex.com/
    Also copy only the 6 hex characters. Don't start with "0X" or "#". The first 2 characters are for RED the 2 next for GREEN and the last 2 for BLUE. For example pure red will be FF0000 and pure white will be FFFFFF while a mid gray will be 888888.


    Loading and saving configurations (v0.3 and later)


    Here is a typical way of using the GUI to create custom configurations:
    • open the GUI
    • select a configuration in the Configuration drop-down list
    • type a new name in the Configuration file name text box
    • play around with the properties
    • your new configuration is automatically saved at creation
    • the last selected configuration will become the default one when you either start the game, restart the System LUA or reset the values with the Reset button
     

    Attached Files:

    #1 GregBlast, Sep 19, 2013
    Last edited by a moderator: Oct 21, 2015
  2. Holland

    Holland
    Expand Collapse

    Joined:
    May 23, 2013
    Messages:
    982
    Re: Speedometer

    Sounds like a good ideal. But when I think about it, why do we need a speedometer when you can look on the dashboard? Looking down on the speedometer in the car gives you that driving feel, not looking to the left or right. Just a thought. Good ideal though.;) Keep it up.
     
  3. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Re: Speedometer

    You're right but as always I did this more as an exercice to play around with the available features and try to get something concrete out of it. Here it's a speedometer but it could be anything else you would want to see on your HUD.
    But still when you're not using your internal camera (I do it most of the time but still) it may be useful to have some indications like your speed. Just didn't want to make it simple text ;).
     
  4. moosedks

    moosedks
    Expand Collapse

    Joined:
    Nov 4, 2012
    Messages:
    1,112
    Re: Speedometer

    every other view mode without opening debug window
     
  5. bits&bytes

    bits&bytes
    Expand Collapse

    Joined:
    Jun 13, 2013
    Messages:
    40
    Re: Speedometer

    A speedometer is something i wanted form the first time i played BeamNG.
    I really love the meters on the dashboard of the cars, but because I have a little screen on my laptop, they are hard to read and most of them are in MPH.
    I was planning to make one like that form Race Dirver Grid with some indicators around it, but did not have any clue on how to start.
    So I am glad that you did this already.

    Your tutorials are always very clear and interesting to learn from, so of course i am interested.
    But I do not want to put pressure on you, it 's your mod so you decide what you do with it.

    It would be great if you can make it a little transparent, so you can look trough it. But maybe I am asking for the impossible :eek:.
     
  6. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Re: Speedometer

    Will release a first version in a few minutes. Just a little more tweaks (like transparency ;). Actually that's the circle behind it that is full black and thus makes the inner one no longer transparent. But I will make the back one transparent too ;). Well you know what this will be a parameters in the GUI.

    EDIT:
    Done. I've updated the first post with the first beta release of it.
     
    #5 GregBlast, Sep 20, 2013
    Last edited: Sep 20, 2013
  7. Holland

    Holland
    Expand Collapse

    Joined:
    May 23, 2013
    Messages:
    982
    Re: Speedometer

    Yeah your right.
    And yeah I see what your saying, I just didn't look at it that way. And your doing a good job so far! :D
     
  8. eletricmano

    eletricmano
    Expand Collapse

    Joined:
    Mar 30, 2013
    Messages:
    408
    Re: Speedometer

    How do you open its GUI to config it?
    Edit: Just figured out, sorry. :eek:
     
  9. JAM3SwGAM3S

    JAM3SwGAM3S
    Expand Collapse

    Joined:
    Jul 1, 2013
    Messages:
    380
    Re: Speedometer

    You need to add an input it says on the thread :)

    • to use the GUI you can either open your console and select mode BNGS and then type gauges.showGUI()
    • or you can edit your [game path]\scripts\client\inputmaps\keyboard.inputmap.cs file and add a bind like %mm.bindSLuaCmd(keyboard, "alt u", "gauges.showGUI()", "" ); if you wish to open it with alt+u
     
  10. Luke #37

    Luke #37
    Expand Collapse

    Joined:
    Sep 15, 2013
    Messages:
    16
    Re: Speedometer

    I like the look of this, good work, however I think perhaps it could be improved by way of cutting the bottom of the circle off, and moving the speedo further down the screen in the corner. For instance;


    (imported from here)

    It too would be greatly improved with an odometer that records how many Miles/KM you have driven since spawning the vehicle, instead of the text display of speed.

    In a later update, you may wish to include MPH and KPH on the same dial, like real life vehicles.

    This is a great start though!
     
  11. Pinecones

    Pinecones
    Expand Collapse

    Joined:
    Aug 20, 2013
    Messages:
    67
    Re: Speedometer

    Nice job so far!
    Would be good to get the RPM's too.

    On a side note, you should use the Lua Mod Installer to make it easier on people, because every update they will probably have to re-insert the lua. It could make things easier in the longrun as more and more lua mod's come out.
     
  12. KamikazeF0X

    KamikazeF0X
    Expand Collapse

    Joined:
    Aug 6, 2013
    Messages:
    38
    Re: Speedometer

    This is simple, This is AWESOME !

    Why not add a gear indicator ?
     
  13. eletricmano

    eletricmano
    Expand Collapse

    Joined:
    Mar 30, 2013
    Messages:
    408
    Re: Speedometer

    It would be nice if we could change the speedometer's size. Anyways, thanks for the mod, really useful for me! :D
     
  14. JAM3SwGAM3S

    JAM3SwGAM3S
    Expand Collapse

    Joined:
    Jul 1, 2013
    Messages:
    380
    Re: Speedometer

    You can change the size by setting up the customization using Alt + U then you can change the size and loads of other stuff
     
  15. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Re: Speedometer

    Forgot to say that you can press F10 to open the GUI editor of the game and play around with the canvas containing the speedometer. It stretches horizontally so if you resize vertically it goes off the canvas thus cutting it. It will by default cut both top and bottom but you can configure the speedometer position (Offset X and Offset Y) in the GUI. If you set Offset Y to 75% it will be at the bottom of the canvas. If you then resize it by hand in the editor you'll be able to cut only the bottom part.

    I agree this "by hand" thing is not optimal but I didn't figure out yet how to move or resize the canvas by code (actually the "CanvasTexture" object given by "BeamEngine.canvasTexture"). If anybody knows please let me know ;).

    - - - Updated - - -

    Thought about it but didn't find a way to get a hand on the current gear yet ^^. If player is using a manual transmission I could figure it out by checking the inputs (gear up and down) but otherwise... Anybody ?

    - - - Updated - - -

    Actually you can already. Open the GUI and change the Radius property and you're done. You can also open the GUI editor with F10 and resize the canvas by hand.
    The current video is deprecated. I'll make another one with full features included.

    As for the odometer with current miles / km we have a time indicator so it can be calculated. Will have a look at how time value works and determine elapsed miles / km based on elapsed time since last update.
     
    #14 GregBlast, Sep 20, 2013
    Last edited: Sep 20, 2013
  16. Kimmykix

    Kimmykix
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    231
    Re: Speedometer

    Any easy way to change the color of the speedo? that yellow looks terrible to me xD
     
  17. GregBlast

    GregBlast
    Expand Collapse

    Joined:
    Aug 12, 2013
    Messages:
    224
    Re: Speedometer

    Actually I wanted to make some selectable from the GUI but didn't yet really mess with colors.
    But there's a very easy way to change it in the code. Just find the init function and there you can change the values of all the setARGB calls if you want. That function should be called like this:
    Code:
    setARGB( A, R, G, B)
    where A, R, G and B are values between 0 and 255 for alpha, red, green and blue values. If you want to easily determine a color ARGB values you can use a tool like ColorPix. It's pretty handy.

    So to give a little concrete example. If you want the gauge to have a plain red background you can modify the code of the gauge background brush like this:
    Code:
    --    Gauge background brush
    local brush = SkPaint()
    brush:setAntiAlias( true )
    brush:setARGB( math.ceil( opacity * 255 ), 255, 0, 0 )
    brushes.gaugeBkgd = brush
    
    The alpha value is determined by the opacity chosen from the GUI. But you can decide to give it a maximum opacity lower than the max by changing 255 with something else there.


    As for the text colors you can replace SK_ColorBLACK and such with one of the following:


    • SK_ColorBLACK
    • SK_ColorBLUE
    • SK_ColorCYAN
    • SK_ColorDKGRAY
    • SK_ColorGRAY
    • SK_ColorGREEN
    • SK_ColorLTGRAY
    • SK_ColorMAGENTA
    • SK_ColorRED
    • SK_ColorWHITE
    • SK_ColorYELLOW
    Or try some negative numeric values (as SK_ColorWHITE = -1 and SK_ColorBLACK = -16777216 for example).


    PS: by the way... ;)

    Corvette yellow gauges:

    (imported from here)

    (imported from here)

    Ferrari yellow RPM gauge:

    (imported from here)


    EDIT:

    Posted new video.
     
    #16 GregBlast, Sep 21, 2013
    Last edited: Sep 21, 2013
  18. Narwhal

    Narwhal
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    1,698
    Re: Speedometer

    hello, thanks for this awesome mod
    i have a problem though, how do i move the speedometer? When i try to move its position, it gets cut off
    (i changed the offset of the speedo between the two pictures.)
    speedo.PNG
    offset.PNG
     
  19. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
  20. Pinecones

    Pinecones
    Expand Collapse

    Joined:
    Aug 20, 2013
    Messages:
    67
    Re: Speedometer

    EDIT: Removed my file, the one below is much better.

    Here's a lua installer for use with Lua-mod-installer
    With this, after a game update all you need to do is use the lua installer, select this file, then the beamNG folder and your done.
     
    #19 Pinecones, Sep 21, 2013
    Last edited: Sep 21, 2013
  21. Incognito

    Incognito
    Expand Collapse

    Joined:
    Aug 4, 2013
    Messages:
    246
    Re: Speedometer

    You could put a file "gauges.lua" in archive with the installation file and add a "copy the file" action in the installation file :)
    Below is the installation file, which will also copy the file "gauges.lua" to the desired location and add in keyboard inputmap:
    Code:
    %mm.bindSLuaCmd(keyboard, "alt u", "gauges.showGUI()", "" );
     

    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