Results 1 to 4 of 4

Thread: General function question

  1. #1
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default General function question

    Why does this work:

    Simba Code:
    function WalkTowardTile(T : TTile) : Boolean; //Note, its T : TTile, not var T : TTile
    var
      Ti, Me : TTile;
      Tr, tx, ty : Integer;
    begin
      if not LoggedIn then
        Exit;
      Tr := 0;
      Debug('Can''t find next tile. Trying to walk closer.');
      while not TileOnMM(T) do
      begin
        Me := GetMe.Tile;
        tx := (T.x - Me.x)/2 + Me.x;
        ty := (T.y - Me.y)/2 + Me.y;
        Ti := Tile(tx, ty);
        if TileOnMM(Ti) then
          WalkToTile(Ti, 3, 1)
        else
          T := Ti; //I reset the parameter T
        if Tr > 5 then
        begin
          Result := False;
          Exit;
        end;
      end;
      Result := True;
    end;

    I want to know because I've been having problems with my miner & banker lately and I think this may be the issue. The script runs great for awhile, then crashes with a black SMART screen after awhile.

    Can anyone explain to me what exactly is going on when this happens (resetting a parameter in a function like shown above)? I always thought it'd give a compiler error.
    Last edited by doom0791; 03-17-2011 at 07:50 AM. Reason: Correcting my terms. Thanks YoHoJo
    Unfortunately, no active scripts atm.

  2. #2
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Why don't you just add a new variable (A TTile) and set NewTile := Ti, then use it from there?

  3. #3
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by TomTuff View Post
    Why don't you just add a new variable (A TTile) and set NewTile := Ti, then use it from there?
    Thanks, I intend to do that later.

    I'd really like to know what's going on though, just for the sake of knowing. I guess it just irks me to not know why something works when it shouldn't.
    Unfortunately, no active scripts atm.

  4. #4
    Join Date
    Feb 2009
    Location
    Irvine, CA
    Posts
    2,873
    Mentioned
    8 Post(s)
    Quoted
    138 Post(s)

    Default

    Quote Originally Posted by doom0791 View Post
    Thanks, I intend to do that later.

    I'd really like to know what's going on though, just for the sake of knowing. I guess it just irks me to not know why something works when it shouldn't.
    It shouldn't, but it still happens, thus why it's a bug.

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
  •