Item Storer

  • 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.

LoneElf

Active Member
Apr 30, 2017
165
2
18
Hi. So I am trying to make an ITEM STORER thing, where when you open a chest, it cancels the event but opens a chest with 1 row, formatting the first 3 and the last 3 slots with magenta glass panes. So, that was obviously easy, but what is hard is getting when the player puts an item in the 3 empty slots in the middle. So, in a regular chest, if I put something there, it saves it. Now, I tried doing something like this: if slot 3 of player is set: set {_item1} to slot 3 of player , but it didn't work because the slot number 3 is set with air when you open it, so whenever I open it the next time after putting an item in, it sets slot 3 to air, as I did: set slot 3 of player to {_item1} to close. Now, I need help with that, knowing what item is being put into that slot, and allowing the item to be accessed. Thank you! Sorry about my explanations. Mostly, they are horrible! :emoji_slight_smile:

- LoneElf
 
It may not be the full issue, but you're setting the items in the slots to local variables which do not save once the gui is closed. it would need to be something like {item.%player%} with no underscore and a player, just to differentiate it from everyone else's item variables
It would also help a lot if you posted the full code you are using for it
 
Sorry about the code not being supported. My bad. Here it is:
code_language.skript:
on right click on chest:
        cancel event
        open chest with 1 row named "&dItem Storer" to player
        wait 1 tick
        format slot 0 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 1 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 2 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 3 of player with {item1.%uuid of player%} to close
        format slot 6 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 7 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 8 of player with 160:2 named "&dStore your items in the empty slots!" to close

Thanks for the help in advanced!
 
Sorry about the code not being supported. My bad. Here it is:
code_language.skript:
on right click on chest:
        cancel event
        open chest with 1 row named "&dItem Storer" to player
        wait 1 tick
        format slot 0 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 1 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 2 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 3 of player with {item1.%uuid of player%} to close
        format slot 6 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 7 of player with 160:2 named "&dStore your items in the empty slots!" to close
        format slot 8 of player with 160:2 named "&dStore your items in the empty slots!" to close

Thanks for the help in advanced!
I do believe this will do what you want.^-^ It does need SkRayFall for the store and unstore event, but it works very well. Sorry it took me a while I'm a very slow coder lol.
code_language.skript:
on right click on chest:
    cancel event
    open chest with 1 rows named "&dItem Storer" to player
    wait 1 tick
    format slot 0 of player with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    format slot 1 of player with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    format slot 2 of player with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    loop {inventory.%player%::*}:
        set slot 3 of player's current inventory to "%{inventory.%player%::1}%" parsed as item
        set slot 4 of player's current inventory to "%{inventory.%player%::2}%" parsed as item
        set slot 5 of player's current inventory to "%{inventory.%player%::3}%" parsed as item
    format slot 6 of player with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    format slot 7 of player with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    format slot 8 of player with magenta stained glass pane named "&dStore your items in the empty slots!" to close
       
on store:
    if name of player's current inventory contains "&dItem Storer":
        add "%item%" to {inventory.%player%::*}
       
on unstore:
    if name of player's current inventory contains "&dItem Storer":
        loop {inventory.%player%::*}:
            set {_item} to loop-value
            if {_item} = "%loop-value%":
                remove "%item%" from {inventory.%player%::*}
 
Last edited by a moderator:
Thanks a lot man! I learned something new from you, and don't worry, if you are helping me, don't worry about how fast you code :emoji_stuck_out_tongue: :emoji_slight_smile:
[doublepost=1501173622,1501171643][/doublepost]Ah. So now that I tested it as the auth thing is done, when I SHIFT CLICK an item, it doesn't go in the empty slots, then after that, when I put an actual item in, the shifted one is in when I open the GUI again as well as the other item which shouldn't happen because I still have the shifted clicked item in my inventory which leads to duping. An item doesn't have to be placed in the empty slots after the shifted clicked item, it can just be the shifted clicked item. It is like this: It cancels the SHIFT CLICK event but the GUI things it is there when you open it again, but my inventory still keeps the shifted clicked item because it was canceled. I honestly don't know, it is quite confusing. Thanks :emoji_slight_smile:
[doublepost=1501173969][/doublepost]Also, when I shift click the item out of the GUI, it says there and doesn't go into my inventory, but when I re-open the GUI, it is gone and I no longer have my item. Thanks again :emoji_slight_smile:
 
Thanks a lot man! I learned something new from you, and don't worry, if you are helping me, don't worry about how fast you code :emoji_stuck_out_tongue: :emoji_slight_smile:
[doublepost=1501173622,1501171643][/doublepost]Ah. So now that I tested it as the auth thing is done, when I SHIFT CLICK an item, it doesn't go in the empty slots, then after that, when I put an actual item in, the shifted one is in when I open the GUI again as well as the other item which shouldn't happen because I still have the shifted clicked item in my inventory which leads to duping. An item doesn't have to be placed in the empty slots after the shifted clicked item, it can just be the shifted clicked item. It is like this: It cancels the SHIFT CLICK event but the GUI things it is there when you open it again, but my inventory still keeps the shifted clicked item because it was canceled. I honestly don't know, it is quite confusing. Thanks :emoji_slight_smile:
[doublepost=1501173969][/doublepost]Also, when I shift click the item out of the GUI, it says there and doesn't go into my inventory, but when I re-open the GUI, it is gone and I no longer have my item. Thanks again :emoji_slight_smile:
I was able to fix the shift click issue by setting the inventory up to function more like a GUI with functions being called on click events that essentially do the moving for you.
So you click the chest, your GUI opens, and you just click the items you want to store or take.
It has a build in cap too so you could change the amount able to be stored if you wanted to at any point.
code_language.skript:
function giveTest(p: player, item: item):
    give {_p} {_item}
    remove "%{_item}%" from {inventory.%{_p}%::*}
    chestStore({_p})

