Page 3 of 6 FirstFirst 12345 ... LastLast
Results 21 to 30 of 60

Thread: Schripting Advice (Tutorial)

  1. #21
    Administrator James's Avatar
    Join Date
    May 2010
    on the intraweb


    @chrissstrahl Reborn uses try catch in it's code (in the gamex wrapper), but what I was referencing was to see if try\catch is also a stock command that can be used with MOHAA scripts(with or without Reborn).

    Here are a few examples:

    @Ryback, I get what you mean now with cluttered code. I don't think using try/catch like that would be very ideal either. It would be extremely tedious, what I would do is only put it in main functions or loops where you're executing stuff.

    Also, I just had a thought... I don't know if this is possible but let me try to explain my theory...
    In mohaa there are several mods that use common files like mikes torso, legs, dmprecache (just to name a few). This is probably the single most probable cause of mod incompatibility when there are servers running multiple mods...

    I had an issue like this when I was making something in powershell...
    What I did was instead of trying to modify an existing file, I wrote a code block that "executes what I need" without touching the original file.

    What I am suggesting is this...
    Instead of modifying the original dmprecache file to execute your code can something like this be done..

    1. Read the contents of the original precache file (maybe this isn't even needed (not sure))
    2. Append a code block from within your script to "exec my\folder\path\myScript.scr"
    3. And let it execute on the fly from there

    I'm not sure if this is possible, but it was just another crazy thought I had.

  2. #22


    I am not sure if that can be done just by scripting, but I doubt it.
    It would be pretty unreliable because someone else might have modified the code...

    I know of these parm queries and how they are being used, does anyone know a few more and in what relation they are ?

  3. #23


    I have made again a few updates to the file (see attachment).
    I plan to add:
    • why to use switch instead of if/else
    • why and when to use try/catch
    • when to use continue
    • when to use break
    • how to avoid a runaway loop error in for/while
    • what self actually is
    • how to use parm. to get certain values from entities/threads

    I am looking forward to your continuous insight/opinion/advice for the above

    I have noticed that I have not got the faintest idea what group. variable prefix does do and how it is utilized...

    I am afraid this is almost a how to do scripting tutorial.
    Last edited by chrissstrahl; July 18th, 2018 at 04:16 PM.

  4. #24


    It relates to a group of threads. So if a thread is created within another thread they are then part of the same group scope. Not particularly useful most of the time, or should I say I've not really seen a need for it much.
    Last edited by 1337Smithy; July 10th, 2018 at 03:35 PM.

  5. #25


    Hmmm, that sounds actually useful
    Is there some example in a script, this could be interesting for something complex like a coop mod, maybe.

  6. #26


    Oh I'm sure there are good use cases, I just don't use it much in the stuff I've worked on. I know I've seen it used by jv_map in his stuff like the flying mod etc... It's not common though.

  7. #27


    global/scientist_standtable.scr does use group

  8. #28


    Yeah, I haven't looked in that script for a while but I guess it's used just as the level scope would be? It is useful though as it keeps that script contained and doesn't conflict with the rest of your level and means you don't have to paramaterise your functions.
    Last edited by 1337Smithy; July 11th, 2018 at 01:58 PM.

  9. #29


    I think it is used in a different context here and has to do with ai grouping, but I did not really take time to check it out, because I was compiling a list.

  10. #30


    I have updated the document again, added loops (for and while).
    And I have included examples for continue and break.
    Not very good examples but I guess they will do

    As always feedback is welcome.
    Last edited by chrissstrahl; March 14th, 2019 at 01:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts