Page 5 of 6 FirstFirst ... 3456 LastLast
Results 41 to 50 of 60

Thread: Schripting Advice (Tutorial)

  1. #41
    Developer RyBack's Avatar
    Join Date
    Apr 2014
    Location
    In Front of the screen
    Posts
    1,603

    Default

    Can someone test whether adding new scope ie. "{ }" would create a new layer in the stack?

    test:
    local.y = 6
    {
    local.y = 10
    println local.y
    }
    println local.y
    end

    If it prints 10 twice, then it won't be much difference to add these curly brackets.
    If it does 10 then 6, then using these extra brackets I'd highly recommend NOT.
    Also if I'm going brackets way I'd put the bracket in a new line by itself. Helps in readability and avoiding errors.
    Goto is a nono, for the same reasons todes explained, that's just bad software engineering.
    Edit:
    Upon testing, it does print 10 twice, which means that the additional brackets are basically useless.
    Now do it like this:

    main:
    {
    //code here
    }
    end
    Last edited by RyBack; March 25th, 2019 at 12:13 PM.

  2. #42

    Default

    add comments so everyone can understand the code does.
    In my opinion if code needs comments to explain what it does, then coder should think about better names for his variables and functions instead of adding lines to source.

    Well, zappa, these bracket in function names can be treated like your ";" characters at the end of statements, it doesn't make big difference, but it works for you and that's your style, so why not to use it? In my opinion and what works for me, it's a lot more readable to have code looking like this:


    //=========================================================================
    DoObjective1: {
    //=========================================================================
    // iprintln "Objective 1 started"
    level.dasboxset = 0
    level.dasdetonatorset = 0
    thread DelayedTruckStart

    $dastruck_escape triggerable
    $dasdetonator triggerable
    $dasdetonator setthread DasDetonatorSet
    waitframe

    $dastruck_a waittill drive

    while (level.trucksgotaway == 1) {
    wait 10
    }
    }end


    instead of:

    DoObjective1:
    // iprintln "Objective 1 started"
    level.dasboxset = 0
    level.dasdetonatorset = 0
    thread DelayedTruckStart

    $dastruck_escape triggerable
    $dasdetonator triggerable
    $dasdetonator setthread DasDetonatorSet
    waitframe
    $dastruck_a waittill drive

    while (level.trucksgotaway == 1)
    wait 10
    end


    Or other weird creations.
    Github - Steam - .Crimewavez#5285

  3. #43

    Default

    I just wanted to add that I appreciate Chrissstrahl's guide and what he's doing, same for anyone helping keep these games alive and contributing to the community . Most of it I do agree with.

  4. #44

    Default

    Quote Originally Posted by 1337Smithy View Post
    I just wanted to add that I appreciate Chrissstrahl's guide and what he's doing, same for anyone helping keep these games alive and contributing to the community . Most of it I do agree with.
    Thanks

  5. #45

  6. #46

    Default

    @Zappa
    I am kinda disappointed that you didn't use the opportunity to provide constructive suggestions for improvement, I was hoping for that rather than what you wrote instead .

    I have updated the Document again, after Todesengel pointed out that cfg files in mohaa do not have the typical 8KB limit.
    Last edited by chrissstrahl; September 14th, 2019 at 09:05 AM.

  7. #47
    Senior Member Major A's Avatar
    Join Date
    Aug 2014
    Location
    Indiana, USA
    Posts
    110

    Default

    I just wanted to add that, for me, if it wasn't for commenting what certain things do, I'd get lost in my own work repeatedly trying
    the same thing over and over that doesn't work (playing with torso mostly ) so I comment them to tell me I've already tried something.
    My scripting things isn't that strong as it is, and seeing things commented on what a line does actually helps me.
    I'm not picking on anyone, just saying I like how the pdf is done.

    In the first map I did, had I not commented my shitters, I'da been lost lolol
    Code:
    thread jumpspot1       //to the hole... lol
    //thread jumpspot2     //unused atm
    thread sounds          //sounds, duh, Major Dumbass :P
    thread teleporter1     //to the awesomeness or vehicle every other teleport
    thread teleporter2     //exit awesomeness
    thread HULK_SMASH      //death from above
    thread shitter_tele    //Allied shitter1 quick tele to the awesomeness
    thread shitter1        //Allied shitter1 south, same as tele
    thread shitter2        //Allied shitter2
    thread shitter3        //Axis shitter1
    thread shitter4        //house shitter
    thread shitter5        //axis shitter 2 south
    thread drip            //sewer cross section ambient
    thread klink_forms     //he's sorry :P
    thread wasted          //superfly
    thread guns            //need more gun juice
    thread holy_grenade    //go away before I taunt you a second time :P lolol
    I realize that's not inside the working code stuff to do on the threads actions itself, just saying this is a easy way to keep track of stuff in this situation.

    As constructive suggestions go, working examples are always cool, just sayin' :P
    Last edited by Major A; March 27th, 2019 at 05:41 PM.

    ASUS P8B75-M * Quadcore 3.1GHz * 32GB ram * GT740 4GB video * Logitech USB Marble Mouse=Trackball * System - ArchLinux-EndeavourOS, KDE Plasma Desktop * Triple monitor

  8. #48

    Default

    Quote Originally Posted by chrissstrahl View Post
    @Zappa
    I am kinda disappointed that you didn't use the opportunity to provide constructive suggestions for improvement, I was hoping for that rather than what you wrote instead .
    I'm sorry, but I don't see and end point in this kind of discussion
    It kinda feels like when people talks about politics, religion or football teams.
    People can have valid arguments in both sides, but you'll never change the mind of the other side.

    That's why I said everything is subjective.

    I still think a guide must be 100% objective, and not include any personal preference like "this make the code more readable" or "don't use this".
    But that's only my opinion.

  9. #49
    Senior Member Major A's Avatar
    Join Date
    Aug 2014
    Location
    Indiana, USA
    Posts
    110

    Default

    @Zappa, I whole heatedly agree! That's why I said what I like about comments but didn't want to project any disappointment at anyone.
    I do see the point about, don't use this....part...I have 1 or 2 goto's in a couple places :P

    If it ain't broke thing comes to mind alot for me haha

    EDIT...THINKING BACK, I'm not sure I've used goto but maybe once, and I may have changed it as well just because of the nature of what
    I was doing at the time, but as you stated, it's subjective to the need at hand.....now I'm curious what I used it on....maybe I commented it someplace LMAO
    Last edited by Major A; March 27th, 2019 at 10:05 PM.

    ASUS P8B75-M * Quadcore 3.1GHz * 32GB ram * GT740 4GB video * Logitech USB Marble Mouse=Trackball * System - ArchLinux-EndeavourOS, KDE Plasma Desktop * Triple monitor

  10. #50
    Developer Todesengel's Avatar
    Join Date
    Dec 2013
    Location
    St. Louis, Missouri, USA
    Posts
    276

    Default

    As Zappa says... there is generally no 'one true way' and many things related to this topic are subjective. He's absolutely right. That being said....

    In the past, I don't recall seeing much content along the lines of 'best practices' for scripting and the guide reinforces some critical material (coding style, variable scope, & parm for example) that may not be obvious to beginners. I don't think anyone was putting this guide forth as "here is the new coding standard and we must all adhere to it henceforth", it's just suggestions for good coding and you have to admit, having a document like that is a GREAT asset and was sorely needed. That being said....

    I think that people with different suggestions on coding style should either contribute to this one - or write another scripting advice document and send it off to the mod/tutorial database too! I would be thrilled if new scripters had as many viewpoints and suggestions as possible on writing code. It'd be awesome if new scripters could digest several different viewpoints and create their own style with the necessary background to make good choices.

    Tode

Posting Permissions

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