Results 1 to 10 of 10

Thread: Bug in MakeCompass.

  1. #1
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default Bug in MakeCompass.

    Well this isn't a question but a bug. You all know the MakeCompass command i guess well there is a small bug in it, which means you always turn the long way instead of the small one. To fix this do the following:

    Go to Srl\core\MapWalk.scar

    at line 94 and 95 you should see this
    SCAR Code:
    if StartPos > EndPos then Left_Right := True
        else if StartPos < EndPos then Left_Right := False

    Change it to:
    SCAR Code:
    If (LowerCase(Side) = 'n') or (LowerCase(Side) = 's') then
      begin;
        if StartPos > EndPos then Left_Right := False
        else if StartPos < EndPos then Left_Right := True
        else exit;
      end else
      begin;
        if StartPos > EndPos then Left_Right := True
        else if StartPos < EndPos then Left_Right := False
        else exit;
      end;
    Now it will always rotate the shortest way .
    Verrekte Koekwous

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

    Default

    Thanks!

  3. #3
    Join Date
    Jun 2007
    Location
    England
    Posts
    262
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice, not that it makes much of a difference though

  4. #4
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Not sure about that, consider these two scenarios:

    If our StartPos is 10 degrees and EndPos 330 degrees, then the shortest way will be to rotate leftwards. StartPos < EndPos therefore Left_right will be true.

    However, If our StartPos is 350 degrees and EndPos 320 degrees, then the shortest way will be to rotate leftwards. StartPos > EndPos therefore Left_right will be False (This is now not the shortest way to rotate the compass!)

    Its not as easy as that
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  5. #5
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Starblaster100 View Post
    Not sure about that, consider these two scenarios:

    If our StartPos is 10 degrees and EndPos 330 degrees, then the shortest way will be to rotate leftwards. StartPos < EndPos therefore Left_right will be true.

    However, If our StartPos is 350 degrees and EndPos 320 degrees, then the shortest way will be to rotate leftwards. StartPos > EndPos therefore Left_right will be False (This is now not the shortest way to rotate the compass!)

    Its not as easy as that
    Yes i know that, i found that problem too. I don't know when i changed this it mostly turns the shortest way. So i consider it as a bug ^^. If you don't, please remove this topic because it doesn't makes sense then. I have got a way to fix this, if you want me to i can do it I think it is because i tested it at makeCompass('n')
    Verrekte Koekwous

  6. #6
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    There is no need to delete the topic. However, if you want to, I know you have the option to delete your own topic.

    It's a good challenge - making a procedure to rotate the compass the shortest distance. It took me a good hour to get my head around the maths
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  7. #7
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    How about something like this:

    SCAR Code:
    program New;

    procedure CompassDir(Start, Angle: Integer);
    var
      Left: Boolean;
    begin
      if Min(iAbs((Angle - (360 + Start)) mod 360), iAbs((Angle - (180 + Start)) mod 360)) = iAbs((Angle - (360 + Start)) mod 360) then Left := True;
      if Left then WriteLn('Turn Left!') else WriteLn('Turn Right!');
    end;

    begin
      CompassDir(0, 350);
    end.

    The actual line you need:

    SCAR Code:
    Min(iAbs((Angle - (360 + Start)) mod 360), iAbs((Angle - (180 + Start)) mod 360)) = iAbs((Angle - (360 + Start)) mod 360) then Left := True;

    Where Start is the Starting angle and Angle is the EndAngle.
    Hup Holland Hup!

  8. #8
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Check first post i found it, it works 100%. Please edit my bug tracker to! I tested it and it works at all angles etc. .
    change it to:
    SCAR Code:
    If (LowerCase(Side) = 'n') or (LowerCase(Side) = 's') then
      begin;
        if StartPos > EndPos then Left_Right := False
        else if StartPos < EndPos then Left_Right := True
        else exit;
      end else
      begin;
        if StartPos > EndPos then Left_Right := True
        else if StartPos < EndPos then Left_Right := False
        else exit;
      end;
    Verrekte Koekwous

  9. #9
    Join Date
    Jun 2007
    Posts
    69
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  10. #10
    Join Date
    Apr 2007
    Location
    The Buckeye State
    Posts
    482
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    still makes the compass whatever direction the long way.
    I like my coffee black just like my metal.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. MakeCompass... help?
    By Jakez27 in forum OSR Help
    Replies: 16
    Last Post: 12-23-2008, 03:44 PM
  2. MakeCompass?
    By Naum in forum OSR Help
    Replies: 7
    Last Post: 01-18-2008, 09:31 PM
  3. MakeCompass
    By passiondrive in forum OSR Help
    Replies: 2
    Last Post: 07-05-2007, 05:03 PM
  4. MakeCompass('n')
    By del_signo in forum OSR Help
    Replies: 5
    Last Post: 02-28-2007, 11:40 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
  •