Results 1 to 10 of 10

Thread: SendInterSCARMessage / ReadInterSCARMessage question

  1. #1
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default SendInterSCARMessage / ReadInterSCARMessage question

    mkay, so i was looking through the scar help file and i came across : procedure SendInterSCARMessage(id, message: string);
    and
    function ReadInterSCARMessage(id: string): string;


    so i thought they where cool so i made a simple script, where one sends a message and one recieves, but i noticed that you can only recieve it if you specify what you want to recieve example:

    SCAR Code:
    program New;
    begin
    if(ReadInterScarMessage('lol') = 'noob' ) then
    begin
    writeln('noob');
    SendInterSCARMessage('lol', 'nou');
    end;
    end.

    but, my question is how would i make it say what ever the first script says, without specifying in the second script?

    i can picture this being really fun and usefull
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Messages are sent on "channels" and they can contain anything you want. You just have to read it on the channel you specified in the sender.

  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    wait, so how would that look on the reciever?
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program new;

    var
      s : string;

    begin
      repeat
        s := ReadInterSCARMessage('Channel');
      until(s <> '');
      writeln(s);
    end.
    Last edited by Da 0wner; 04-20-2009 at 10:17 AM. Reason: standards wtf

  5. #5
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    wewt =D thanks

    also, go ahead and someone say something on "lol"
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  6. #6
    Join Date
    Mar 2007
    Posts
    1,700
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Here's a few of my ISM functions, feel free to use.
    SCAR Code:
    procedure Send(ID: string; val: Variant);
    begin
      case VarType(val) of
        11: SendInterSCARBoolean(ID, val);
        5: SendInterSCARExtended(ID, val);
        3: SendInterSCARInteger(ID, val);
        256: SendInterSCARMessage(ID, val);
      end;
    end;

    function Get(ID: string; TimeOut: integer): Variant;
    var
      a: integer;
    begin
      a := GetSystemTime;
      repeat
        if GetSystemTime - a > TimeOut then
        begin
          Writeln('Timed out getting '+ID);
          TerminateScript;
        end;
        case GetType(ID) of
          11:
            begin
              Result := ReadInterSCARBoolean(ID);
              if Result then Exit;
            end;
          5:
            begin
              Result := ReadInterSCARExtended(ID);
              if Result > 0.0 then Exit;
            end;
          3:
            begin
              Result := ReadInterSCARInteger(ID);
              if Result > 0 then Exit;
            end;
          256:
            begin
              Result := ReadInterSCARMessage(ID);
              if Result <> '' then Exit;
            end;
        end;
        Wait(100);
      until False;
    end;

    procedure Recieve(ID: string; Target: Variant; TimeOut: integer);
    var
      a: integer;
    begin
      a := GetSystemTime;
      while GetSystemTime - a < TimeOut do
      begin
        if Get(ID, 500) = Target then
          Exit;
        Wait(100);
      end;
    end;

    Btw my GetID function looks like this
    SCAR Code:
    function GetType(ID: string): integer;
    var
      Int, Ext, Bool, Str: integer;
    begin
      Int := 3; Ext := 5; Bool := 11; Str := 256;
      case ID of
        'World': Result := Int;
        'Ready': Result := Bool;
        'Player1': Result := Str;
        'Player2': Result := Str;
        //etc
      end;
    end;

  7. #7
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    >.>

    saturn, you shoulda been a dev forever ago

    (btw, Frt uses this as an auto responder you might wanna check it akward)

  8. #8
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    iv also noticed something =[

    both scripts have to be open for one to recieve what the sender said, as in you cant have the sender something, then the reciever opens up the script, and sees what he said =\
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  9. #9
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You can. You just have to have the sender constantly sending something :d.

  10. #10
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    SCAR Code:
    program new;

    var
      s, ss : string;

    begin
      repeat
        repeat
          s := ReadInterSCARMessage('lol');
        until(ss <> s);
        writeln(s);
        ss := s;
      until false
    end.

    And that would continue reading messages as long as they are different.
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

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
  •