Randomizing variable in script

Welcome to the OMSI-WebDisk!
As guest you can only see content in your selected language! Registered users can choose the visibility of other languages in their control panel, more informations here. All topics are marked with a language flag inside the forums: = English [EN], = German [DE], = French [FR].
If you're not able to speak the topic language than write in English!
  • Moin,

    I'm working on Baseline script, and I'm in dead point, as I have no idea how to randomise errors. Idk if it's possible to randomise something with end to end numbers. I wanted originally to randomise number between 0 and 1000, with about 80 error messages in script that would mean 8% chance of showing up random error message. It would randomise it every restart of elec_busbar_main.

    In another words:

    Random 0 - 1000 S.L.error_prob

    With randomised number on variable error_prob, every single message would have it's unique ID, so for example FFR MUX would have error_prob ID of 420, so if script randomised at start number 420 it would popup. Can't actually say what I figured out there, but I hope someone that is better in scripts than me would help.

    Danke! :cheers:

  • Advertisement
  • Omsi actually has an random Operator:)

    So you coud basically set your limit in Stack 0 like this

    1001 random S.L.error_prob

    Since 1000 should be included

    Depending on on your need you could make a Macro so you can just call this rng whenever you need it.

    Im not exactly sure how to pass the number to the specific error without a huge if-else block since i belive omsi has nothing like a switch operation

    I belive the best way would be to call this rng whenever there ist the possibility for an error to occur