validity of variables / constants

Das Forum befindet sich im reduzierten Betrieb. Die Addon- und Supportforen bleiben weiterhin verfügbar.
Bitte beachte, dass OMSI nicht mehr weiterentwickelt wird. Ein Teil der Entwickler widmet sich inzwischen der Entwicklung eines neuen Simulators. Weitere Informationen zum LOTUS-Simulator findest Du hier.
  • Hi All,


    I would like to add a feature to the engine script for a specific engine type. (RÁBA-MAN D2156 HM6U)
    But for the same script different const files are used to simulate other engine type (RÁBA D10) in two derivatives. (UTS155 and UTSLL160)


    I added a newline tag for one const file, and wanted to do so, that the others may use the old default value for the consumption.


    Code
    1. (C.L.engine_consumption_curve_available)
    2. {if}
    3. (L.L.engine_n) (F.L.engine_consumption_per_rpm) 1000 / s2
    4. 1 l2 / 0.845 * s2
    5. (L.L.engine_fuel_used) l0 l2 / s1 + (S.L.engine_fuel_used)
    6. {else}
    7. (L.L.engine_fuel_used) l0 (C.L.engine_fuel_value) / s1 + (S.L.engine_fuel_used)
    8. {endif}


    But it requires the newline in the else part too.


    Thanks the answers in advance!
    ----
    Is it possible to create functions as in c / c++ for example?

  • Sorry, I cannot see your problem... Does this code work or not?


    Functions are possible: If you create a macro which loads or saves values to or from the register (l0, l1, ... s0, s1, ...) then you can bring these values in these registers before the macro starts und you can get them back after the macro quits!

    ;)
  • krtz07:
    I'm trying to add a curve instead of a fixed constant for the fuel consumption.
    I found a scanned factory datasheet where a curve shows fuel consuption per rpm. Also Engine power and torque.
    But it is available only for one engine from the above mentioned three.


    I have the data in g/kWh so I have to convert it into kWh/kg.


    marcel:
    I declared a constant and added to all of the engine const files I use: engine_consumption_curve_available
    For the D2156 HM6U engine the given value is 1, for the D10 engines it's set to 0


    I selected a .bus file which incudes the D10 engine const file and an Error message popped up showing that it needs the engine_consumption_per_rpm curve.


    My question: Is it possible that I should not add (for example a fake curve) if the constant / curve won't be used? As it's evaluated by a constant not a variable.


    ------
    Function: thanks, I will try.

  • Ah, now I understand!


    Yes, this curve has to exist! But the answer is just very easy: If you do not have a curve, just make a "horizontal" curve with just a constant value (and only two [pnt]'s). Then you will not use this constant. Else you can also ADD the constant and create a curve without any correct value (but at least one [pnt]-entry!). But you can not add NO curve, then you will get this error message!

  • Ah, now I understand!


    Yes, this curve has to exist! But the answer is just very easy: If you do not have a curve, just make a "horizontal" curve with just a constant value (and only two [pnt]'s). Then you will not use this constant. Else you can also ADD the constant and create a curve without any correct value (but at least one [pnt]-entry!). But you can not add NO curve, then you will get this error message!


    OK, thanks. Problem solved.

  • I am extremely interested in seeing how this is progressing. I too have fuel consumption curves and can not make heads and tails between the conversion factor and how to implement it. I'll be interested in adding this onto the turbocharger mod.

  • I am extremely interested in seeing how this is progressing. I too have fuel consumption curves and can not make heads and tails between the conversion factor and how to implement it. I'll be interested in adding this onto the turbocharger mod.


    The code is there above. You may use it in the project! Feel free to contact me. (per PM or e-mail)

  • I suppose the code assumes that the fuel consumption rate of 11.8? since that is listed for diesel. Also where does that code go into? the {macro:engine_consumption}?


    I assume this needs to be added to the consist file..


    Now in order to archive an true curve, doesn't the engine_efficiency_rpm curve have to be nulled out somehow?

  • I suppose the code assumes that the fuel consumption rate of 11.8? since that is listed for diesel. Also where does that code go into? the {macro:engine_consumption}?


    Yes, you are right.


    I assume this needs to be added to the consist file..


    Now in order to archive an true curve, doesn't the engine_efficiency_rpm curve have to be nulled out somehow?


    I added a curve, so the rpm value not the same as above. Something like this:


    This case hopefully the whole possible range is covered.

    :)


    I just added this function, and did not changed the code above and below. But you might be right.

  • [pnt] 2800 255 [pnt] 4800 415

    Hmm, are you sure it even works? I tried testing it out by giving the coding an insane highvalue, the fuel percentage should had dropped instantly but it did not. yes I have made some changes to the curve and based it off of that of an D2866, the code posted was not the final result.

  • Hmm, are you sure it even works? I tried testing it out by giving the coding an insane highvalue, the fuel percentage should had dropped instantly but it did not. yes I have made some changes to the curve and based it off of that of an D2866, the code posted was not the final result.


    Using this it looked like the code works: