More Fuel Types

Discussion in 'Programming' started by Capkirk, Jun 5, 2018.

  1. Capkirk

    Capkirk
    Expand Collapse

    Joined:
    Nov 19, 2017
    Messages:
    673
    I've been trying to add more fuel types to beamng beyond "gas" "diesel" and "kerosene", specifically CNG and LNG. I've never used LUA before, but it seems pretty simply, and by editing the fuelTank.lua file in the game directory, I was able to get the game to recognize CNG as a fuel type. However, if I try to make it into it's own seperate file, (by copying the entire LUA file and putting in a mod) it won't work. So, I was wondering if anyone knows how to make a lua file work so it can be packed into a mod. Just for reference, the relevant code section is
    Code:
      elseif storage.energyType == "CNG" then
        storage.energyDensity = 53.6 * 1000000 --MJ/kg
        storage.fuelLiquidDensity = 0.13
      elseif storage.energyType == "LNG" then
        storage.energyDensity = 53.6 * 1000000 --MJ/kg
        storage.fuelLiquidDensity = 0.5 
    
     
  2. Alex_Farmer557

    Alex_Farmer557
    Expand Collapse

    Joined:
    Dec 28, 2016
    Messages:
    3,541
    wait kero is a recognised fuel ingame?
     
  3. Capkirk

    Capkirk
    Expand Collapse

    Joined:
    Nov 19, 2017
    Messages:
    673
    Yeah, it's defined in the lua file. I've never tried using it, but if you set an engine's fuel type to "kerosene" it should work
     
    • Informative Informative x 1
  4. Alex_Farmer557

    Alex_Farmer557
    Expand Collapse

    Joined:
    Dec 28, 2016
    Messages:
    3,541
    dear lord my irish fuel memes cant be truer!
    You sir, are a saviour!!
     
  5. Neo

    Neo
    Expand Collapse

    Joined:
    Oct 31, 2015
    Messages:
    260
    Usually you copy the file into you mods directory and mimic the folder structure there one to one, but you are not able to upload you mod to the repo bacause you are not allowed to overwrite any game data files see here. You may find a way to get you code into the game without overwriting game data files.
     
  6. Capkirk

    Capkirk
    Expand Collapse

    Joined:
    Nov 19, 2017
    Messages:
    673
    I actually did that, just copy the entire fuelTank.lua into the mod and it didn't do anything. Only changing the file in the game directory seemed to work.
     
  7. Deleted member 160369

    Deleted member 160369
    Expand Collapse
    Guest

    Experienced the same issues when I was trying to implement methanol fuel for the Monster Truck.

    Ultimately gave up in the end.
     
    • Informative Informative x 1
  8. Ytrewq

    Ytrewq
    Expand Collapse

    Joined:
    Dec 6, 2014
    Messages:
    2,270
    I tried to make Grand Marshal run on ethanol (under the codename Most Useless Mod). Didn't work :(.
     
    • Like Like x 1
  9. Capkirk

    Capkirk
    Expand Collapse

    Joined:
    Nov 19, 2017
    Messages:
    673
    Really? Damn, maybe it's just not possible then. I suppose we could ask the developers to put CNG and LNG into the game. It would take all of 30 seconds, and would be useful for a natural gas powered bus config, among other things.
     
    • Agree Agree x 1
  10. fufsgfen

    fufsgfen
    Expand Collapse

    Joined:
    Jan 10, 2017
    Messages:
    6,782
    Maybe this is similar case as was with custom controller, where Diamondback needed to make some reorganizing to get custom shift logic etc. possible.
     
  11. Capkirk

    Capkirk
    Expand Collapse

    Joined:
    Nov 19, 2017
    Messages:
    673
    Yeah, maybe. Could @Diamondback provide some feedback on this? I'd like to know if it's at least possible.
     
  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