External images, text and etc

Discussion in 'Programming' started by ThePajlok, Jul 13, 2024.

  1. ThePajlok

    ThePajlok
    Expand Collapse

    Joined:
    Feb 8, 2014
    Messages:
    10
    Hi,

    I have been working on redesigning individual elements of the BeamNG interface for some time now.
    Everything is going well, unfortunately I encountered quite a big problem.
    For certain parts of the new design and completely new menus I need to download data from an external website, such as text and graphics.
    My problem is that the game does not load any graphics as if it had no Internet connection. The code containing the image looks like this:

    " <img class="nnm_mod_test_image" src="https://picsum.photos/200/300">"

    I tried using also:

    "<img class="nnm_mod_test_image" src="http-external://picsum.photos/200/300">"

    where "http-external://" is used by default in the menu for the "News" button:

    " <a href="http-external://go.beamng.com/devblog">{{:: 'ui.mainmenu.news' | translate}}</a>"

    Unfortunately it doesn't work. I also tried to use JavaScript and jQuery but it didn't help either.


    Here is small piece of new UI:



    Thank you in advance for your help!
    If you have any questions, this is my discord: @paylok
     
    #1 ThePajlok, Jul 13, 2024
    Last edited: Jul 13, 2024
  2. Neverless

    Neverless
    Expand Collapse

    Joined:
    Sep 18, 2016
    Messages:
    234
    What kind of data do you need to pull from the internet during runtime? And for what reason?
    Point is, you cant do that, so maybe there is a different solution if you tell us why you are doing it in the first place
     
  3. ThePajlok

    ThePajlok
    Expand Collapse

    Joined:
    Feb 8, 2014
    Messages:
    10
    For example, the main menu will contain a box with a summary of the latest posts from the BeamNG DevBlog along with any graphics, downloaded from a previously prepared RSS (this stage has already been done) and substituted as ready data for the HTML code.

    The BeamNG interface can work dynamically and statically, but downloading static data is important to me because of the UI element that I would like to use for this.
     
  4. r3eckon

    r3eckon
    Expand Collapse

    Joined:
    Jun 15, 2013
    Messages:
    601
    This is just a suggestion as I have no idea if this can work but you might be able to use luasocket as a workaround to download whatever data you need. For images your UI would point to files inside the userfolder that are updated from lua, with data downloaded with luasocket saved to files using the io library. Then you can force a refresh with a guihook.trigger call that invokes some AngularJS function containing scope.$apply after files are downloaded. For text you can just send downloaded data as strings using guihooks.
     
  5. ThePajlok

    ThePajlok
    Expand Collapse

    Joined:
    Feb 8, 2014
    Messages:
    10
    I don't think Lua is able to work with the in-game main interface. As an interface application of course, but I doubt it will work with modules
     
  6. _N_S_

    _N_S_
    Expand Collapse

    Joined:
    Oct 28, 2017
    Messages:
    73
    No, it's not supposed to work.
    The game has a strict whitelist of allowed resource URLs and ip addresses.
    Earlier the list looked like this: (I don't know how it looks now)
    lll.png
    Attempts to access somewhere other than that are denied.
    ddd.png
    Exceptions - LAN
    LAN.png
     
    • Agree Agree x 3
  7. r3eckon

    r3eckon
    Expand Collapse

    Joined:
    Jun 15, 2013
    Messages:
    601
    It definitely works with lua, example: the mod manager UI module receives mod lists from lua through the ModManagerModsChanged guihook:

    This is code from ui\modules\modmanager\modmanager.js
    upload_2024-7-14_13-12-51.png

    This code is from lua\ge\extensions\core\modmanager.lua
    upload_2024-7-14_13-13-36.png

    But as @_N_S_ points out the game has a whitelist of what the socket library can access which means your only option seems to be an external program running in the background to update files in the userfolder.

    Oh well, kinda figured this would likely be the case for security reasons but I never actually tried.
     
  8. DaddelZeit

    DaddelZeit
    Expand Collapse

    Joined:
    Jul 17, 2019
    Messages:
    3,484
    This list is up-to-date and how the filter looks for both UI and Lua/C++ calls.
    Only steamstatic links work, not steamcommunity links.
    upload_2024-7-14_19-31-28.png
    upload_2024-7-14_19-34-51.png
    The closest thing you will get to your desired result is opening a popup to the devblog.
    upload_2024-7-14_19-38-2.png

    I don't recommend working around these restriction as BeamNG obviously wants to prevent this.
     
    • Agree Agree x 1
  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