Results 1 to 14 of 14

Thread: What does this mean?

  1. #1
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default What does this mean?

    This is a snippet from Sky Scripter's Gametab quickfix posted in the Snippets section.

    SCAR Code:
    xx := 526 + (33 * (i mod 7));

    I was wondering what the mod meant in
    (i mod 7)
    Hope I'm not too nooby, I think this is one of those things I'm supposed to know, I just never learned

    Hope someone can explain, Thanks!

  2. #2
    Join Date
    May 2007
    Location
    baltimore, md
    Posts
    836
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    i had the same question basically it divides i by 7 and returns the remainder.

    so i mod x would return the remainder of i/x

  3. #3
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    10 mod 3

    It does 10/3 then returns the remainder...which is 1...
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  4. #4
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Wow weird, thanks guys

  5. #5
    Join Date
    May 2007
    Location
    baltimore, md
    Posts
    836
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    weird, but useful. for example if you want to do something every other time
    if i mod 2 = 0 then

    that would do something on every even number.

  6. #6
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Yeah I bet there are a lot of nifty uses for it, and I bet you could do some crazy math stuff too.

  7. #7
    Join Date
    Feb 2006
    Location
    New Zealand
    Posts
    1,330
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Mostly useful for loads in scripts. Example if every 2 loads on a player you want to drop without losing how many loads you have actually done.. so...

    loads:= 2

    if(players[currentplayer].integer1 mod loads = 0 ) then nextplayer:=true

    that means when the player has done two loads it will switch. Then next timem it comes round when the player has done 4 loads etc etc etc up in twos. Or 3's if you make it that way

  8. #8
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    I knew how to use mod, but not what to use for. thx

  9. #9
    Join Date
    Jul 2007
    Location
    UK
    Posts
    307
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    The Problem with most tutorials is that they don't give out alot of pascal operator information

  10. #10
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Yeah foreal, but I'm learning lots of little things like this with help from you guys

    And Pyro I think I'm going to put that in my script

  11. #11
    Join Date
    Jun 2007
    Location
    I'm not sure...
    Posts
    581
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It just saves you from resetting the loads variable. That actually is a great idea because then you could put it in your proggie so you can see the total amount of loads.
    ---------------------------------------------------------


    Pm me if you need any math functions made. Me = l0ving t3h mathz

    ---------------------------------------------------------

  12. #12
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Yeah I think I have 2 variables Loads and TotalLoads, and before I reset Loads I add Loads to TotalLoads and report TotalLoads in my proggie.

  13. #13
    Join Date
    Apr 2007
    Location
    Michigan -.-
    Posts
    1,357
    Mentioned
    2 Post(s)
    Quoted
    4 Post(s)

    Default

    lol i didnt even know what that meant...

    ty i understand now
    METAL HEAD FOR LIFE!!!

  14. #14
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Good to know it helped an SRL Member too

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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