1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Reading lore of player's item

Discussion in 'Skript' started by TheVedel1, Aug 20, 2017.

Thread Status:
Not open for further replies.
  1. TheVedel1

    TheVedel1 Member

    Joined:
    Jul 28, 2017
    Messages:
    14
    Likes Received:
    0
    Skript Version:2.2-dev29
    Skript Author:
    bensku
    Minecraft Version: 1.12.1
    ---
    Full Code:

    Code (Skript):
    1.  
    2. on right click on player:
    3.     if name of clicked player is "&a&lTrader":#12
    4.         set {_lore::*} to lore of player's tool split by "||"
    5.         loop {_lore::*}:
    6.             set {parsed::*} to loop-text parsed as "Sell Price: %number%"
    7.             set {_price::*} to uncolored loop-text parsed as "Sell Price: %text%"
    8.             set {_price} to {parsed::1}
    9.             play "BLOCK_NOTE_XYLOPHONE" to player at volume 1
    10.             broadcast "&6Item is worth: &e%{_price}% Gold"
    11.             exit loop
    12.             stop
    13.  
    So I'm trying to make a Skript that can tell how much a player's item is worth by rightclicking an NPC. I'm just getting 2 errors, %number% and %text% is not valid item data. I haven't used parsing before, and I'm not sure how Subtext works, the wiki doesn't tell me much.

    The forums seem empty on this subject, and the ones who have something regarding this, have code that doesn't work either.

    I wonder if this is possible?

    Thank you,
    Zwac
     
  2. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    232
    The only thing you're doing wrong is using loop-text instead of loop-value, loop-text would only work with text literals.
     
  3. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    232
    Thank you for the quick reply. Well I have no errors now, it just writes "item is worth <none> Gold".

    Replaced loop-text with loop-value.
     
  4. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    232
    Could you show me how the lore of the item looks like? Also, what does {_price::1} outputs?
     
  5. ShaneBee

    Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,183
    Likes Received:
    232
    Ok so I had to restart my server for it to read lore properly, might be a citizens bug? {_price::*} and {_price::1} now outputs the correct amount.

    You saved my day @Snow-Pyon, thank you so much <3
    --- Double Post Merged, Aug 20, 2017, Original Post Date: Aug 20, 2017 ---
    Sorry to disturb you again @Snow-Pyon, but I have a similar error now, trying to sell all items containing the right lore. I get the item data error again.
    Can you spot why? Oh and btw, It removes 1 of each of the looped items, but what if you have a stack of 2? I've tried messing around with it, but the money dont add up, it just removes more items.

    Code:
    Code (Skript):
    1. command /sellall:
    2.     trigger:
    3.         loop all items in player's inventory:
    4.             set {_lore::*} to lore of loop-item split by "||"
    5.             loop {_lore::*}:
    6.                 set {_test::*} to uncolored loop-value parsed as "Sell Price: %number% %text%"
    7.                 play "BLOCK_NOTE_XYLOPHONE" to player at volume 1
    8.                 remove 1 of loop-item from player's inventory
    9.                 add {_test::1} to player's balance
    10.                 send "&6You sold your item for: &e%{_test::1}% Gold" to player
    11.                 send "&6You now have: &e%player's balance% Gold" to player
    12.                 exit loop
    13.                 stop

    Thank you very much.
    --- Double Post Merged, Aug 21, 2017 ---
    bump. Anyone got an idea how to do this?
     
Thread Status:
Not open for further replies.

Share This Page

Loading...