#(danjoe3) Sell All feature & Script review

43 messages · Page 1 of 1 (latest)

blissful finch
#

Hey there!

I'm currently trying to create a sell-all feature. I've been able to create a sell-hand system, but a sell-all is something I'm having an issue with. Could you let me know what needs to be done to achieve this? I've got a data script showing all the sell amounts and would like to know how I could go on about it.

I'd also like some feedback with my sell-hand function too please! 😬 I'm sure there's a simpler way to go on about this! https://paste.denizenscript.com/View/121376

winter needleBOT
#

(danjoe3) Sell All feature & Script review

winter needleBOT
#

Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.

dusk plume
#

Right off the bat, how would you know if I sold a stone, that it would be in the 'Blocks' key? I'd recommend sticking to a single key for all blocks, i.e. <script[novashop_data].data_key[Blocks.<[YourBlock].material.name>]>

For sell_cmd, the indent spacing looks weird. No need to indent it at all after the script key.
Did you use VS Studio with the Denizen plugin installed?

#

Instead of parsing the entire inventory a few times to see what matches, why not do it once.

Grab the contents of the inventory; exclude anything that needs to be excluded, then foreach the list against what you want allowed to be sold. If the key doesn't exist for the item, then - foreach next.

pseudo rose
#

I mean, you don't even have to do the contents grabbing, excluding part.

blissful finch
# dusk plume Right off the bat, how would you know if I sold a stone, that it would be in the...

I understand that, I think that would be easier instead of doing a bunch of for loops. But if the item was a diamond? I’d have to change the data key from blocks to ores. Or would you suggest that I just have the entire data as a separate data script just for selling?

The indent spacing is a bit weird because I was doing some testing earlier. I didn’t mean to paste in that itself, my bad there!

pseudo rose
#

Loop through the inventory contents and compare each item to your list of sellable materials.

#

If it is a sellable material, take the item + reward it.

#

If you want a fancy narrate message, create a definition with the amount of money given.

#
- foreach <player.inventory.list_contents> as:item:
  - if <[item].script.if_null[null]> != null:
    - foreach next
  - if <[item].material.name> in <[sellable_items]>:
    - take item:<[item].material.name> quantity:<player.inventory.quantity_item[<[item].material.name>]>
    - give xyz.mul[<player.inventory.quantity_item[<[item].material.name>]>]
    - define amount:+:<script.data_key[x.y.z]>
- narrate "You received <[amount]>
#

Obviously you have to do more checks to identify, what Items are sellable, to prevent accidentally selling the wrong items.

pine shoal
#

Wouldn't it be easier to just get all the slots that match the item they're tying to sell?

#

!t find_all_items

oblique mountainBOT
pine shoal
#

can also use slot instead of matcher in take command that way

pseudo rose
#

How do you identify the item?

pine shoal
#

The item they're trying to sell?

#

I'd assume they only want non script items to be sellable, so check if script doesnt exist and then .find_all_items[<[item].material.name>]?

pseudo rose
#

Why would you need this extra step

pine shoal
#

how is this an extra step

#

instead of looping thru all contents, only loop thru matched items

#

well the slots rather

pseudo rose
#

One loop for filtering out. Another loop to loop through matched items.

pine shoal
#
- foreach <player.inventory.find_all_items[matcher]> as:slot:
  - foreach next if:<player.inventory.slot[<[slot]>].script.exists>
  - take slot:<[slot]> ...```
pseudo rose
pine shoal
pseudo rose
#

I wouldn't use the matcher filter. Looking into Danjoes script it will add a lot of matchers that will checked against every item in another loop

#

This is what I'm talking about

pine shoal
#

Oh, I thought it'd be the easiest way but it might not be as efficient

pseudo rose
#

If an item got renamed, is it still a sellable item? Are enchanted items still sellable?

blissful finch
#

The sell hand, how would you guys suggest I go about it? As my data script has keys that are blocks, wood, red stone etc. Would you guys suggest that I make a separate data script just for selling?

pseudo rose
#

Do you only go for plain materials?

#

If that's the case you could just flag the material.

#

and save the data there

blissful finch
dusk plume
#

Either on the server side, or the actual item players have in their inventory.

blissful finch
#

So instead of using a data script, just flag the item with the sell price within a server flag?

pseudo rose
#

in a material flag

blissful finch
#

Awesome! Thank you so much!