Total players online: 14



Take the Tour | Site Map

It is currently Sun Dec 10, 2017 11:32 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Nov 03, 2017 9:57 am 
Offline
Novice Scripter
Novice Scripter

Joined: 10/02/2009 02:59
Posts: 66

Groups:
I am trying to find a crystal ball of knowledge in my backpack - and make sure it is activated.

I tried with ' if on in property' and if turned_on in property' and off and turned off - but no luck to get my wanted resoult.

I am left with this code - that works, but it runs through it several times before it is sure it is on.

Code:
  1. Search:
  2.  if #finditem = -1
  3.     {
  4.     return
  5.     }
  6. wait 10
  7. if knowledge in #property
  8.    {
  9.    set %crystalball #FindID
  10.    msg foundit$
  11.    goto activate
  12.    }
  13. goto search
  14. activate:
  15. set %jStart #jIndex
  16. set #lobjectid %crystalball
  17. wait 10
  18. gosub WaitForSysVars CONTSIZE = 300_150 CONTNAME = generic_gump
  19. set %x #contposx + 50
  20. set %y #contposy + 60
  21. click %x %y
  22. wait 1s
  23. set %jEnd #jIndex
  24. for %i %jStart %jEnd
  25.   {
  26.         scanjournal %i
  27.   if no_longer in #journal
  28.      {
  29.      msg tryagain$
  30.      goto activate
  31.      }
  32.   msg activated$
  33.   }
  34.  
  35. sub waitForSysVars
  36.   set !cnt %0 / 3
  37.   set !timeOut #scnt + 5
  38.   if ( %0 % 3 = 1 )
  39.     set !timeOut #scnt + % . %0
  40.   for !i 1 !cnt
  41.   {
  42.     set !offset 3 * !i - 2
  43.     set !evaluation !offset + 1
  44.     set !value !offset + 2
  45.     if ! ( # . % . !offset % . !evaluation % . !value )
  46.       set !i 0
  47.     if #scnt > !timeout
  48.       return #false
  49.   }
  50.  


So - could someone point me in right direction, of either getting item property to work or the journal scan? Journal scan would be best - as my intention is to use it in skill scripts.

Thx everyone :-)

*Edit*

Found a way that worked properly....