function takeTest(p: player, item: item):
    remove {_item} from {_p}'s inventory
    add "%{_item}%" to {inventory.%{_p}%::*}
    chestStore({_p})  
   
function chestStore(p: player):
    open virtual chest inventory with size 1 named "&dItem Storer" to {_p}
    wait 1 tick
    format gui slot 0 of {_p} with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    format gui slot 1 of {_p} with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    format gui slot 2 of {_p} with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    loop {inventory.%{_p}%::*}:
        set {_slot} to loop-index
        set {_slot} to {_slot} + 4
        set {_item} to "%loop-value%" parsed as item
        format gui slot {_slot} of {_p} with {_item} to run function giveTest({_p}, {_item})
    format gui slot 6 of {_p} with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    format gui slot 7 of {_p} with magenta stained glass pane named "&dStore your items in the empty slots!" to close
    format gui slot 8 of {_p} with magenta stained glass pane named "&dStore your items in the empty slots!" to close
   
on right click on chest:
    cancel event
    set {_p} to player
    chestStore({_p})
     
on inventory click:
    if name of player's current inventory contains "&dItem Storer":
        if "%clicked slot type%" is not equal to "container":
            cancel event
            set {_item} to "%item%" parsed as item
            set {_p} to player
            if size of {inventory.%{_p}%::*} is 3:
                send "Chest full"
                stop
            takeTest({_p}, {_item})
The wonky bit:
because the clicked items refresh the GUI on use so you can see your items moving, the math resets and doesnt set slots properly.
essentially you only see them being added to one slot but that slot contains all of the items. clicking on them will return them just fine,
but only in sequential order.
The only way I found to fix this is to not have it re-run the chest function to refresh your view. So it stores in separate
slots, but you don't see it. it looks like your items disappear and when you reopen then you see them.

so like partial helpful, but my head is sore from beating it against the deskXD
 
So, I get an error:
code_language.skript:
[21:05:30 ERROR]: Can't understand this condition/effect: format slot {_slot} of {_p} with {_item} to run function giveTest({_p}, {_item}) (scripts.sk, line 21: format slot {_slot} of {_p} with {_item} to run function giveTest({_p}, {_item})')
Thanks :emoji_slight_smile:
[doublepost=1501214979,1501214925][/doublepost]Also, when I click on an item, it says CHEST FULL even though 3 spaces are empty. Thanks :emoji_slight_smile:
 
So, I get an error:
code_language.skript:
[21:05:30 ERROR]: Can't understand this condition/effect: format slot {_slot} of {_p} with {_item} to run function giveTest({_p}, {_item}) (scripts.sk, line 21: format slot {_slot} of {_p} with {_item} to run function giveTest({_p}, {_item})')
Thanks :emoji_slight_smile:
[doublepost=1501214979,1501214925][/doublepost]Also, when I click on an item, it says CHEST FULL even though 3 spaces are empty. Thanks :emoji_slight_smile:
that needs to be "format gui slot" with the way I have it set up you may also have to fix it's indentation if you haven't. I noticed i had that line a bit off on spacing in my post.
Try deleting the variable to give yourself a fresh slate that should fix the second problem
code_language.skript:
command /test:
    trigger:
        delete {inventory.%player%::*}
        send "deleted"
[doublepost=1501253123][/doublepost]That is TuSKe, in case I hadn't mentioned it. regular format slot is very buggy
 
Ah. Thanks. I replaced the format gui slot earlier with set slot because it showed an error, so I'll get TuSKe. Thanks. One thing though: I don't understand what you mean about the 2nd one. If you could explain a little more in detail, that would be great. Thanks :emoji_slight_smile:
 
Ah. Thanks. I replaced the format gui slot earlier with set slot because it showed an error, so I'll get TuSKe. Thanks. One thing though: I don't understand what you mean about the 2nd one. If you could explain a little more in detail, that would be great. Thanks :emoji_slight_smile:
That command deletes the variable that stores your items. So if you delete it, when it checks the size of the list to stop you from going over three it will see the value as 0 and not stop you from storing.
 
I see, but how would I incorporate that into my current code?
 
I see, but how would I incorporate that into my current code?
it was just a possible fix for the variable if somehow you got it set to 3 without any items being stored. it's not meant to be incorporated. you had said it said chest full without any items being stored so that was just a potential fix for that
 
So, now when I click the item, nothing happens. Could you paste the whole code out that works for you because I am kind of lost and I really need this to work xD And if you can include the needed addons, that would be great! Thanks man :emoji_slight_smile:
[doublepost=1502050936,1501476936][/doublepost]And when and if you do it, can you make sure that it works on your end? Thanks :emoji_slight_smile:
[doublepost=1502125007][/doublepost]or can someone else do it if the member above can't? Thanks
 
So, now when I click the item, nothing happens. Could you paste the whole code out that works for you because I am kind of lost and I really need this to work xD And if you can include the needed addons, that would be great! Thanks man :emoji_slight_smile:
[doublepost=1502050936,1501476936][/doublepost]And when and if you do it, can you make sure that it works on your end? Thanks :emoji_slight_smile:
[doublepost=1502125007][/doublepost]or can someone else do it if the member above can't? Thanks
Yeah dude, I did my best to help and get you in the right direction, but I just don't have time to iron out all it's kinks with my current projects. If you don't get any more ideas here I'd defs recommend setting it up in the requests section. you never know if someone might have the time to get it all sorted for you:emoji_slight_smile: good luck!
 
Status
Not open for further replies.