Author Topic: Pascal problem with procedures  (Read 4027 times)

0 Members and 1 Guest are viewing this topic.

Offline blackbeardTopic starter

  • Restricted
  • **
  • Posts: 10
  • Activity:
    0%
  • Reputation Power: 1
  • blackbeard has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Pascal problem with procedures
« on: September 21, 2015, 11:21:55 AM »
0
I made a easyuo mining macro and i'm trying to convert the code i made in easyuo to pascal for stealth. But i dont know how to simulate the subs of easyuo in pascal. i'm trying to use procedures, but i'm getting error of unknown identifier on line 94, it is commented.

Code: [Select]
program Mining;

const
pickaxe1 = $0E85;
pickaxe2 = $0E86;
runebook =$22C5;
runebook_color =$0461;
runa_casa = 9;
limiteinativo = 1000;

var
cntalvo, cntinativo, contadorrunas : integer;



procedure save();

begin

end;

procedure guardar();

begin

end;


procedure recall(runa : integer) ;

begin
 
    findtypeex(runebook, runebook_color,backpack,false);
    useobject(finditem);
    waitgump(inttostr(runa));
    wait(300)
    numgumpbutton(getgumpscount()-1,runa+100);
   
   
    wait(9000);
end;
procedure verifica_marreta();
   
   begin
    FindType (pickaxe2 , Backpack);
    UseObject(FindItem);
    UseObject(FindItem);
   end;

procedure verifica_peso();




begin
if weight > maxweight - 2 then
begin
 recall(runa_casa);
 guardar();
end;
end;

procedure detecta();

begin

end;
procedure hiding();

begin

end;

procedure inicio();

begin
  verifica_peso();
  recall(contadorrunas);
 
 
   
end;


procedure mining();

begin
   verifica_peso();
   save();   
   hiding();
   verifica_marreta();
   useobject(finditem);
   alvo(); // getting error: Unknown Identifier
   jornal();
   
end;

procedure jornal();

begin

end;

procedure alvo();

begin
     if targetpresent then
     begin
        if cntalvo = 1 then targettotile(0,getx(self)-1,gety(self),getz(self));
     end;
end;

procedure inativo();

begin
cntinativo := cntinativo + 1;
if cntinativo > limiteinativo then
begin
    cntinativo := 1;
    inicio();
end;

end;

procedure andar();

var
i, x, randomx, randomx2, y, randomy, randomy2 : integer;
tileinfo : tstaticcell;

begin
    randomx := random(10);
    randomx2 := random(10);
    randomy := random(10);
    randomy2 := random(10);
   
    x := getx(self) + randomx - randomx2;
    y := gety(self) + randomy - randomy2; 
   
    tileinfo := ReadStaticsXY(x, y, WorldNum);
   
    if tileinfo.staticcount > 0 then
    begin
        //addtosystemjournal('length'+inttostr(length(tileinfo.statics)));
        for i := Low(TileInfo.Statics)to high(TileInfo.Statics) do
        begin
            if (TileInfo.Statics[i].Tile >= 1339) and  (TileInfo.Statics[i].Tile <= 1359) and  (TileInfo.Statics[i].z = GetZ(self)) then
            begin
                newmovexy(x,y,true,0,false);
            end
            else
            begin
                inativo();
                andar(); 
            end;
        end;
    end
    else
    begin
        inativo();
        andar();
    end;
end;

begin
 contadorrunas := 1;
 cntalvo := 1;
 recall(contadorrunas);
 andar();
 mining();
end.




What is wrong, in procedure mining, i'm getting an error, unknown identifier when try to call andar() procedure.

What i'm doing wrong?

Post Merge: September 21, 2015, 11:49:54 AM
Sry, i found the solution.
« Last Edit: September 21, 2015, 11:49:54 AM by blackbeard »

Offline camotbik

  • Sr. Member
  • *
  • Posts: 349
  • Activity:
    0%
  • Reputation Power: 3
  • camotbik has no influence.
  • Gender: Male
  • Hello! I'm a UO addict.
  • Respect: +38
  • Referrals: 0
    • View Profile
Re: Pascal problem with procedures
« Reply #1 on: September 24, 2015, 08:34:12 AM »
0
You are calling alvo, before its defined. Check the fixed code.
Code: [Select]
program Mining;

const
pickaxe1 = $0E85;
pickaxe2 = $0E86;
runebook =$22C5;
runebook_color =$0461;
runa_casa = 9;
limiteinativo = 1000;

var
cntalvo, cntinativo, contadorrunas : integer;



procedure save();
begin
end;

procedure guardar();
begin
end;


procedure recall(runa : integer) ;
begin
    findtypeex(runebook, runebook_color,backpack,false);
    useobject(finditem);
    waitgump(inttostr(runa));
    wait(300)
    numgumpbutton(getgumpscount()-1,runa+100);
    wait(9000);
end;
procedure verifica_marreta();
   begin
    FindType (pickaxe2 , Backpack);
    UseObject(FindItem);
    UseObject(FindItem);
   end;

procedure verifica_peso();
begin
    if weight > maxweight - 2 then
    begin
        recall(runa_casa);
        guardar();
    end;
end;

procedure detecta();
begin
end;

procedure hiding();
begin
end;

procedure inicio();
begin
  verifica_peso();
  recall(contadorrunas);
end;

procedure alvo();

begin
     if targetpresent then
     begin
        if cntalvo = 1 then targettotile(0,getx(self)-1,gety(self),getz(self));
     end;
end;

procedure inativo();
begin
    cntinativo := cntinativo + 1;
    if cntinativo > limiteinativo then
    begin
        cntinativo := 1;
        inicio();
    end;
end;

procedure andar();

var
i, x, randomx, randomx2, y, randomy, randomy2 : integer;
tileinfo : tstaticcell;

begin
    randomx := random(10);
    randomx2 := random(10);
    randomy := random(10);
    randomy2 := random(10);
    x := getx(self) + randomx - randomx2;
    y := gety(self) + randomy - randomy2;  
    tileinfo := ReadStaticsXY(x, y, WorldNum);  
    if tileinfo.staticcount > 0 then
    begin
        //addtosystemjournal('length'+inttostr(length(tileinfo.statics)));
        for i := Low(TileInfo.Statics)to high(TileInfo.Statics) do
        begin
            if (TileInfo.Statics[i].Tile >= 1339) and  (TileInfo.Statics[i].Tile <= 1359) and  (TileInfo.Statics[i].z = GetZ(self)) then
            begin
                newmovexy(x,y,true,0,false);
            end
            else
            begin
                inativo();
                andar();  
            end;
        end;
    end
    else
    begin
        inativo();
        andar();
    end;
end;

procedure jornal();
begin
end;


procedure mining();
begin
   verifica_peso();
   save();  
   hiding();
   verifica_marreta();
   useobject(finditem);
   alvo(); // getting error: Unknown Identifier
   jornal();
end;

begin
 contadorrunas := 1;
 cntalvo := 1;
 recall(contadorrunas);
 andar();
 mining();
end.
What you witness -- is whatver..
uogamers hybrid.

Tags: