Randomizing variable in script

Willkommen in der OMSI-WebDisk!
Als Gast kannst du nur Inhalte in deiner ausgewählten Sprache sehen. Registrierte Nutzer können die Sichtbarkeit anderer Sprachen in ihrem Kontrollzentrum aktivieren, weitere Infos hier.
Alle Themen sind in den Foren mit einer Sprachflagge gekennzeichnet: = Englisch [EN], = Deutsch [DE], = Französisch [FR]. Wenn du die angegebene Sprache nicht beherrschst, schreibe auf Englisch!
  • 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:

  • Anzeige
  • Omsi actually has an random Operator:)


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

    Code
    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

    java.lang.StackOverflowError


    forum.png


    Kein Support über DM/PM

    Einmal editiert, zuletzt von MeerrettichMeister ()