Code:
  1.       ;Sub CBKnowledge
  2. Search:
  3.  if #finditem = -1
  4.     {
  5.     return
  6.     }
  7. wait 10
  8. if knowledge in #property
  9.    {
  10.    set %crystalball #FindID
  11.    msg foundit$
  12.    wait 10
  13.    if turned , #spc , on in #property
  14.       {
  15.       msg activatedprop$
  16.       halt
  17.       }
  18.    msg false$
  19.    goto activate
  20.    }
  21. goto search
  22. activate:
  23. event property %crystalball
  24. if turned , #spc , off in #property
  25.    {
  26.    set #lobjectid %crystalball
  27.    event macro 17 0
  28.    gosub WaitForSysVars CONTSIZE = 300_150 CONTNAME = generic_gump
  29.    set %x #contposx + 50
  30.    set %y #contposy + 60
  31.    click %x %y
  32.    wait 1s
  33.    msg activating$
  34.    goto activate
  35.    }
  36. msg activated$
  37.  
  38. sub waitForSysVars
  39.   set !cnt %0 / 3
  40.   set !timeOut #scnt + 5
  41.   if ( %0 % 3 = 1 )
  42.     set !timeOut #scnt + % . %0
  43.   for !i 1 !cnt
  44.   {
  45.     set !offset 3 * !i - 2
  46.     set !evaluation !offset + 1
  47.     set !value !offset + 2
  48.     if ! ( # . % . !offset % . !evaluation % . !value )
  49.       set !i 0
  50.     if #scnt > !timeout
  51.       return #false
  52.   }
  53.  
  54.  


Any comments?

Would like to have suggestions for a good journal scan for to find resoults for using it.


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Fri Nov 03, 2017 12:35 pm 
Offline
Administrator
Administrator
User avatar

Joined: 08/12/2003 07:28
Posts: 18569
Location: Switzerland

I'll post a short snippet when I come home...
It will make use of my scan-sub I developed for stuff like this...

_________________
EUO Member and postwhore since: 19th Dezember, 2002; Loosing on freeshard Alexandria since: 5th January, 2005
Searches cure for cancer since: 17th November, 2003 on GRID.org & Worldcommunitygrid.org
Made scripts for Project 'Programmers for Alexandria' worth 50$
Image
Quote "mmorning": Where would theses boards be if Orn didn't miss all the sarcasm. Man its great having him here :)
Quote "author-unknown": Good idea. I gotta start doing that too. You're a trendsetter Orn. :)
Quote "dreyfus": #true is always #true


Top
  ProfileShow poster's scripts in the public script library 
PostPosted: Fri Nov 03, 2017 2:27 pm 
Offline
Administrator
Administrator
User avatar

Joined: 08/12/2003 07:28
Posts: 18569
Location: Switzerland

As the demo-code in viewtopic.php?p=409558#p409558 provided in full...
Code:
  1. set #lobjectid %crystalball
  2. wait 10
  3.         {
  4.         event macro 17 0
  5.         gosub WaitForSysVars CONTSIZE = 300_150 CONTNAME = generic_gump
  6.         set %x #contposx + 50
  7.         set %y #contposy + 60
  8.         set %linetoscan #Jindex
  9.         click %x %y
  10.         gosub journalscan %linetoscan 2000 no_longer ; Scan while 2 seconds for the string.
  11.         if #result = 0
  12.                 {
  13.                 set %linetoscan #Jindex ; We found it no longer activated. Redo (With the not yet met until-loop)!
  14.                 }
  15.         }
  16. until (result <> 0)
  17. msg activated$
  18. ...
  19.  
  20.  
  21.  
  22.  
  23.  
  24. ; ---------------
  25. ; -------------------------
  26. ; Sub name: journalscan
  27. ; Autor: Orngrimm
  28. ; Version: 1.0
  29. ; Purpose: To scan for multiple strings in Journal with timeout in milisecs
  30. ; Params:       %1      req Line of the journal to start checking (Will scan that line) / "now" for actual line as starting point (will scan actual line)
  31. ;               %2      req timeout in miliseconds; "inf" for infinite wait; 0 for single check only
  32. ;               %3      req string 1 to look for in the journals
  33. ;               %4-%n opt string 2..n to look for in the journals
  34. ;               set req     %overdrive LPC of the accelerated speed
  35. ; Outputs:      #result         0 for timeout; #Jindex with the looked word
  36. ;               set             #Journal
  37. ; -------------------------
  38. sub journalscan
  39. if %0 < 3
  40.         {
  41.         display OK Sub got called with too few arguments.$Script pauses for debugging.
  42.         pause
  43.         return
  44.         }
  45. ; .............. Hand in .............
  46. set !oldLPC #LPC
  47. set #LPC %overdrive
  48.  
  49. ; .......... PREPARATIONS .............
  50. ; determine the first line to star looking forward
  51. if %1 = now
  52.         set !line #Jindex
  53.         set !line %1
  54.  
  55. ; Determine the timeout
  56. if %2 = inf
  57.         set !timeout #systime + 100000 ; Preload with 100 secs
  58.         set !timeout #systime + %2
  59.  
  60. ; build array of all the strings to look for
  61. for !cnt 3 %0
  62.         {
  63.         set !tmpindex !cnt - 2
  64.         set !tmpvalue % . !cnt
  65.         set !lookforstring . !tmpindex !tmpvalue ; ----- Unsure if those brackets work!! ------
  66.         set !strings !cnt - 2 ; keeping track of how many strings we are looking for
  67.         }
  68.  
  69. set !hit #false ; Set to correct starting-condition
  70. ; .......... SCAN .............
  71.         {
  72.         if #Jindex > !line
  73.                 {
  74.                 ; Only scan if you have a new line!
  75.                 set !line !line + 1
  76.                 scanjournal !line
  77.                 for !cnt 1 !strings
  78.                         {
  79.                         ; check if we find one of the strings we are looking for
  80.                         if !lookforstring . !cnt in #Journal
  81.                                 {
  82.                                 ; gotcha!
  83.                                 set !hit #true ; We want to abort the scan
  84.                                 }
  85.                         }
  86.                 }
  87.         if %2 = inf
  88.                 set !timeout #systime + 100000 ; The neverending chase of "now" + 100secs
  89.         }
  90. until ( ( #systime >= !timeout ) || ( !hit = #true ) )
  91.  
  92. if !hit = #true
  93.         {
  94.         set !result !line
  95.         }
  96.         {
  97.         ; If we ended the scan and didnt find a hit, then timeout was true.
  98.         set !result 0
  99.         }
  100. ; .............. Hand back .............
  101. set #result !result
  102. set #LPC !oldLPC
  103. ;--------------------------

_________________
EUO Member and postwhore since: 19th Dezember, 2002; Loosing on freeshard Alexandria since: 5th January, 2005
Searches cure for cancer since: 17th November, 2003 on GRID.org & Worldcommunitygrid.org
Made scripts for Project 'Programmers for Alexandria' worth 50$
Image
Quote "mmorning": Where would theses boards be if Orn didn't miss all the sarcasm. Man its great having him here :)
Quote "author-unknown": Good idea. I gotta start doing that too. You're a trendsetter Orn. :)
Quote "dreyfus": #true is always #true


Top
  ProfileShow poster's scripts in the public script library 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Hosted by CalWeb Internet Services, Inc.