Results 1 to 4 of 4

Thread: Integer Problem

  1. #1
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Integer Problem

    in my current script, i am attempting to make the antirandom function work every three casts of the certain spell

    i have my integer "I" set up to each time after the spell Go "+1" and then i did what i thought logical and did "if (I:= 3+random(2) * X) then Begin, antirandom; end" but it doesnt work

    SCAR Code:
    if (I := 3+random(2) * X) then
        begin
         Antirandom;
        end

    it compiles and everything, and when I=3 it does the antirandom, but not everytime it is a multiple of three.

    any suggestions on how to make this work?
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  2. #2
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Use the mod function:
    SCAR Code:
    var
      p : integer;

    begin
      p := 3;
      if ((i mod p) = 0) then AntiRandom;
    end;

    More info on using the 'mod' function here.

    And NOTE that when comparing something you use '=' instead of ':='
    := is used when declaring something.
    = is used when comparing something.

    EX.
    SCAR Code:
    a := 3; //makes 'a' equal 3
    if (a = 3) then DOTHIS; //compares 'a' to 3 and if 'a' IS 3 does what you tell it

    Hope this helps =]
    Derek-

  3. #3
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok thanks, i'm gonna try it now, and i think i had the "=" instead of ":=" in the first place, but i was changing so many things around i thought that was one of the things i did wrong and switched it back

    EDIT: Would i need to Declare a seperate variable to say "p := 3" or could i just use "3"?
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  4. #4
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    No, you can just use 3:
    SCAR Code:
    if (i mod 3)=0) then

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. function SendKeyboard(FKey:Integer; Text:String): Integer;
    By Daniel in forum Research & Development Lounge
    Replies: 4
    Last Post: 07-18-2007, 04:28 PM

Posting Permissions

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