Solved Digital real time clock in BeamNG

Discussion in 'Mod Support' started by schumacher, Jan 28, 2017.

  1. schumacher

    schumacher
    Expand Collapse

    Joined:
    Sep 1, 2013
    Messages:
    1,053
    Hey guys, i just wanted to ask if someone of you is able to inegrate a working clock as a material (like the nav screen) into my dashboard. i have the html code for the clock but no clue how to make it work in beamng. can someone help me?

    Code:
    <script src="http://www.clocklink.com/embed.js"></script> <script type="text/javascript" language="JavaScript">obj=new Object;obj.clockfile="5005-green.swf";obj.TimeZone="Germany_Frankfurt"; obj.width=240;obj.height=80;obj.wmode="transparent";showClock(obj);</script>
    or

    Code:
    <embed src="http://www.clocklink.com/clocks/5005-green.swf?TimeZone=Germany_Frankfurt" width="240" height="80" wmode="transparent" type="application/x-shockwave-flash">
    website:

    http://www.clocklink.com/gallery/view/5005

    Unbenannt.png
    this is where i want to place it
     
    #1 schumacher, Jan 28, 2017
    Last edited: Jan 28, 2017
  2. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,673
    You would need to change the material of the 3d model in the area that you wish to embed the clock to a new material.

    Then you need to find the lua file for the vehicle you want to add the page into. This will be found in a folder called lua which is contained in the root folder of the vehicle.

    Then copy a line of code that will look something like:
    Code:
    local naviScreenName = "@R60_Nav"
    And change the bit that states "naviScreenName" to something along the lines of "digiClock", then change the bit that states "R60_Nav" (or your vehicle equivalent) to the name of the material you created on the model.

    You will also find a line of code that looks similar to this:
    Code:
    obj:queueGameEngineLua('be:getObjectByID('..vehicleID..'):createUITexture("'..naviScreenName..'", "local://local/vehicles/Raven R60/navi_screen.html", 256, 128, UI_TEXTURE_USAGE_AUTOMATIC, 30)')
    Then copy this line of code and change where it states "naviScreenName" to be "digiClock" (keep the dots etc).

    I think the numbers "256,128" of the code adjust the resolution of the HTML web page that is created. Can't quite remember.

    Then when the vehicle loads, the lua file will tell the game you want to assign the material (on the 3d model) to be a HTML material, as well as that you want that material to be one from the html file you specified.
     
  3. schumacher

    schumacher
    Expand Collapse

    Joined:
    Sep 1, 2013
    Messages:
    1,053
    thats really useful; thank you. We tried to add this (html/lua file) and also added some lines in materials.cs but we just get orange no texture instead of the clock time.
     

    Attached Files:

  4. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,673
    Did you change the texture on the actual model within your modelling software?

    Also putting "--" in front of a line in lua comments it out. Which means the game will just ignore it as it is a comment for human reading only.
     
  5. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    2,977
    The UI runs in a sandbox. It'll not be able to connect to websites to get data and alike. If you want a clock, you need to code it yourself :/
     
  6. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,673
    That's good to hear actually, since many a bad thing could happen if you give mods internet access. Although I did find myself wondering if it was possible to auto-update the OS of a cars nav system within BeamNG among other things such as streaming YouTube to the navigation screen xD
     
  7. NGAP NSO Shotgun Chuck

    NGAP NSO Shotgun Chuck
    Expand Collapse

    Joined:
    Mar 6, 2015
    Messages:
    1,268
    This is interesting. I saw in one of YBR's videos a mod with a clock that syncs to your system time, but I've never seen one with a clock that accurately displays the time the map is set to instead. I wonder if that's possible?
     
    • Agree Agree x 1
  8. schumacher

    schumacher
    Expand Collapse

    Joined:
    Sep 1, 2013
    Messages:
    1,053
    All right, thank you for the replies. Since tdev said it isnt possible with different websites I finally found an html code which works without any website. Can I use this one instead? Is this possible?
     

    Attached Files:

  9. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    2,977
    This would work :)

    now you need to figure out the HTML/Lua/Material setup out
     
    • Like Like x 1
  10. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    695
    Tdev is right you should provide the file locally and not ask a server.
    moreover, you should avoird using flash because it will be dead soon and it eat quit a lot of resources for simple things.

    I made a simple clock using code from stackoverflow.
    Javascript interval refresh a text in a SVG image
    If you want help contact me via pm or here
    upload_2017-2-4_10-47-37.png

    To @tdev : is there a way to get the temperature of the map?
     
  11. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    2,977
    oh, cool :D

    I am interested on how you solved it. If you share, i'll look into the temperature for you :)
     
    • Like Like x 2
  12. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    695
  13. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    2,977
  14. schumacher

    schumacher
    Expand Collapse

    Joined:
    Sep 1, 2013
    Messages:
    1,053
    Okay, the thread is solved now, with thomatoes50's help its working now :)

    Unbenannt.png
     
    • Like Like x 1
  15. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    2,977
    could you please share the code? I would like to test if the triggered updates are working, and this would be an ideal usecase :)
     
  16. schumacher

    schumacher
    Expand Collapse

    Joined:
    Sep 1, 2013
    Messages:
    1,053
    Sure :) Here are all the files used for the clock to work:
     

    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