Results 1 to 7 of 7

Thread: Help compileing a function

  1. #1
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Help compileing a function

    So ive qucikly made a function of looking though the reflection inclued for my scirpt im making which is a mining guild.

    So its meant to have the tile of a rock, and check if poeple are near it by checking the 4 tiles around it, N E S W cuz cant mine from top right and stuff. Then check it they are mining, then check if they are mining on that rock.

    Any help to compile if it would work and the such would be great thanks.

    Simba Code:
    Function CheckRock(TileX:TTile):Boolean;
    Var PlayerArray,PlayersNearRock:TPlayerArray;
        I:Integer;
        PointT :TPoint;
        a,b,c,d:TTile;
    Begin

      If Not LoggedIn Then Exit;
      writeln('Starting - CheckRock');

      PointT := TileToPoint(TileX)
      a := Tile((PointT.x+1),PointT.y)
      b := Tile((PointT.x),(PointT.y+1))
      c := Tile((PointT.x-1),PointT.y)
      d := Tile(PointT.x,(PointT.y-1))
      PlayerArray := GetAllPlayers

      For I:=0 To High(PlayerArray) Do
      Begin
        If (PlayerArray[I].Tile = A) Or (PlayerArray[I].Tile = B) Or (PlayerArray[I].Tile = C) Or (PlayerArray[I].Tile = D) Then
        Begin
          PlayersNearRock := PlayersNearRock + PlayerArray[I]
          writeln('CheckRock - Added player to an array');
        End;
      End;
                                //Not sure what it is :(
      If High(PlayersNearRock) = 0 or -1 Then
      Begin
        Result := True
        writeln('No players found near rock');
        Exit;
      End;

      For I:= 0 To High(PlayersNearRock) Do
      Begin
        If (GetAnimation = -1) Then
        PlayersNearRock := PlayersNearRock - PlayersNearRock[I]
      End;

      If High(PlayersNearRock < 0 ) Then
      Begin
        writeln('CheckRock - No players left in array');
        Result := True
        Exit;
      End;

      For I:= High(PlayersNearRock) DownTo 0 Do
      Begin
        If PlayersNearRock[I].Tile = a Then
          If PlayersNearRock[I].Orientation = 90 Then
          Begin
            writeln('Player facing rock and animating dang :(');
            Result := False
            Exit;
          End;
        If PlayersNearRock[I].Tile = b Then
          If PlayersNearRock[I].Orientation = 0 Then
          Begin
            writeln('Player facing rock and animating dang :(');
            Result := False
            Exit;
          End;
        If PlayersNearRock[I].Tile = c Then
          If PlayersNearRock[I].Orientation = 270 Then
          Begin
            writeln('Player facing rock and animating dang :(');
            Result := False
            Exit;
          End;
        If PlayersNearRock[I].Tile = d Then
          If PlayersNearRock[I].Orientation = 180 Then
          Begin
            writeln('Player facing rock and animating dang :(');
            Result := False
            Exit;
          End;
      End;
    End;

    Thanks
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  2. #2
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    What does it say when you are trying to compile? Do you get any errors?

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  3. #3
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yh i do get errors
    The first one i get is this line
    Simba Code:
    writeln('CheckRock - Added player to an array');
    Code:
    [Error] (42:7): Type mismatch at line 41
    And im sure there is more further in
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  4. #4
    Join Date
    Mar 2006
    Posts
    13,241
    Mentioned
    228 Post(s)
    Quoted
    267 Post(s)

    Default

    First problem is the lind above the writeln is missing a ;

    Second is you have playersnearrock declared as a TPlayerArray and then you go and try to assign tile values to it. Change it to a TTileArray or the equivalent.
    STOP PM'ING ME

  5. #5
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Umm where do i try to use a tile to it, i thought i was using the player type?
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  6. #6
    Join Date
    Jun 2007
    Location
    La Mirada, CA
    Posts
    2,484
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Code:
    PlayersNearRock := PlayersNearRock + PlayerArray[I]
    You don't add to arrays in this manner. That is like doing 'Cars = Cars + Bikes;' you can't add two totally different things.

    Here you are adding an array element and an array, just doesn't work.

    You need to learn more about arrays from a tutorial around here. It should be added like...

    Code:
    SetLength(array, GetArrayLength + 1);
    array[index] = item to be inserted;
    //etc.. or something like that, look into it
    Hope this helps

    "Failure is the opportunity to begin again more intelligently" (Henry Ford)


  7. #7
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    648
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks that works great i have it compileing now, all i need to do is test it
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

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
  •