Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

Out of Range

тут можно задать вопрос по скриптингу
Half-Life
Novice
Novice
Posts: 86
Joined: 30.10.2012 12:06
Location: Одесса
Contact:

Out of Range

Post by Half-Life »

Доброго времени суток. Есть процедура

Code: Select all

procedure GetBODInfo;
var
GumpInfo:TGumpInfo;
Exep,Text:String;
CountOfString:Byte;
begin
  if Dead or not Connected then Exit;
  While IsGump do CloseSimpleGump(GetGumpsCount-1);
  UseObject(BOD);
  Wait(WaitTime);
  CheckLag(WaitLag);
  If GetGumpID(GetGumpsCount-1)<>$5AFBD742 then GetBODInfo;
  GetGumpInfo(GetGumpsCount-1, gumpInfo); 
  CountOfString:=Length(gumpInfo.XmfHTMLGumpColor);
  if CountOfString = 0 then GetBODInfo;
  Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]); //131 строка
  Count:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[1].text_id]);
  Amount:=Amount-Count;
  Item:=GetClilocById(gumpInfo.XmfHTMLGumpColor[4].Cliloc_id);
  if (Amount=0) then begin
    MoveItem(BOD,1,BulkDestination,0,0,0);
    Wait(WaitTime);
    CheckLag(WaitLag);
    while IsGump do CloseSimpleGump(GetGumpsCount-1);
    AddToSystemJournal('Бод '+Item+' выполнен');
    SalvageItems;
    SearchBOD;
  end;
  AddToSystemJournal('Надо сделать '+IntToStr(Amount)+' '+Item);
  Exep:=GetClilocById(gumpInfo.XmfHTMLGumpColor[6].Cliloc_id);
  If Exep='All items must be exceptional.' then Exceptional:=True;
  if CountOfString>7 then begin
    Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
    If Text='All items must be made with spined leather.' then Spined:=True;
    Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
    If Text='All items must be made with horned leather.' then Horned:=True;
    Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
    If Text='All items must be made with barbed leather.' then Barbed:=True;
  end;
  While IsGump do CloseSimpleGump(GetGumpsCount-1);
  Wait(250);
end;
и на один из пяти десяти раз выдаёт ошибку - Exec: [Error] at (131:3): Out Of Range
что не так?
Last edited by Half-Life on 28.01.2014 3:46, edited 2 times in total.
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Out of Range

Post by Vizit0r »

Half-Life wrote:что не так?
версия стелса не так.
скачай последнюю.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Half-Life
Novice
Novice
Posts: 86
Joined: 30.10.2012 12:06
Location: Одесса
Contact:

Re: Out of Range

Post by Half-Life »

Vizit0r wrote: версия стелса не так.
скачай последнюю.
Версия 6.2.1
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Out of Range

Post by Vizit0r »

тогда 131 строку в студию
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Half-Life
Novice
Novice
Posts: 86
Joined: 30.10.2012 12:06
Location: Одесса
Contact:

Re: Out of Range

Post by Half-Life »

В первом посте она указана.
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Out of Range

Post by drabadan »

Half-Life wrote:В первом посте она указана.
Так объясни как ее найти...
раззул глаза и увидел...

добавь задержечку небольшую перед строкой, посмотри если повторяется...
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Out of Range

Post by Vizit0r »

Half-Life wrote:В первом посте она указана.
играть в угадайку не буду, подожду пока ты укажешь точную строку.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Out of Range

Post by drabadan »

Vizit0r wrote:
Half-Life wrote:В первом посте она указана.
играть в угадайку не буду, подожду пока ты укажешь точную строку.
а я вот, тоже такой думал... а там коммент есть соответствующий =)
Half-Life
Novice
Novice
Posts: 86
Joined: 30.10.2012 12:06
Location: Одесса
Contact:

Re: Out of Range

Post by Half-Life »

procedure GetBODInfo(Старая)
procedure GetBODInfo;
var
GumpInfo:TGumpInfo;
Exep,Text:String;
CountOfString:Byte;
begin
if Dead or not Connected then Exit;
While IsGump do CloseSimpleGump(GetGumpsCount-1);
UseObject(BOD);
Wait(WaitTime);
CheckLag(WaitLag);
If GetGumpID(GetGumpsCount-1)<>$5AFBD742 then GetBODInfo;
GetGumpInfo(GetGumpsCount-1, gumpInfo);
CountOfString:=Length(gumpInfo.XmfHTMLGumpColor);
if CountOfString = 0 then GetBODInfo;
Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]); //131 строка
Count:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[1].text_id]);
Amount:=Amount-Count;
Item:=GetClilocById(gumpInfo.XmfHTMLGumpColor[4].Cliloc_id);
if (Amount=0) then begin
MoveItem(BOD,1,BulkDestination,0,0,0);
Wait(WaitTime);
CheckLag(WaitLag);
while IsGump do CloseSimpleGump(GetGumpsCount-1);
AddToSystemJournal('Бод '+Item+' выполнен');
SalvageItems;
SearchBOD;
end;
AddToSystemJournal('Надо сделать '+IntToStr(Amount)+' '+Item);
Exep:=GetClilocById(gumpInfo.XmfHTMLGumpColor[6].Cliloc_id);
If Exep='All items must be exceptional.' then Exceptional:=True;
if CountOfString>7 then begin
Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
If Text='All items must be made with spined leather.' then Spined:=True;
Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
If Text='All items must be made with horned leather.' then Horned:=True;
Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
If Text='All items must be made with barbed leather.' then Barbed:=True;
end;
While IsGump do CloseSimpleGump(GetGumpsCount-1);
Wait(250);
end;
Переделал процедуру таким вот образом. Вроде больше не выскакивает сия ошибка.
Но всё равно интересно откуда этот баг вылазит.
Кстати задержка не помогала. Ни задержка ни проверка на лаг, гамп.
procedure GetBODInfo(Новая)

