Author Topic: Backpack Inventory  (Read 6461 times)

0 Members and 1 Guest are viewing this topic.

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +304
  • Referrals: 1
    • View Profile
Backpack Inventory
« on: May 26, 2011, 08:36:27 AM »
0
I have a series of crafting scripts that have a history of making the wrong item on occasion, derailing the script.  I think this is a product of trying to optimize speed.  This also caused issues clearing items out of the backpack since the items that were getting made were pretty random.  For several months I have been trying to come up with a solution that will allow me to maintain speed and efficiency, but detect the random items to tell me when to reset the process.  A secondary concern is getting the random stuff out of the backpack.  

I finally came up with a solution today that involves taking an inventory of IDs of the items in the backpack at the start of the script and capturing them in a variable.  I am using it as a check against items I make to confirm correct make, and to keep from throwing things away.  It's pretty simple, but I figured I would share since it took me so long to figure it out.



Code: [Select]
Finditem * C_ , #BackpackID
Set %BackpackItemString BackpackContents:
For #Findindex 1 #FindCnt
    {
    Set %BackpackItemString %BackpackItemString , #FindID
    Set %BackpackItemString %BackpackItemString , _
    }

The second line inserts an underscore between IDs to avoid the extremely unlikely occurrence of an ID getting duplicated with parts of other IDs.
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +786
  • Referrals: 1
    • View Profile
Re: Backpack Inventory
« Reply #1 on: May 26, 2011, 09:46:40 AM »
0
nice.
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Outlaw Josey Wales

  • Full Moon Rising!
  • Hero Member
  • *
  • Posts: 595
  • Activity:
    0%
  • Reputation Power: 7
  • Outlaw Josey Wales has no influence.
  • Gender: Male
  • Respect: +121
  • Referrals: 2
    • View Profile
Re: Backpack Inventory
« Reply #2 on: May 26, 2011, 10:03:05 PM »
0
nice job

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +600
  • Referrals: 2
    • View Profile
Re: Backpack Inventory
« Reply #3 on: May 27, 2011, 05:12:52 AM »
0
Cool idea, so simple yet so effective :)

You could also just do this to simplify three line further:

Code: [Select]
Finditem * C_ , #BackpackID
Set %BackpackItemString BackpackContents:
For #Findindex 1 #FindCnt
    Set %BackpackItemString %BackpackItemString , #FindID , _

X
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline PauloniusTopic starter

  • Elite
  • *
  • *
  • Posts: 2040
  • Activity:
    0%
  • Reputation Power: 29
  • Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.Paulonius is on the verge of being accepted.
  • Respect: +304
  • Referrals: 1
    • View Profile
Re: Backpack Inventory
« Reply #4 on: May 27, 2011, 10:18:57 AM »
0
Thanks 12X,  I was not sure how many additional phases your could append to it, so I did it with an extra line.
This coin declares Caesar is "Dictator for Life." He did serve as Dictator for the remainder of his life, but his life would end only a few weeks after this issue. For Caesar to put his image on coins and essentially declare himself king was too much for Brutus and his republican allies.

"If everything seems under control, you're not going fast enough'
-Mario Andretti

"If everyone is thinking alike, someone isn't thinking."
- General George Patton Jr

Offline Dixie Wrecked

  • Full Member
  • ***
  • Posts: 124
  • Activity:
    0%
  • Reputation Power: 3
  • Dixie Wrecked has no influence.
  • Gender: Male
  • Respect: +61
  • Referrals: 1
    • View Profile
Re: Backpack Inventory
« Reply #5 on: May 27, 2011, 12:05:11 PM »
0
I did this exact same thing in my BOD filling script in order to clean the backpack out after each book is filled.  I haven't released that version yet, as it only trashes the extra items right now and I want to make it unravel or smelt some of them first.  This was the only option I could think of as well, although I also had to set a variable of item types that might be new and not want to be trashed (tongs, tinker tools, sewing kits, etc), as I add the IDs of these items to the initial inventory string so that I don't remove them from the backpack when I know they will be needed later.
"hmm, theres no examples and directions sticky in new member intros.  you have to admit script library would have been a good place to put it"
- karrde

Tags: