A thing that we all need (Materials .CS / .JSON)

Discussion in 'Programming' started by Nekkit, Sep 3, 2019.

  1. Nekkit

    Nekkit
    Expand Collapse

    Joined:
    Jun 30, 2018
    Messages:
    1,103
    Im not a programmer myself and i cant do it, but talking from the big part of the modding community, .json format of materials instead of .cs is really hard to switch to. Can someone make a converter from .cs to .json materials format?
     
    • Agree Agree x 3
  2. Alex_Farmer557

    Alex_Farmer557
    Expand Collapse

    Joined:
    Dec 28, 2016
    Messages:
    3,527
    • Like Like x 1
  3. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    103
    Sort of. I made a simple .json to .cs converter. (Though it's currently broken) https://github.com/swift502/BeamNG-material-tools

    I can definitely make a .cs to .json converter. Should be fun. :)
    I can also add any other functionality. I personally needed duplicate detection and removal so I made it for that purpose. But if you need anything specific let me know.

    It's all very simple stuff though. No GUI, just python code.
     
    #3 swift502, Sep 3, 2019
    Last edited: Sep 3, 2019
    • Like Like x 1
  4. Driv3r1142

    Driv3r1142
    Expand Collapse

    Joined:
    Feb 15, 2015
    Messages:
    1,923
    So can anyone explain this thing they did to materials? I asked in the discussion thread and got no answers. It's not that the format doesn't make sense, I haven't had any luck making my own materials via Notepad++ and having the game recognize them.
     
  5. Aboroath

    Aboroath
    Expand Collapse

    Joined:
    Aug 25, 2013
    Messages:
    3,807
    I haven't been able to get .json figured out either. Been a HUGE reason why I don't do maps anymore. I can take a stock .json, modify it EXACTLY in Notepad and sure enough every time the game has an issue with it. A converter is certainly a great idea in my book.
     
  6. swift502

    swift502
    Expand Collapse

    Joined:
    Oct 30, 2018
    Messages:
    103
    The 0.17 changelog says:
    "Material files moved to new Json format, allowing multiple files for better modability"

    And I got this answer recently:
     
    • Like Like x 1
  7. thomatoes50

    thomatoes50
    Expand Collapse
    BeamNG Team

    Joined:
    Jan 31, 2013
    Messages:
    695
    It may be usefull for someone but there is a tool inside the game
    Code:
    \lua\ge\extensions\util\resaveMaterials.lua
    This is not really supported and may crash the game.
    It will hang and try to convert the entire universe.


    Not recommended to use when you have lots of mods or unclean userpath

    start by using this command
    Code:
    extensions.load("util_resaveMaterials")
     
    • Like Like x 2
    • Informative Informative x 2
  8. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,657
    In the process of removing anything TorqueScript related (like it happened for the levels and the .MIS files, now it's time for the materials .CS files).
    .JSON is a more future-proof format which we can work and support better.

    Also, this move allow us to have multiple "materials" files in a single folder (see the vehicles, which have their skin materials files in a separate .JSON file from the rest)
     
    #8 Nadeox1, Sep 4, 2019
    Last edited: Sep 4, 2019
    • Like Like x 2
    • Informative Informative x 1
  9. Driv3r1142

    Driv3r1142
    Expand Collapse

    Joined:
    Feb 15, 2015
    Messages:
    1,923
    Thank you for explaining it a bit more, but you also forgot the other half of my question;

    It's not that the format doesn't make sense, or that I don't know where or what everything is, it's that I can't seem to add a new material to one of these files in Notepad++ and have the game recognize it.
     
  10. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,657
    That's pretty generic description you gave unfortunately, could be anything.

    Can you provide the file?



    By the way, to clear the doubts.
    This JSON move for materials is at early stages yet.

    You can keep working with the .CS format, as it works as usual.
    In the future we have will have some automatic converter built-in the new editor, to make the move quick and painless.





    If you are still interested, you just need to be extra careful with this format.
    And mind that since it's a work in progress feature, things could change, so be aware.

    This format is way more strict with the syntax, which is good as it prevents broken stuff to be inserted and left in there (which can become an issue in the future).

    Since it's JSON specification, you can use a JSONLinter to validate your file.
    The game will also throw errors in the console if your Json is invalid:

    (A common mistake for example is forgetting that the last lines of a group does not need a comma)

    Here I'm attaching my VR_City level materials file, both the original .CS and the hand-written .JSON
    Here's a comparison between the two:

    The most noticeable chance is that you don't have [0] [1].. at the end of the material feature to indicate the 'layer' (stage). You now have { } brackets present all the time, which correspond to every layer (stage)
     

    Attached Files:

    #10 Nadeox1, Sep 5, 2019
    Last edited: Sep 5, 2019
    • Like Like x 5
    • Informative Informative x 3
  11. Driv3r1142

    Driv3r1142
    Expand Collapse

    Joined:
    Feb 15, 2015
    Messages:
    1,923
    Thank you for the explanation :) I'll give converting to the new system another shot when I have more time, this should be very helpful in regards to understanding things.
     
  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