Results 1 to 11 of 11

Thread: Error: Unknown declaration "Models"...Compiling failed.

  1. #1
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default Error: Unknown declaration "Models"...Compiling failed.

    I've tried ~10 different ways (and different methods within those ways) of changing the end of my script. It continues to throw up an error - Error: Found unexpected token "", expected "End" at line 202
    Compiling failed.

    I've looked through the script, ensured there are ends on all my procedures.
    Attempted Loops, Cases, creating loops through seperate procedures that contain the loop.
    Nothing seems to be working.

    The other big issue which I believe to be related. When typing ogl.setDebug('Models') or even 'Textures' it throws an error - Error: Unknown declaration "Models" at line 196. So that made me think it was a const/var that I had added that broke everything. Unfortunately I have no idea what to do besides scrap it at this point. Ideas?
    Compiling failed.
    Simba Code:
    program ClutchCrafting;
    {$include_once ogLib/lib/core/core.simba}
    {See Thread for Instructions}
    { https://villavu.com/forum/showthread.php?t=113141&p=1343183#post1343183}
    const
    ItemSlot = 2; {first slot begins at 0}
    PresetOption = 2; {Bank Preset 1 or 2}
    Item = 45135; {See Thread for Instructions}
    Banker = 3377138974;
    Loop = '2';

    var
      Banker1, funcModelArray: glModelArray;
      clientCenter: TPoint;
      SClay: glTextureArray;
      Door, PWheel: glModelArray;
      position:array[0..2] of int32;
      canMould, canPW, canOpen, canPosition, canWalk, canBank, canRotateCamera: countDown = [0];

    procedure Check;
    begin end;

    procedure pWalk;
    var
      funcDirection:ansiString;
      funcIndex:uInt32=0;
      funcMapX,
        funcMapY:array[0..3] of single;
      funcPlayer:tPoint;
      funcTextureArray:glTextureArray;
    begin
      writeLN('[procedure] pWalk');
      funcPlayer:=minimap.getLocalPosition();
        if funcPlayer.y<position[1]-3 then
          funcDirection:='south'
        else if funcPlayer.y>position[1]+2 then
          funcDirection:='north';
        if funcPlayer.x<position[0]-3 then
          funcDirection:=funcDirection+'east'
        else if funcPlayer.x>position[0]+3 then
          funcDirection:=funcDirection+'west';
        if funcDirection then
          minimap.clickDirection(funcDirection);
        canWalk.setTime(random(1500,2500));
        canPW.setTime(Random(1000,2000));
    end;

    procedure pPosition;
    begin
      writeLN('[procedure] pPosition');
      position:=[71, 84, 270];
      canPosition.setTime(random(9000));
    end;

    procedure PWCheck;
    begin
      if ogl.getModels(2328382469) then
        begin
          PWheel := ogl.getModels(2328382469);
          mouse.click(PWheel[0].toPoint().randomizePointEllipse(5), 1);
          wait(RandomRange(3000,5000));
        end;

        if production.hasProduction then
          begin
            canMould.setTime(600);
            exit;
          end else
          canOpen.setTime(1000);
    end;

    procedure Open;
    begin
      if ogl.getModels(2524031219) then
        begin
          Door:= ogl.getModels(2524031219);
          mouse.click(Door[0].toPoint().randomizePointEllipse(5), 1);
          wait(RandomRange(3000,5000));
        end;
    end;

    procedure Mould;
    begin
      if production.getProduct()=(ItemSlot) then
        begin
          production.clickMake;
          wait(RandomRange(600,1500));
        while production.HasProgress() do
          wait(RandomRange(600,1200));
        end
      else
        begin
          production.setProduct(ItemSlot);
        end;
    end;

    procedure CTool;
    begin
      production.SetTool(0)
    end;

    procedure CItem;
    begin
      inventory.clickItem(Item);
      wait(RandomRange(600,1200));
    end;

    procedure Craft;
    begin
      if production.getProduct()=(ItemSlot) then
        begin
          production.clickMake;
          wait(RandomRange(600,1500));
        while production.HasProgress() do
          wait(RandomRange(600,1200));
        end
      else
        begin
          production.setProduct(ItemSlot);
        end;
      canBank.SetTime(600);
    end;

    procedure OBank;
    begin
      if ogl.getModels(Banker) then
        begin
          Banker1 := ogl.getModels(Banker);
          mouse.click(Banker1[0].toPoint().randomizePointEllipse(5), 1);
          wait(RandomRange(1200,2000));
        end;
      canBank.setTime(15000);
    end;

    procedure Withdraw;
    begin
      bank.clickpreset(PresetOption);
      wait(RandomRange(600,1000));
    end;

    procedure RotateCamera;
    begin
      writeLn('Rotating Camera');
      mainScreen.setDegrees(normalRandom(0,360),normalRandom(0,50));
      canRotateCamera.setTime(random(120000));
      WriteLn('Done Rotating Camera');
    end;

    Procedure mainLoop;
    var
    Reaction : Procedure() =@Check;
    begin
      if production.hasChooseATool() then
        Reaction:=@CTool
      else if production.hasProduction then
        Reaction:=@Craft
      else if inventory.isFull() and (not canBank.isFinished()) then
        Reaction:=@CItem
      else if bank.HasBank() then
        Reaction:=@Withdraw
      else if ogl.getModels(Banker).isEmpty or canRotateCamera.isFinished() then
        Reaction:=@RotateCamera
      else if (Length (ogl.getModels(Banker))) or (canBank.isFinished()) then
        Reaction:=@OBank;
        Reaction();
    end;

    Procedure mainLoop2;
    var
    Reaction : Procedure() =@Check;
    begin
      SClay:= ogl.getTextures(93840);

      if canPosition.isFinished() then
        Reaction:=@pPosition
      else if (not SClay.isEmpty()) and canWalk.isFinished() then
        Reaction:=@pWalk
      else if (ogl.getModels(PWheel)) and (canPW.isFinished()) then
        Reaction:=@PWCheck
      else if canOpen.isFinished() then
        Reaction:=@Open
      else if (canMould.isFinished()) then
        Reaction:=@Mould
      else if canRotateCamera.isFinished() then
        Reaction:=@RotateCamera
      else if bank.HasBank() then
        Reaction:=@Withdraw
      else if (Length (ogl.getModels(Banker))) or (canBank.isFinished()) then
        Reaction:=@OBank;

        Reaction();
    end;

    begin
      ogl.setup();

      case Loop of
        1: mainLoop;
        2: mainLoop2;
      end;
    end.
    Last edited by Clutch; 05-22-2015 at 04:36 PM.

  2. #2
    Join Date
    May 2012
    Posts
    499
    Mentioned
    23 Post(s)
    Quoted
    228 Post(s)

    Default

    Your loop const is a string, in your mainloop its an integer.
    What is line 196?

  3. #3
    Join Date
    May 2012
    Posts
    499
    Mentioned
    23 Post(s)
    Quoted
    228 Post(s)

    Default

    Ogl.getmodels isn't a boolean I think.

    Try using if length(ogl.getmodels(66655566)) then

  4. #4
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by lovebotter View Post
    Ogl.getmodels isn't a boolean I think.

    Try using if length(ogl.getmodels(66655566)) then
    First of all -
    Simba Code:
    ogl.setDebug('Models');

    This is wrong... it is...
    Simba Code:
    ogl.setDebugMode('Models');

    That being said I felt really stupid, UNTIL I corrected it. Still get the same error. Currently wiping all my code one by one until I can find the problem.



    Edit: but yes I do still feel stupid.

    Simba Code:
    Procedure mainLoop2;
    var
    Reaction : Procedure() =@Check;
    begin
      SClay:= ogl.getTextures(93840);

      if canPosition.isFinished() then
        Reaction:=@pPosition
      else if (not SClay.isEmpty()) and canWalk.isFinished() then
        Reaction:=@pWalk
      else if (ogl.getModels(PWheel)) and (canPW.isFinished()) then
        Reaction:=@PWCheck
      else if canOpen.isFinished() then
        Reaction:=@Open
      else if (canMould.isFinished()) then
        Reaction:=@Mould
      else if canRotateCamera.isFinished() then
        Reaction:=@RotateCamera
      else if bank.HasBank() then
        Reaction:=@Withdraw
      else if (Length (ogl.getModels(Banker))) or (canBank.isFinished()) then
        Reaction:=@OBank;

        Reaction();
    end;

    The problem is somewhere in the above... Removed it and no more errors. Gonna sober up and hopefully get this fixed tomorrow.
    For my own Knowledge - I think @Open is my issue. Since as Brandon mentioned it doesn't have a check within that loop like everything else and since the countdown starts at 0 it is nil because it doesn't exist yet.
    Last edited by Clutch; 05-23-2015 at 03:59 AM.

  5. #5
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    First of all -
    Simba Code:
    ogl.setDebug('Models');

    This is wrong... it is...
    Simba Code:
    ogl.setDebugMode('Models');

    That being said I felt really stupid, UNTIL I corrected it. Still get the same error. Currently wiping all my code one by one until I can find the problem.



    Edit: but yes I do still feel stupid.

    Simba Code:
    Procedure mainLoop2;
    var
    Reaction : Procedure() =@Check;
    begin
      SClay:= ogl.getTextures(93840);

      if canPosition.isFinished() then
        Reaction:=@pPosition
      else if (not SClay.isEmpty()) and canWalk.isFinished() then
        Reaction:=@pWalk
      else if (ogl.getModels(PWheel)) and (canPW.isFinished()) then
        Reaction:=@PWCheck
      else if canOpen.isFinished() then
        Reaction:=@Open
      else if (canMould.isFinished()) then
        Reaction:=@Mould
      else if canRotateCamera.isFinished() then
        Reaction:=@RotateCamera
      else if bank.HasBank() then
        Reaction:=@Withdraw
      else if (Length (ogl.getModels(Banker))) or (canBank.isFinished()) then
        Reaction:=@OBank;

        Reaction();
    end;

    The problem is somewhere in the above... Removed it and no more errors. Gonna sober up and hopefully get this fixed tomorrow.
    For my own Knowledge - I think @Open is my issue. Since as Brandon mentioned it doesn't have a check within that loop like everything else and since the countdown starts at 0 it is nil because it doesn't exist yet.
    I'm not well versed in oglib but I assume this line is incorrect:

    Simba Code:
    else if (ogl.getModels(PWheel) and canPW.isFinished()) then

    Can you pass a glModelArray to getModels() ? (and on that note, do you need to declare all of those variables globally? )

  6. #6
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    I'm not well versed in oglib but I assume this line is incorrect:

    Simba Code:
    else if (ogl.getModels(PWheel) and canPW.isFinished()) then

    Can you pass a glModelArray to getModels() ? (and on that note, do you need to declare all of those variables globally? )
    That line is fine, you can pass arrays to getModels(), and those variables globally - I haven't had issues yet except for this one script and it's about my 8th OGL script so far, but majority of it, it's easier to declare globally opposed to typing in all of that information for 6 different procedures that are all calling onto the same thing.

    I suppose for SRL it would be like declaring TPA's and ATPA's. Albeit obviously different.

  7. #7
    Join Date
    Jun 2012
    Location
    Howell, Michigan
    Posts
    1,585
    Mentioned
    34 Post(s)
    Quoted
    553 Post(s)

    Default

    I'm not very versed in OG and I'm a bit rusty with my scripting... but could this line be the issue
    Simba Code:
    else if canOpen.isFinished() then
        Reaction:=@Open

    because you are not declaring in the open procedure whether or not it is successful?

    Simba Code:
    procedure Open;
    begin
      if ogl.getModels(2524031219) then
        begin
          Door:= ogl.getModels(2524031219);
          mouse.click(Door[0].toPoint().randomizePointEllipse(5), 1);
          wait(RandomRange(3000,5000));
        end;
    end;

    Adding something like this help?

    Simba Code:
    procedure Open;
    begin
      if ogl.getModels(2524031219) then
        begin
          Door:= ogl.getModels(2524031219);
          mouse.click(Door[0].toPoint().randomizePointEllipse(5), 1);
          wait(RandomRange(3000,5000));
          canOpen.setTime(1000);
        end;
    end;
    Last edited by King; 05-23-2015 at 05:49 AM.

  8. #8
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    That line is fine, you can pass arrays to getModels(), and those variables globally - I haven't had issues yet except for this one script and it's about my 8th OGL script so far, but majority of it, it's easier to declare globally opposed to typing in all of that information for 6 different procedures that are all calling onto the same thing.

    I suppose for SRL it would be like declaring TPA's and ATPA's. Albeit obviously different.
    I know you can pass arrays, but you are not passing an array of uInt32, you are passing PWheel, which is a glModelArray. a glModelArray is an array of glModel, which is a record. If that compiles then I've no idea how

    In terms of the globals, it is generally bad practice to keep all of your variables global (and therefore in the memory at all times). For example, Banker1 is only used in OBank, so it should be declared locally in OBank.

  9. #9
    Join Date
    Oct 2013
    Location
    East Coast USA
    Posts
    770
    Mentioned
    61 Post(s)
    Quoted
    364 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    In terms of the globals, it is generally bad practice to keep all of your variables global (and therefore in the memory at all times). For example, Banker1 is only used in OBank, so it should be declared locally in OBank.
    To me, the important reason to avoid globals is that they make code buggy.

    Someone makes a change in one place and suddenly you have bugs cropping up in another.

    Your functions are relying on data they do not control. Every global is like adding a secret undocumented parameter to all of your functions. If your function takes two integers, you sanity check them first. It would also have to sanity check any global it uses.

    It's clear from this code that two values are needed from the caller to produce a result.
    Simba Code:
    function add(x, y: integer): integer;
    begin
      result := x + y;
    end;

    Do it this way and it is not clear at all:
    Simba Code:
    var
      x, y: integer;

    function add(): integer;
    begin
      result := x + y;
    end;

    Anything a function requires as input should come to it through its parameters. Anything the function needs internally to create the result should be private and defined locally.

  10. #10
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by King View Post
    I'm not very versed in OG and I'm a bit rusty with my scripting... but could this line be the issue
    Simba Code:
    else if canOpen.isFinished() then
        Reaction:=@Open

    because you are not declaring in the open procedure whether or not it is successful?

    Simba Code:
    procedure Open;
    begin
      if ogl.getModels(2524031219) then
        begin
          Door:= ogl.getModels(2524031219);
          mouse.click(Door[0].toPoint().randomizePointEllipse(5), 1);
          wait(RandomRange(3000,5000));
        end;
    end;

    Adding something like this help?

    Simba Code:
    procedure Open;
    begin
      if ogl.getModels(2524031219) then
        begin
          Door:= ogl.getModels(2524031219);
          mouse.click(Door[0].toPoint().randomizePointEllipse(5), 1);
          wait(RandomRange(3000,5000));
          canOpen.setTime(1000);
        end;
    end;
    This and altering the Reaction to require the OGLS to be called upon, yes.
    @bonsai; @The Mayor;
    That makes sense and is good to know! Now the way I am handling it, is there requires changes to be made at the top - our globals. Such as the ID's for specific items. Leather, gems, soft clay etc. etc.. Now, I don't know of a better way to have those as something you can alter (to make it user-friendly) outside of declaring them globally. I would assume we could add a GUI (which I want to do) but I've never done that before nor had the time to explore that option yet, but would this negate the need to declare them globally?
    Last edited by Clutch; 05-23-2015 at 08:56 PM.

  11. #11
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    This and altering the Reaction to require the OGLS to be called upon, yes.
    @bonsai; @The Mayor;
    That makes sense and is good to know! Now the way I am handling it, is there requires changes to be made at the top - our globals. Such as the ID's for specific items. Leather, gems, soft clay etc. etc.. Now, I don't know of a better way to have those as something you can alter (to make it user-friendly) outside of declaring them globally. I would assume we could add a GUI (which I want to do) but I've never done that before nor had the time to explore that option yet, but would this negate the need to declare them globally?
    Don't get confused with global variables and constants

    Simba Code:
    const
      NPC_ID = 1234567; // The ID of the NPC you are fighting


    procedure findStuff();
    var
      models: glModelArray; // locally declared
    begin
      models := ogl.getModels(NPC_ID);
      // etc.
    end;

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
  •