Author Topic: Sorting Script Issue  (Read 12991 times)

0 Members and 1 Guest are viewing this topic.

Offline soulbreakTopic starter

  • Newbie
  • *
  • Posts: 5
  • Activity:
    0%
  • Reputation Power: 1
  • soulbreak has no influence.
  • Respect: 0
  • Referrals: 0
    • View Profile
Sorting Script Issue
« on: March 10, 2015, 04:43:58 PM »
0
So I am trying to create a sorting script that will ID items and then place them in respective chests. I'm not trying to get too creative, I just want to sort Silver, Power, Vanq, Charged and Weapon types respectively.

Currently the way the script works is it will ID a weapon, but somehow it will not go through the lifting/sorting action to place it in the right chest?

Could any code guru's out there take a look and see what I did wrong.

http://pastebin.com/fnHBjvNj

Offline KaliOfLS

  • That's "Dr." Kali to you!
  • Sr. Member
  • *
  • Posts: 406
  • Activity:
    0%
  • Reputation Power: 6
  • KaliOfLS has no influence.
  • Gender: Male
  • Respect: +33
  • Referrals: 2
    • View Profile
Re: Sorting Script Issue
« Reply #1 on: May 09, 2015, 10:10:53 PM »
0
there are a few problems.  I will add comments to your code below where I foresee problems.

