Skript Lists

  • 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 community!

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Blobbyguy

Member
Feb 2, 2017
25
0
0
Bloblandia
I've run into this issue in a few projects I've been working on and was wondering if anyone knew of a way to do the following:

Hey, what's the best item to add a value to a list value? E.g. {Shop::%Contents List%::emoji_stuck_out_tongue:rice}. I'm having an issue where I have two items that are the exact same in the list, and I want to change the price. If I just set {Shop::%Item%::emoji_stuck_out_tongue:rice} to say 50, it updates both the instances of the item. If someone knows a better way to structure something like this or knows how to work around this, please let me know.

Some people have suggested switching to {Shop::emoji_stuck_out_tongue:rice::Item} but tI'm hesitant to do that as I would like to store other data under the instance of the item, almost having it act like a structure/class. E.g. {Shop::%Contents List%::emoji_stuck_out_tongue:rice}, {Shop::%Contents List%::OtherInfo}, {Shop::%Contents List%::MoreInfo}(edited

Thanks in advance! ^_^
 
I've run into this issue in a few projects I've been working on and was wondering if anyone knew of a way to do the following:

Hey, what's the best item to add a value to a list value? E.g. {Shop::%Contents List%::emoji_stuck_out_tongue:rice}. I'm having an issue where I have two items that are the exact same in the list, and I want to change the price. If I just set {Shop::%Item%::emoji_stuck_out_tongue:rice} to say 50, it updates both the instances of the item. If someone knows a better way to structure something like this or knows how to work around this, please let me know.

Some people have suggested switching to {Shop::emoji_stuck_out_tongue:rice::Item} but tI'm hesitant to do that as I would like to store other data under the instance of the item, almost having it act like a structure/class. E.g. {Shop::%Contents List%::emoji_stuck_out_tongue:rice}, {Shop::%Contents List%::OtherInfo}, {Shop::%Contents List%::MoreInfo}(edited

Thanks in advance! ^_^
Maybe try to find the loop-index of both those two same items (e.g. 26 and 27), and edit the price of just one of them. Even though they're "the same thing", they're not the same element of the array, so what differs from them is their index.
 
What do you mean it's updating "both instances"? You can't store the same index in a list twice. If you doing something like "set {shop::%item%:: price} to 50", then do it again, you're not creating two instances, you're just creating it once then overwriting it.

You need to think about why you need two instances and structure your variables accordingly. Why can the same item have two different prices? Are there different shops that can price the item differently? If so, index the item prices by the name/ID of the shop, such as {shop::%shop ID%::%item%:: price}. Is this a per-player thing? If so, you can index it by each player's UUID, such as {shop::%player's UUID%::%item%:: price}.
 
Status
Not open for further replies.