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

[Python] search in Property string (solved)

Ask for help
Post Reply
sauber
Neophyte
Neophyte
Posts: 18
Joined: 18.07.2018 21:01

[Python] search in Property string (solved)

Post by sauber »

Hi Guys

I'm translating a Pascal procedure in Python

Although, if I ask to Print I get this error in the Sysjornal
NameError: name 'BMSearch' is not defined

Code: Select all

def setupBooks():
    FindType(BulkBookType,Backpack())
    #print(FindItem())
    print(BMSearch(FindItem(),info,'Black'))
Original Pascal

Code: Select all

procedure setupBooks;
var
info : String;
begin
  while FindType(BulkBookType,backpack) > 0 do
  begin
    info := GetCliloc(FindItem);
    if BMSearch(1,info,'Black') > 0 then
    begin
      BBook:=FindItem;
      Ignore(FindItem);
    end
    else
    begin
      if BMSearch(1,info,'Tailor') >0 then
      TBook:=FindItem;
      Ignore(FindItem);
    end;
  end;
  IgnoreReset;  
  AddToSystemJournal('Tailor book id :'+IntToStr(TBook));
  AddToSystemJournal('Black book id :'+IntToStr(BBook));
  AddToSystemJournal('Book setup success');  
end;
Last edited by sauber on 03.12.2018 22:59, edited 1 time in total.
nah nah
Developer
Developer
Posts: 414
Joined: 13.07.2011 11:23
Contact:

Re: [Python] BMSearch - Name Error - not defined

Post by nah nah »

there is no fuction BMSearch in python. you need to use

Code: Select all

substring in string
sauber
Neophyte
Neophyte
Posts: 18
Joined: 18.07.2018 21:01

Re: [Python] BMSearch - Name Error - not defined

Post by sauber »

Same problem, I need to add the String message from the Item to a variable, I believe with GetCliloc?

GetCliloc is not defined

Any example please?
nah nah
Developer
Developer
Posts: 414
Joined: 13.07.2011 11:23
Contact:

Re: [Python] BMSearch - Name Error - not defined

Post by nah nah »

Code: Select all

tooltip = GetToolTip(FindType(BulkBookType,Backpack()))
print(tooltip)
sauber
Neophyte
Neophyte
Posts: 18
Joined: 18.07.2018 21:01

Re: [Python] BMSearch - Name Error - not defined

Post by sauber »

Thanks!

Code: Select all

def setupBooks():
   FindType(bulkBookType,Backpack())
   for bkCnt in range(FindCount()):
       FindType(bulkBookType,Backpack())
       info = GetTooltip(FindType(bulkBookType,Backpack()))
       if 'Tailor' in info: 
           TBook = str(FindItem()))
           print('Tailor book id: ' + str(FindItem()))
       if 'Black' in info: 
           BBook = str(FindItem()))
           print('Black book id: ' + str(FindItem())) 
       Ignore(FindItem())
       Wait(600)
Post Reply