Paste #9638: Issue Selling Bag Detailed Bug Fixing log + FIX

Date: 2014/09/14 05:32:05 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


on player right clicks with i@selling bag:
    - announce "Right Click"
    - define is_shopping false  
    - foreach <global.flag[playerstore].escape_contents> {
      - if <player.location.is_within[<def[value].unescaped>]> {
        - announce "Shopping is true!"
        - define is_shopping true  
        - foreach stop  
        }  
      }  
    - if !%is_shopping% {
      - Announce "Shopping Bag Clear"
      - inventory clear d:in@<player.name>_selling_bag
      - narrate '<dark_red>You are not in a shop right now!'
      - take 'i@selling bag'
      - determine cancelled
      } 


Walktrough:

################################################
STEP 1

What I did is:

- type sell
- selling bag dropped
- right click with selling bag.
- got narrated: "Right Click" and "Shopping is True!"

Conclusion:

- if <player.location.is_within[<def[value].unescaped>]> This is the cause.

###############################################
STEP 2

What I did is:

- right click with selling bag while debugging:
- Debug: http://mcmonkey.org/paste/9627
- moved outside shop
- found out this is not the issue.

Conclusion:

This is to determine that the player is in the shop as it seems.
Shopping bag clear is removal bag.

##############################################
STEP 3

What I did is:
- say sell while debugging, right click selling bag
- debug: http://mcmonkey.org/paste/9628

Conclusion:

Can't find any clear action?

#############################################
STEP 4

What I did is:
- click storekeeper with selling bag with item: Quartz Block ( 155:1 )
- Debug: http://mcmonkey.org/paste/9630

Conclusion: Found possibile Error! It seems to have saved a Diamond Pickaxe?

############################################
STEP 5

What I did is:
- reproduce step 4 with longer debug.
- click storekeeper with selling bag with item: Quartz Block ( 155:1 )
- debug: http://mcmonkey.org/paste/9632

Debug:  ( I see alot of Null's, is it supposed to be this way? )

13:18:59 [INFO] +- Executing dCommand: IF/p@NLBlackEagle ---------+ 
13:18:59 [INFO]  Filled definition %is_shopping% with 'true'. 
13:18:59 [INFO]  Filled definition %is_shopping% with 'true'. 
13:18:59 [INFO]  Filled definition %is_shopping% with 'true'. 
13:18:59 [INFO]  Filled tag <player.name> with 'NLBlackEagle'. 
13:18:59 [INFO]  Filled tag <in@NLBlackEagle_shopping_bag||null> with 
                   'in@nlblackeagle_shopping_bag'. 
13:18:59 [INFO]  Comparable 1: Logic='NEGATIVE', 
                   Comparable='Boolean(true)', Operator='EQUALS', 
                   ComparedTo='Boolean(true)' --> OUTCOME='false' 
13:18:59 [INFO] +- Executing dCommand: IF/p@NLBlackEagle ---------+ 
13:18:59 [INFO]  Filled definition %is_shopping% with 'true'. 
13:18:59 [INFO]  Filled definition %is_shopping% with 'true'. 
13:18:59 [INFO]  Filled tag <player.name> with 'NLBlackEagle'. 
13:18:59 [INFO]  Filled tag <in@NLBlackEagle_shopping_bag||null> with 
                   'in@nlblackeagle_shopping_bag'. 
13:18:59 [INFO]  Comparable 1: 
                   Comparable='Element(in@nlblackeagle_shopping_bag)', 
                   Operator='EQUALS', ComparedTo='Element(null)' --> 
                   OUTCOME='false' 
13:18:59 [INFO]  Comparable 2: Comparable='Boolean(true)', 
                   Operator='EQUALS', ComparedTo='Boolean(true)' --> 
                   OUTCOME='true'  

Conclusion:

else if <in@<player.name>_shopping_bag||null> == null && %is_shopping% { 

Null?

[edit] This does not seems to be a issue.

############################################
Step 6

What I did is:
Check the script closely: on click under assignment

- Found: - note 'in@selling bag' as:<player.name>_selling_bag
- Search: - note remove

Conclusion: No remove =/
###########################################
Step 7

What I did is:
- ask myself: Where the FUCK do you erase the content of the Selling bag????

        } else if <npc.owner> == server {
        - chat "ok let's total these items up for you then!" 
        - define total_price 0 
        - foreach <in@<player.name>_selling_bag.list_contents> { 
          - adjust %value% quantity:1 save:item
          - define price <yaml[prices].read[prices.<<entry[item].result>.full.escaped>].mul[<%value%.qty>]> 
          - define total_price <el@val[%total_price%].add[%price%]> 
          } 
        - note 'in@selling bag' as:<player.name>_selling_bag
        - give money qty:%total_price% 
        - take 'i@selling bag'
        - narrate "<aqua>The shopkeeper gives you <green>%total_price% coins"
        - foreach <in@<player.name>_shopping_bag.list_contents.full.escaped> { 
          - adjust %value% quantity:1 save:item9
          - flag server <<entry[item9].result>adjust:-:<def[value].qty>
          - run script:price_adjuster def:<entry[item9].result>

Conclusion:
Back to the freaking sell talk event... Since I dont see any removal here.
###########################################
Step 8

What I did is:
- being frustrated
- search on sell message.
  - conclusion: Nothing there.
- search on click event with selling bag

Conclusion:
Found on player picks up i@shopping_bag.


FIX:

    on player picks up i@selling bag:
    - if '<player.inventory.contains[i@selling bag]>' {
        - determine cancelled
      } else {
        - note 'in@player bag' as:<player.name>_selling_bag
        - narrate "<aqua>You pick up a brand new selling bag. It's empty!"
      }

##########################################