SRL Archive - RS3 Help

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


Clutch

2015-05-22 11:58:11

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.
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.

Thomas

2015-05-22 12:42:31

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

Thomas

2015-05-22 12:44:41

Ogl.getmodels isn't a boolean I think.

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

Clutch

2015-05-22 23:54:14

From: lovebotter
Ogl.getmodels isn't a boolean I think.

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


First of all -
ogl.setDebug('Models');

This is wrong… it is…
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.

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.

The Mayor

2015-05-23 01:09:45

From: Clutch
First of all -
ogl.setDebug('Models');

This is wrong… it is…
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.

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:

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? )

Clutch

2015-05-23 01:27:07

From: The Mayor
I'm not well versed in oglib but I assume this line is incorrect:

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.

King

2015-05-23 01:46:06

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

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

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?

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;

The Mayor

2015-05-23 02:32:55

From: Clutch
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 :p

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.

bonsai

2015-05-23 05:32:31

From: The Mayor
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.
function add(x, y: integer): integer;
begin
result := x + y;
end;

Do it this way and it is not clear at all:
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.

Clutch

2015-05-23 16:53:41

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

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

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?

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?

The Mayor

2015-05-24 01:45:52

From: Clutch
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



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;