Author Topic: little help with strings and numbers please  (Read 3870 times)

0 Members and 1 Guest are viewing this topic.

Offline SuperslayerTopic starter

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
little help with strings and numbers please
« on: February 24, 2009, 05:48:59 PM »
0
Here I have a sub that restocks mage reagents from a secure (albeit home or bank) and drops them in the characters backpack.  It first checks to see what mage regs are in the pack and how many of them there are.  Then check against a known list of mage regs and jots them down for retrieval.  Next a few string operations deduce what regs and how many are needed, then the find, drag and drop operations commence.  All is well, until .... the number of reagents is less than ten. The string operations fudge themselves up and all is lost.  So what I'm looking for is, how can I fix the single digit issue without rewriting most of the sub.  I'm aware that it isn't atm picking up the regs that aren't there at all, that'll be soon after I hurdle this.  On to the sub, Warning, not the pretties coding, but just quick and functional, here it is:

Code: [Select]
gosub Reg_restock_check #backpackid

display ok Location: Backpack$
+Regs found:$
+ %regsfound $
+regs needing stock:$
+ %restockreg $
+regs missing:$
+ %regsmissing $

goSub SS_Stock_Resources

sub Reg_restock_check
  event macro 8 7
  set %maxregsneeded 50
  set %regs _KUF_KZF_JUF_MZF_JZF_WZF_RZF_SZF
  set %regsmissing
  set %regsfound
  set %restockreg
  finditem %regs C_ , %1
  if #findcnt > 0
  {
    set %restockreg
    set %regsfound
    set #findindex 0
    for #findindex 1 #findcnt
    {
      set %regtype #findtype
      set %regamount #findstack
      if %regamount < %maxregsneeded
      {
        set %regsneeded %maxregsneeded - %regamount
        set %restockreg %restockreg , %regtype , #spc , %regsneeded , #spc $
      }
      set %regsfound %regsfound , %regtype , #spc , %regamount , $
    }
  }
  if #findcnt < 8
  {
regs_missing_loop:
    str pos %regs _
    if #strres = 0
      goto regs_missing_end
    set %length #strres - 1
    str left %regs %length
    set %value #strres
    if %value notin %regsfound
      set %regsmissing %regsmissing , #spc , %value
    set %area %length + 1
    str del %regs 1 %area
    set %regs #strres
    goto regs_missing_loop
regs_missing_end:
  }
return
;------------------------------

Sub SS_Stock_Resources
  set %homesecure ; Fill in the blank here for your testing
  if %restockreg <> N/A
  {
    set #strres %restockreg
    set %tempstring #strres
reg_stock_loop:
    str pos %tempstring #spc
    if #strres = 0
      goto reg_stock_end
    set %templength %tempstring + 6
    str left %tempstring %templength
    set %stockregtypeamt #strres
    set %cut %templength + 1
    str del %tempstring 1 %cut
    set %tempstring #strres
    ;--------------------- reg amt nibble -----------
    set #strres %stockregtypeamt
    str pos %stockregtypeamt #spc
    set %finallength %stockregtypeamt + 2
    str right %stockregtypeamt %finallength
    set %finalregamt #strres
    ;--------------------- end reg amt nibble
    ;------------------- reg type nibble --------------
    set #strres %stockregtypeamt
    str pos %stockregtypeamt #spc
    set %finallength %stockregtypeamt + 3
    str left %stockregtypeamt %finallength
    set %finalregtype #strres
    ;----------------------end reg type nibble
    finditem %finalregtype C_ , %homesecure
    set %reg #findid
    exevent drag %reg %finalregamt
    wait 15
    exevent dropc %1
    wait 15
    ignoreitem %reg
    set %tempcut %templength + 1
    str del %restockreg 1 %tempcut
    set %restockreg %tempstring
    goto reg_stock_loop
reg_stock_end:
  }
stop

Something else while I'm at it, why does this part work without the gump?
Quote
finditem %finalregtype C_ , %homesecure
    set %reg #findid
    exevent drag %reg %finalregamt
    wait 15

I imagine later down the road it may become problematic and it does work atm, but why?  I kinda don't like that it does, but it does? ???

Offline OMGBurgers

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: little help with strings and numbers please
« Reply #1 on: February 24, 2009, 06:29:22 PM »
0
The exevent drag will never show the quantity gump that's the difference between the exevent drag and event drag.  Exevent drag I believe is the newer version and may not work on older shards/clients, but I'm not totally sure.  I actually won't use any script that don't use the Exevent drag when it comes to items of quantity because they tend to mess up in their scripts.

I'll test your script now though and reply back about your other issue.  Just wanted to post that for ya.  Hopefully that's what you're talking about lol.

Offline OMGBurgers

  • Hero Member
  • *
  • Posts: 800
  • Activity:
    0%
  • Reputation Power: 7
  • OMGBurgers has no influence.
  • Respect: +44
  • Referrals: 0
    • View Profile
Re: little help with strings and numbers please
« Reply #2 on: February 24, 2009, 06:48:11 PM »
0
It seems to be working for me.  I thre just three reagents in my pack and got the following message:

Quote
Location: Backpack
Regs found:
MZF 50
KUF 20
KZF 5

regs needing stock:
KUF 30 KZF 45
regs missing:
JUF JZF WZF RZF

Which looks to be correct.

It even restocked correctly for me! :)

One thing that did mess me up is this line:
Code: [Select]
  set %homesecure ; Fill in the blank here for your testing

I had entered my ID for my secure but didn't have a space between the secureid and the ;.  So it kept messing up the find id.  Once I put the space in it all worked perfect.  But that was just me being me... stupid! hahaha.

Offline SuperslayerTopic starter

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: little help with strings and numbers please
« Reply #3 on: February 24, 2009, 07:44:43 PM »
0
Awesome guys, thanks.  I was wondering about the differenced between exevent drag and event drag was.

now on the the completely missing regs :P

Offline SuperslayerTopic starter

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: little help with strings and numbers please
« Reply #4 on: February 24, 2009, 09:13:51 PM »
0
Wow, I'm liking strings more and more  ;D ;D ;D ;D ;D ;D

This works !!

Code: [Select]
if %regsneeded <= 9
         {
          set %Zero 0
          str ins %regsneeded %Zero 0
          set %regsneeded #strres
         }

Offline SuperslayerTopic starter

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: little help with strings and numbers please
« Reply #5 on: June 24, 2009, 11:15:48 AM »
0
this thread can be deleted

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13301
  • Activity:
    0%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: little help with strings and numbers please
« Reply #6 on: June 24, 2009, 11:21:16 AM »
0
We won't delete anything, but might put a [SOLVED] tag in the title.
Please read the ScriptUO site RULES
Come play RIFT with me!

Tags: