Run a bat file on closing BeamNG drive (SOLVED)

Discussion in 'Programming' started by ThreeDTech21, Dec 4, 2015.

  1. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    I made a .bat file that deletes the contents of the cache file so that my materials are registered on the next run of BeamNG, is there a way to automate the process.

    What I need is BeamNG to trigger the .bat file on closing, I notice that BeamNG adds a fonts folder to the cache folder on closing, if I could tap into that code i could add my batch file to process.

    What is the file that is writing the fonts file?
     
  2. Michaelflat

    Michaelflat
    Expand Collapse

    Joined:
    Jul 10, 2014
    Messages:
    1,543
    you could have it so that the batch file is checking wether the beamng drive process is running, but its a bit inefficient, dont know much about the beamng opening a batch file though
     
  3. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616

    This may work Ill check into it
     
  4. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    601
    Easiest solution would probably be having the batch start BeamNG.drive with the /wait flag set, then add your script after that. It'll automatically continue execution when the BeamNG.drive process finishes.
     
    • Like Like x 1
  5. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    yup that worked! If anyone is interested here is the code:

    Code:
    @echo off
    
    TASKKILL /F /IM BeamNG.drive.x64.exe
    
    timeout /t 1
    
    RD /s /q c:\Users\Super\Documents\BeamNG.drive\cache.0.4.3.2
    
    REM timeout /t 1
    
    start "" "c:\Program Files\Steam\SteamApps\common\BeamNG.drive\BeamNG.drive.exe
    It closes BeamNG > waits > deletes the cache > opens BeamNG. It saves a lot of time.. takes about 4-6 seconds. I mapped it to a button on my Xbox 360 controller to run straight away = win.
     
  6. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,685
    How does deleting the cache help anything? Cached files are faster to load, and are a smaller filesize than uncached ones. If anything, it should be loading slower.
     
    • Like Like x 1
  7. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    When updating and changing .dds files they dont show in game unless i delete the cache files, its a issue i posted about several times but no one seems to think its an issue

    http://www.beamng.com/threads/materials-not-updating-when-pressing-ctrl-r.17788/

    http://www.beamng.com/threads/cache-cripples-content-creation.15170/
     
  8. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Err, you linked to two threads. I asked you a question in one of those; you didn't answer it. I'd say that "no one seems to think its an issue" is not accurate.
     
  9. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    sorry mate the thread got buried after a while I been posting a lot and lose track of threads, I'm editing out of the root file for my vehicle using .png file but ill be converting them to .dds later which may actually fix the problem.

    I made the batch file to delete the cache folder after closing BeamNG, the reason is that when you update files in the materials file they don't show up properly unless BeamNG is first closed and the cache file is deleted,

    I'll help you duplicate the issue.

    Do this --> create a new .png file in whatever program and color it black > save it as fullsize_c.dds in the fullsize root folder > replace the default fullsize.c.dds with the the black one, press CTRL+R to reload the vehicle > you will notice the the car is not back > you have just duplicated the issue. But as said before the issue may be localized to .png images since they operate in a different way than .dds i will soon find out since i'm converting my UV maps to .dds in a few days. so the issue may actually be a none issue and why no one seems to care because they are using .dds files, I saw this recently when messing aroudn with the .dds file of the fullsize. Everything updated without restarted the game. for now Ill mark this thread solved. but thanks for helping.
     
    #9 ThreeDTech21, Dec 7, 2015
    Last edited: Dec 7, 2015
  10. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    I see two things going on here:
    1. Please write your answer in the form of "C:\Program Files (x86)\steamapps\common\BeamNG.drive\vehicles\fullsize.zip\fullsize_c.dds" or "C:\Users\your_user_name\Documents\BeamNG.drive\mods\fullsize\fullsize_c.dds" for example. Saying "the root folder" doesn't get us very far. You may copy the path from the address bar at the top of the Windows Explorer window when you browse to that location. (Although it won't include the filename like my examples. That's OK.) While the game uses a virtual filesystem some locations behave differently from others.
    2. PNG files do not use the DDS extension. I'm not aware of any good reason to give a PNG file a DDS extension. The example you gave should be named fullsize_c.png and all files which reference fullsize_c.dds should have their references changed.
     
  11. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    Root folder = the folder of the vehicle. I think writing out the full path in this context would be redundant. (root folder of vehicle) <-- is usually universal for the folder that contains all jbeams, textures, files, etc.

    "I'm not aware of any good reason to give a PNG file a DDS extension."

    .dds is far Superior to .png when it comes to games as explained by one of the devs. It is important to switch png to dds whenever possible which is what I plan to do soon that should clear up the whole cache issue and make this thread obsolete.
     
  12. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    601
    You're wrong. He's trying to help you, at least have the courtesy to answer his questions.

    You're doing it wrong. Simply changing the extension of a PNG file to "dds" doesn't convert the file, it just renames it (and there is, indeed, no good reason to do so). To convert the file, use an image editor like Photoshop, GIMP or Paint.NET.
     
  13. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    I have photoshop CS5 and paint.net and changing the extension of a PNG file to "dds" doesn't convert the file is true and I already know this, maybe its the way I worded it that caused some confusion, but I fully know that it must be converted the right way using a program such as Photoshop or paint.net not just renaming the extension

    as to your first point I don't think courtesy was an issue, I just offered my point of view that it was redundant to list the full path, I'm still not sure what purpose that would serve

    I say its redundant but maybe i'm looking at it too simplistically, "replace the default "C:\ProgramFiles(x86)\steamapps\common\BeamNG.drive\vehicles\fullsize.zip\fullsize_c.dds" <--- I assume this is the format he wanted. But the way I see it the person im speaking to is familiar with BeamNG files and they would already know to unzip the fullsize file, put that file into the mods/vehicles folder and then start replacing the .dds files with .png files to duplicate the issue.
     
    #13 ThreeDTech21, Dec 7, 2015
    Last edited: Dec 7, 2015
  14. Scepheo

    Scepheo
    Expand Collapse

    Joined:
    Feb 10, 2015
    Messages:
    601
    That is just one of many ways, each of them with its own advantages and disadvantages, but none of them wrong. Knowing which one you're using does matter, for one because it determines whether and how your files might be overwritten. For example, files in Documents/BeamNG.drive/levels can overwrite files in Documents/BeamNG.drive/mods/levels.

    That said, I've had similar issues and had to restart BeamNG.drive too. Deleting the cache has never been necessary, though.
     
  15. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    Oh ok I see why its important, the files im using are in C:\Users\Super\Documents\BeamNG.drive\mods\vehicles\schoolbus the schoolbus folder is where all of my texture files are, I don't have a Documents/BeamNG.drive/levels path, I thought the levels folder would go in C:\Users\Super\Documents\BeamNG.drive\mods\levels ?
     
  16. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    That's what I was curious about.

    I'd try moving your work from
    C:\Users\Super\Documents\BeamNG.drive\mods\vehicles\schoolbus
    to
    C:\Users\Super\Documents\BeamNG.drive\vehicles\schoolbus

    and see if that has any affect on the caching issue. So you definitely aren't working out of a ZIP file? (EG definitely not schoolbus.zip right? And you don't have any zip files which contain the same folder structure {with /schoolbus/} in the mods folder?) I was under the impression that the game didn't currently cache things which were not in ZIP files, but I could be wrong. Are you running the current version of the game?

    I'd also definitely look into what I recommended earlier - don't rename stuff to the wrong extension. I'm not saying that it's the culprit now, but eventually it's bound to make you or someone else unhappy. The fix is easy - refer to your files by the correct extension in the first place. So if a materials.cs calls on the file, just call it by the right name. Now that I think about it, I don't think that you even need to call it by the extension in materials.cs, you may just omit the extension. So IIRC fullsize_c.dds can be referred to simply as fullsize_c and that way it will find either the dds file or a png file, whichever is present. I could be wrong about that - I don't have time to check right now (sorry). I definitely wouldn't have both files be present of course.
     
  17. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    Yes i'm running the latest game build, im going to try to run the vehicle from C:\Users\Super\Documents\BeamNG.drive\vehicles\schoolbus and see if that helps
     
    • Like Like x 1
  18. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Any luck with this?
     
  19. ThreeDTech21

    ThreeDTech21
    Expand Collapse

    Joined:
    Sep 27, 2013
    Messages:
    1,616
    It doesn't work, it will only run the file form the mods folder
     
  20. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Pretty sure that means that you're "doing it wrong". Files definitely load fine from the BeamNG.drive\vehicles\ directory in my experience. I have successfully tested this recently. :-/
     
    • Like Like 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