Results 1 to 8 of 8

Thread: Case..Of Help

  1. #1
    Join Date
    Feb 2007
    Posts
    142
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Case..Of Help

    I didn't want to say thanks to everyone who was helping me in my other threads because i didn't want to bump my thread up and get a cheap post count

    so here, Thank You Markus, JackLKrawl, and Mixster05 for helping me out

    however, I've come to a standstill again, I don't know how to word this right, so i'll start by saying here's what i'm trying to do
    SCAR Code:
    begin
    if Players[CurrentPlayer].loc = 'End' then
      begin
        Case rs_GetCompassAngleDegrees of
      {N} 0:Begin
               XCoord:=700;
               YCoord:=266;
               RandomX:=1;
               RandomY:=2;
            end;
      {W}90:begin
               XCoord:=729;
               YCoord:=182;
               RandomX:=2;
               RandomY:=1;
             end;
      {S}180:Begin
               XCoord:=681;
               YCoord:=68;
               RandomX:=1;
               RandomY:=2;
             end;
      {E}270:Begin
               XCoord:=778;
               YCoord:=297;
               RandomX:=2;
               RandomY:=1;
             end;
        end;
        mouse(XCoord, YCoord, RandomX, RandomY, True);
        FFlag(0);
        Players[CurrentPlayer].loc := 'Beginning';
      end;
    end;

    I keep getting a type mismatch error, i've been reading around for a fix and i can't seem to find the problem, however i'm not sure i can write the degrees like that

    i was thinking of writing something like
    SCAR Code:
    E:= 260<E<280;
    and setting this value into my 'case of' function

    if that works then (quick nooby question) how would i denote a negative for north, does a (-) work? so i can do
    SCAR Code:
    N:= -10<N<10

    any help is much appreciated and here's a thank you in advance
    Thanks!

  2. #2
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    first of all you always need somthing that gives you a number at here:
    ase rs_GetCompassAngleDegrees(9) of

    like you see you use 4 thingy's so you will put (3) 0 to 3(0,1,2,3)
    but this time that will won;t work bc you only wanna use the number 90,180,270,360 but if you fill in 359 it will choose most of the time not the 90,180,270,360
    that was just somthing about it but i didn't solve it like you see just trying to help

    Hermpie
    ~Hermen

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

    Default

    Doesn't rs_GetCompassAngleDegrees return a number?
    function Function rs_GetCompassAngleDegrees: Extended;
    By: Wizzup
    Description: Returns the compass angle in degrees.

  4. #4
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ow, lol but if he was using it he should read the above ...
    ~Hermen

  5. #5
    Join Date
    Feb 2007
    Posts
    142
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    k, kinda confused, sorry

    @Hermpie
    first of all you always need somthing that gives you a number at here:
    ase rs_GetCompassAngleDegrees(9) of
    this doesn't make sense to me, rs_GetCompassAngleDegrees is already a function, i can't tag on a (9) or any number and it work correctly can i?

    @Psychor
    Doesn't rs_GetCompassAngleDegrees return a number?
    i thought that is why i could write the procedure like i did above, because if it returns the compass angle as (X Degrees) then set the coords to XCoord,YCoord etc.

    thanks for helping, i'm still not understanding it though

  6. #6
    Join Date
    Jun 2007
    Location
    Belgium
    Posts
    333
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i thought that is why i could write the procedure like i did above, because if it returns the compass angle as (X Degrees) then set the coords to XCoord,YCoord etc.[/QUOTE]

    I'm not an expert, but the rs_GetCompassAngleDegrees returns a angle as an extended, maybe that's the reason you get the type mismatch error.

  7. #7
    Join Date
    Dec 2007
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I believe you'll need Round(rs_GetCompassAngleDegrees). Round converts an extended to an integer.
    But be aware that it'll round the variable up or down. 5.1 in extended will be 5 in integer, and 5.5 in extended will be 6 in integer.
    This sentence is false.

  8. #8
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Gumleren is right with fixing the type mismatch. With the case, I would say either make a sperate procedure/function that gets the compass angle then determines whether or not it's between 45 and 135 for east etc. Otherwise, just have a series of If() Else If()'s to get it to face the right angle, as with cases, you would have to have 360 numbers.
    Edit: Thanks for the thanks

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Case help
    By Aser in forum OSR Help
    Replies: 3
    Last Post: 11-22-2008, 05:21 AM
  2. Using Case and Of
    By Fourscape in forum Outdated Tutorials
    Replies: 3
    Last Post: 08-18-2007, 08:40 PM
  3. Case - Else
    By stylen in forum OSR Help
    Replies: 0
    Last Post: 05-30-2007, 11:54 PM
  4. Case OF
    By Jagex_Fagex in forum News and General
    Replies: 3
    Last Post: 10-25-2006, 08:45 AM

Posting Permissions

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