Results 1 to 10 of 10

Thread: hey it doesnt work

  1. #1
    Join Date
    Sep 2010
    Location
    Azeroth
    Posts
    395
    Mentioned
    0 Post(s)
    Quoted
    17 Post(s)

    Default hey it doesnt work

    hey guys here i have an example that doesnt work... this is my basic script but theres an issue, i thought it was scar but its not working even in simba...
    here ill try to elaborate as much as possible
    Simba Code:
    var
    buf,img,xpos,ypos:integer;
    procedure procedure2(pos,int:integer);      //rite here... the int as you can
    begin                                                   //see , okay well the calculation
      pos:=int                                             //does not happen, i can supply
      FastDrawTransparent(xpos,ypos,img,buf) //more examples but if you
      DrawBitmapDebugImg(buf)                    //writeln(pos)somewhere in there
    end;                                                   //you can see nothing happens...
    function function1:integer;
    var
    i:integer;
    begin
      for i:=37 to 40 do
        begin
          if IsKeyDown(i)then
            result:=i;
        end;
    end;
    procedure procedure1;
    begin
      case function1 of
        37:begin
             writeln('1')
             procedure2(xpos,xpos-1)
           end;
        38:begin
             writeln('2')
             procedure2(ypos,ypos-1)
           end;
        39:begin
             writeln('3')
             procedure2(xpos,xpos+1)
           end;
        40:begin
             writeln('4')
             procedure2(ypos,ypos-1)
           end;
      end;
    end;
    begin
      img:=BitmapFromString(10,10,'')
      buf:=CreateBitmap(300,300)
      FastDrawClear(img,255)
      xpos:=150
      ypos:=150
      displaydebugimgwindow(300,300)
      procedure2(xpos,xpos+0)
        repeat
          procedure1
        until IsKeyDown(27)
    end.

  2. #2
    Join Date
    Jan 2012
    Location
    Netherlands
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    procedure2 is kinda working, but:
    xpos / ypos will become 149, 150 or 151
    The variables xpo, ypos is never stored
    Meaning: your program only shifts the pixel by one, but dont worry.

    Ive got it working:

    Simba Code:
    program Testing;
       
    {$DEFINE SMART}

    var
      buf, img, xpos ,ypos : Integer ;

    procedure procedure2 ;
    begin

      FastDrawTransparent( xpos, ypos, img, buf )
      DrawBitmapDebugImg( buf )

    end;

    function function1 : integer ;
    var
      i : Integer ;
    begin

      for i:=37 to 40 do begin
      if IsKeyDown(i)then
        Result:=i;
      end;
    end;

    procedure procedure1;
    begin

      case function1 of

        37:begin
          writeln('left')
          dec( xpos ) ;
          procedure2 ;
        end;

        38:begin
          writeln('Up')
          dec( ypos );
          procedure2 ;
        end;

        39:begin
          writeln('Right')
          inc( xpos ) ;
          procedure2 ;
        end;

        40:begin
          writeln('Down')
          inc( ypos );
          procedure2 ;
        end;

      end;

    end;

    begin

      img:=BitmapFromString(10,10,'') ;
      buf:=CreateBitmap(300,300) ;
      FastDrawClear(img,255) ;
      xpos:=150 ;
      ypos:=150 ;
      displaydebugimgwindow(300,300) ;
      procedure2 ;

      repeat
        procedure1
      until IsKeyDown(27)

      FreeBitmap( buf ) ;

    end.

  3. #3
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Simba Code:
    procedure procedure2(pos,int:integer);      //rite here... the int as you can
    begin                                                   //see , okay well the calculation
      pos:=int                                             //does not happen, i can supply
      FastDrawTransparent(xpos,ypos,img,buf) //more examples but if you
      DrawBitmapDebugImg(buf)                    //writeln(pos)somewhere in there
    end;

    Change to:
    Simba Code:
    procedure procedure2(pos:integer);      //rite here... the int as you can
    begin                                                   //see , okay well the calculatio                                        
      FastDrawTransparent(xpos,ypos,img,buf) //more examples but if you
      DrawBitmapDebugImg(buf)                    //writeln(pos)somewhere in there
    end;

    Now, when you are like procedure2(10);
    Pos = 10; You had an extra variable in there for no reason.

  4. #4
    Join Date
    Jan 2012
    Location
    Netherlands
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by NKN View Post
    Simba Code:
    procedure procedure2(pos,int:integer);      //rite here... the int as you can
    begin                                                   //see , okay well the calculation
      pos:=int                                             //does not happen, i can supply
      FastDrawTransparent(xpos,ypos,img,buf) //more examples but if you
      DrawBitmapDebugImg(buf)                    //writeln(pos)somewhere in there
    end;

    Change to:
    Simba Code:
    procedure procedure2(pos:integer);      //rite here... the int as you can
    begin                                                   //see , okay well the calculatio                                        
      FastDrawTransparent(xpos,ypos,img,buf) //more examples but if you
      DrawBitmapDebugImg(buf)                    //writeln(pos)somewhere in there
    end;

    Now, when you are like procedure2(10);
    Pos = 10; You had an extra variable in there for no reason.
    The script will stil get a xpos / ypos with the following values: 149-150-151.
    xpos and ypos are relative from 150,150

  5. #5
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by kazhual View Post
    The script will stil get a xpos / ypos with the following values: 149-150-151.
    xpos and ypos are relative from 150,150
    Okay...?
    What's your point?
    I fixed what he asked.

  6. #6
    Join Date
    Jan 2012
    Location
    Netherlands
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by NKN View Post
    Okay...?
    What's your point?
    I fixed what he asked.
    Yes i know,
    But the sqaure wasn't moving ( as i asumend he wanted to move the square )

  7. #7
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    repeat
    procedure1
    until IsKeyDown(27)


    If you're using SMART, this will never end. (Your inputs are blocked in SMART IIRC)


    As with this:
    Simba Code:
    function function1:integer;
    var
    i:integer;
    begin
      for i:=37 to 40 do
        begin
          if IsKeyDown(i)then
            result:=i;
        end;
    end;
    It'll never even go off

  8. #8
    Join Date
    Jan 2012
    Location
    Netherlands
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Well i thaught it would fail but i tried it and it works.

    Try it out yourself:

    Code:
    program Testing;
    	{$DEFINE SMART}
    
    var
      buf, img, xpos ,ypos : Integer ;
    
    procedure procedure2 ;
    begin
    
      FastDrawTransparent( xpos, ypos, img, buf )
      DrawBitmapDebugImg( buf )
    
    end;
    
    function function1 : integer ;
    var
      i : Integer ;
    begin
    
      for i:=37 to 40 do begin
      if IsKeyDown(i)then
        Result:=i;
      end;
    end;
    
    procedure procedure1;
    begin
    
      case function1 of
    
        37:begin
          writeln('left')
          dec( xpos ) ;
          procedure2 ;
        end;
    
        38:begin
          writeln('Up')
          dec( ypos );
          procedure2 ;
        end;
    
        39:begin
          writeln('Right')
          inc( xpos ) ;
          procedure2 ;
        end;
    
        40:begin
          writeln('Down')
          inc( ypos );
          procedure2 ;
        end;
    
      end;
    
    end;
    
    begin
    
      img:=BitmapFromString(10,10,'') ;
      buf:=CreateBitmap(300,300) ;
      FastDrawClear(img,255) ;
      xpos:=150 ;
      ypos:=150 ;
      displaydebugimgwindow(300,300) ;
      procedure2 ;
    
      repeat
        procedure1
      until IsKeyDown(27)
    
      FreeBitmap( buf ) ;
    
    end.

  9. #9
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Quote Originally Posted by kazhual View Post
    Well i thaught it would fail but i tried it and it works.

    Try it out yourself:

    Code:
    program Testing;
    	{$DEFINE SMART}
    
    var
      buf, img, xpos ,ypos : Integer ;
    
    procedure procedure2 ;
    begin
    
      FastDrawTransparent( xpos, ypos, img, buf )
      DrawBitmapDebugImg( buf )
    
    end;
    
    function function1 : integer ;
    var
      i : Integer ;
    begin
    
      for i:=37 to 40 do begin
      if IsKeyDown(i)then
        Result:=i;
      end;
    end;
    
    procedure procedure1;
    begin
    
      case function1 of
    
        37:begin
          writeln('left')
          dec( xpos ) ;
          procedure2 ;
        end;
    
        38:begin
          writeln('Up')
          dec( ypos );
          procedure2 ;
        end;
    
        39:begin
          writeln('Right')
          inc( xpos ) ;
          procedure2 ;
        end;
    
        40:begin
          writeln('Down')
          inc( ypos );
          procedure2 ;
        end;
    
      end;
    
    end;
    
    begin
    
      img:=BitmapFromString(10,10,'') ;
      buf:=CreateBitmap(300,300) ;
      FastDrawClear(img,255) ;
      xpos:=150 ;
      ypos:=150 ;
      displaydebugimgwindow(300,300) ;
      procedure2 ;
    
      repeat
        procedure1
      until IsKeyDown(27)
    
      FreeBitmap( buf ) ;
    
    end.
    Giving the answer is cheating.
    Help them learn it, so they understand, not just copy/paste

  10. #10
    Join Date
    Jan 2012
    Location
    Netherlands
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    I did mention why I didn't work and gave an solution,
    Next time I won't cheat

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
  •