Code: Select all

procedure GetBODInfo;
var
GumpInfo:TGumpInfo;
Exep,Text:String;
CountOfString:Byte;
begin
  if Dead or not Connected then Exit;
  While IsGump do CloseSimpleGump(GetGumpsCount-1);
  UseObject(BOD);
  Wait(WaitTime);
  CheckLag(WaitLag);
  If GetGumpID(GetGumpsCount-1)=$5AFBD742 then begin
    GetGumpInfo(GetGumpsCount-1, gumpInfo);
    Wait(WaitTime);
    CheckLag(WaitLag);
    CountOfString:=Length(gumpInfo.XmfHTMLGumpColor);
    Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]);
    Count:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[1].text_id]);
    Amount:=Amount-Count;
    Item:=GetClilocById(gumpInfo.XmfHTMLGumpColor[4].Cliloc_id);
    if (Amount=0) then begin
      MoveItem(BOD,1,BulkDestination,0,0,0);
      Wait(WaitTime);
      CheckLag(WaitLag);
      while IsGump do CloseSimpleGump(GetGumpsCount-1);
      AddToSystemJournal('Бод '+Item+' выполнен');
      SalvageItems;
      SearchBOD;
    end;
    AddToSystemJournal('Надо сделать '+IntToStr(Amount)+' '+Item);
    Exep:=GetClilocById(gumpInfo.XmfHTMLGumpColor[6].Cliloc_id);
    If Exep='All items must be exceptional.' then Exceptional:=True;
    if CountOfString>7 then begin
      Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
      If Text='All items must be made with spined leather.' then Spined:=True;
      Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
      If Text='All items must be made with horned leather.' then Horned:=True;
      Text:=GetClilocById(gumpInfo.XmfHTMLGumpColor[7].Cliloc_id);
      If Text='All items must be made with barbed leather.' then Barbed:=True;
    end;
    While IsGump do CloseSimpleGump(GetGumpsCount-1);
    Wait(500);
    Exit;
  end;
  GetBODInfo;
end;
Half-Life
Novice
Novice
Posts: 86
Joined: 30.10.2012 12:06
Location: Одесса
Contact:

Re: Out of Range

Post by Half-Life »

Ещё такой вопрос. Как можно узнать открыт ли банк или нет?
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Out of Range

Post by drabadan »

Half-Life wrote:Ещё такой вопрос. Как можно узнать открыт ли банк или нет?
welcome to my world...

Пиши дллку на основе OCR... Закрывай все сундуки, и распознавай сундучек банка дллкой, експортировав из нее состояние банка.
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Out of Range

Post by Vizit0r »

Half-Life wrote:Ещё такой вопрос. Как можно узнать открыт ли банк или нет?
запоминаешь LastContainer, орешь банк, ждешь изменения LAstContainer.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Out of Range

Post by Vizit0r »

Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]); //131 строка

ни одной проверки, а есть ли вообще нужный элемент в массиве - вот и обращаешься к несуществующему элементу.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Out of Range

Post by drabadan »

Vizit0r wrote:
Half-Life wrote:Ещё такой вопрос. Как можно узнать открыт ли банк или нет?
запоминаешь LastContainer, орешь банк, ждешь изменения LAstContainer.
а если ластконтейнер и был банк?

тут проблема как уловить момент, что банк закрыт. То-есть открыть его и сравнить проблем нету...

Code: Select all

Program New;

begin
if LastContainer = ObjAtLayer(BankLayer) then
    ClientPrint('There is spoon!')
else
    ClientPrint('There is no spoon!');
end.
но когда при работе, он потом закрывается, то ластконтэинер все равно помнит банк...
Half-Life
Novice
Novice
Posts: 86
Joined: 30.10.2012 12:06
Location: Одесса
Contact:

Re: Out of Range

Post by Half-Life »

Vizit0r wrote:Amount:=StrToInt(gumpInfo.Text[gumpInfo.GumpText[0].text_id]); //131 строка

ни одной проверки, а есть ли вообще нужный элемент в массиве - вот и обращаешься к несуществующему элементу.
стоп стоп стоп
If GetGumpID(GetGumpsCount-1)<>$5AFBD742 then GetBODInfo;
GetGumpInfo(GetGumpsCount-1, gumpInfo);
CountOfString:=Length(gumpInfo.XmfHTMLGumpColor);
if CountOfString = 0 then GetBODInfo;

как ещё можно проверить?
Post Reply