Code: [Select]
SUB MAIN
    FINDITEM %bag_scan G_1
    SET #LOBJECTID #FINDID
    EVENT MACRO 17 0
    WAIT 1S
    loop:
    FINDITEM * C_ , %bag_scan
    SET %temp_count #FINDCNT
    EVENT SYSMESSAGE %temp_count
    SET %item_temp #FINDID
    IF #FINDCNT < 1
         gosub new_bag ;after newbag, finditem should be called again.  Otherwise, when it moves on #findid is the previously stored data or N/A or something.
    SET #LTARGETID #FINDID
    SET #LTARGETKIND 1
    SET %jstart #jindex
    IF %use_wand = #TRUE
    {
       FINDITEM %wand C_ , #CHARID
       IF #FINDKIND = #TRUE ;what is this?  if #findcnt < 1 is probably better here.
       {
       FINDITEM %wand C_ , #BACKPACKID
       IF #FINDCNT < 1
          {
          SET %use_wand #FAlSE
          RETURN
          }
       SET #LHANDID #FINDID
       EVENT MACRO 24 1
       WAIT 1s
       }
       FINDITEM %wand C_ , #CHARID ;why find it again?  You know the id.  It was just found and p ut in your left hand.
       SET #LOBJECTID #FINDID
       EVENT MACRO 17 0
    }
    IF %use_wand = #FALSE
       EVENT MACRO 13 3
    TARGET ;need to put a time here to wait.  Target 1s
    EVENT MACRO 22 0
    WAIT 1s
    SET %jend #jindex
    FOR %i %jstart %jend
    {
    SCANJOURNAL %i
    ;WAIT 1s
    EVENT SYSMESSAGE %i
    SET %temp_var %i
   
;----- BIG jumbled mess of sorting
    FINDITEM %item_temp C_ , %bag_scan
    ;I would say if #findcnt < 1 ;something fishy is up, maybe go up. 
    ;I would also set %ItemID #findid
    IF #FINDTYPE in %mask
    {
         SET %bag_drop %mask_bag
         GOSUB drop
    }
    IF ( fortification IN #JOURNAL )
    {
       if #FINDTYPE in %ring
           SET %bag_drop %f_ring
       if #FINDTYPE in %chain
           SET %bag_drop %f_chain
       if #FINDTYPE in %plate
           SET %bag_drop %f_plate
       if #FINDTYPE in %helmet
           SET %bag_drop %f_helm
       if #FINDTYPE in %shield
           SET %bag_drop %f_shield
       gosub drop  ;then add %ItemID here, maybe even the bag --  gosub drop %ItemID %bag_drop
    }
    IF ( invulnerability IN #JOURNAL )
    {
       if #FINDTYPE in %ring
           SET %bag_drop %i_ring
       if #FINDTYPE in %chain
           SET %bag_drop %i_chain
       if #FINDTYPE in %plate
           SET %bag_drop %i_plate
       if #FINDTYPE in %helmet
           SET %bag_drop %i_helm
       if #FINDTYPE in %shield
           SET %bag_drop %i_shield
       if #FINDTYPE in %leather
           SET %bag_drop %leat
       if #FINDTYPE in %studded
           SET %bag_drop %stud
       gosub drop
    }
    IF ( teleporting IN #JOURNAL )
    {
       SET %bag_drop %tele
       GOSUB drop
    }
    IF ( reflection IN #JOURNAL )
    {
       SET %bag_drop %flect
       GOSUB drop
    }
    IF ( invisibility IN #JOURNAL )
    {
       SET %bag_drop %invis
       GOSUB drop
    }
    IF ( reaction IN #JOURNAL )
    {
       SET %bag_drop #backpackid
       GOSUB drop
    }
    ;wands
    IF ( Greater in #journal ) && ( #FINDTYPE in %wand )
    {
         set %bag_drop %gheal
         gosub drop
    }
    IF ( lightning in #journal ) && ( #FINDTYPE in %wand )
    {
         set %bag_drop %lb
         gosub drop
    }
    IF ( identification IN #JOURNAL )
    {
       SET %bag_drop %id
       GOSUB drop
    }
    ;weapons
    IF ( touch in #JOURNAL )
    {
       SET %bag_drop %touch
       GOSUB drop
    }
    IF ( breath in #JOURNAL ) || ( lightning in #JOURNAL )
    {
            if #FINDTYPE in %sword
            {
                 SET %bag_drop %c_sword
                 GOSUB drop
            }
            if #FINDTYPE in %mace
            {
                 SET %bag_drop %c_mace
                 GOSUB drop
            }
            if #FINDTYPE in %arch
            {
                 SET %bag_drop %c_arch
                 GOSUB drop
            }
            if #FINDTYPE in %fenc
            {
                 SET %bag_drop %c_fenc
                 GOSUB drop
            }
    }
    IF ( force in #JOURNAL ) && ( #FINDTYPE = %halberd )
    {
       SET %bag_drop %p_halb
       GOSUB drop
    }
    IF ( power in #JOURNAL )
    {
       if #FINDTYPE in %sword
           SET %bag_drop %p_sword
       if ( #FINDTYPE = %halberd )
           SET %bag_drop %p_halb
       if #FINDTYPE in %mace
           SET %bag_drop %p_mace
       if #FINDTYPE in %arch
           SET %bag_drop %p_arch
       if #FINDTYPE in %mace
           SET %bag_drop %p_fenc
       gosub drop
    }
    IF ( vanquishing in #JOURNAL )
    {
       if #FINDTYPE in %sword
           SET %bag_drop %v_sword
       if ( #FINDTYPE = %halberd )
           SET %bag_drop %v_halb
       if #FINDTYPE in %mace
           SET %bag_drop %v_mace
       if #FINDTYPE in %arch
           SET %bag_drop %v_arch
       if #FINDTYPE in %mace
           SET %bag_drop %v_fenc
       gosub drop
    }
    ;------
    IF ( You_are_not_certain... IN #JOURNAL )
    {
       WAIT 9S
       GOTO loop
    }
    IF ( This_item_is_out_of_charges. IN #JOURNAL )
    {
       FINDITEM %wand C_ , #CHARID
       IF #FINDKIND = #FALSE
       {
          SET %x ( #CHARPOSX ) ;maybe add a +1 offset... or drop it in a garbage can?
          SET %y ( #CHARPOSY )
          EXEVENT DRAG #FINDID
          WAIT 1S
          EXEVENT DROPG %x %y ;some servers don't let you drop at feet.
       }
       GOTO loop
    }
    deleteJournal
    }
    IF %use_wand = #FAlSE
       WAIT 9s
    ;WAIT 1s
    IGNOREITEM %item_temp
    GOTO loop
RETURN
 
 
;---------------------------------
;        Function subs
;---------------------------------
SUB drop
    FINDITEM %item_temp C_ , %bag_scan ;you do not need to find the item again.  Just pass the id in as a variable. as I mentioned above.
    if #findcnt < 1
         ignoreitem %item_temp
    EXEVENT DRAG #FINDID ;if you pass id in as variable, you would start here with exevent drag %1
    WAIT 1S                      ;no need for this wait
    EXEVENT DROPC %bag_drop  ;works, or you could pass the bag in as a variable too and use exevent dropc %2
    SCANJOURNAL #jindex ;this is absolutely unreliable...  what happens if one is ful land then you fix it and pres play and the journal hasn't changed?  Get false error.
    IF ( weight IN #JOURNAL ) || ( cannot_hold IN #JOURNAL )
    {
       DISPLAY %bag_drop is FULL
       HALT
    }
    ;EXEVENT DROPC #backpackid  ;?? You already dropped it.  This is not worth doing.
    ;you need wait 20 after moving an item.
RETURN
 
 
sub new_bag
     SET #TARGCURS 1
     set %timer #scnt
     WHILE #TARGCURS = 1
     {
        if %Timer < #scnt
       {
               EVENT SYSMESSAGE Target bag to ID!
               set %Timer #scnt + 5
        }
     }
     SET %bag_scan #LTARGETID
return

There is a lot more you can do in terms of structure as well to make it a lot more clean.
R~~~~ B~~~~~~~~ 
^ real life signature for sure

Tags: