Jump to content

Need Help with creating an Item Compacting Skript


Recommended Posts

Quote

 

every 5 minutes:
    loop all blocks:
        if loop-block is a chest or trapped chest:
            set {_chest} to loop-block

            if inventory of {_chest} contains white dye:
                set {_ca} to amount of white dye in inventory of {_chest}
                loop 108 times:
                    if {_ca} is greater than or equal to 32:
                        add 1 white dye named "&fCompacted White Dye" to inventory of {_chest}
                        remove 32 white dye from {_chest}'s inventory
                    else:
                        stop loop

 

This is what I have, however, it does not work and I am not sure as to why. My plan is that every 5 minutes, if a chest has at least 32 white dye, it would compact it into 1 compacted white dye. And if the chest were to have way more than 32 white dye, let's say 358, it would create 11 compacted white dye, and then leave the left over white dye in the chest.

Does anyone know what I need to change in order to make it work like I want it to?

Link to comment
Share on other sites

There is no such thing as loop all blocks. And even if that was a thing, that would be looping millions of blocks in loaded chunks. You could loop all players then loop all blocks in a certain radius around that player. 

Discord - tarna256

In-game name - _Tarna_

Website - https://tarna.dev
Paste Site: https://paste.tarna.dev

---------------------------------------------------------

[VIP] - 7/27/2020

Community Support - 7/8/20 - 11/3/20

Helper  - 11/3/20 - 2/21/21

Moderator - 2/21/21 - 5/17/21

❤️ - 5/17/21 - 12/20/22

Moderator - 12/20/22 - now

---------------------------------------------------------

image.png.70849a9b84e0347ce107b8e3eaee312c.pngimage.png.2111009afbd8bef10966ba9ede35a199.png

Link to comment
Share on other sites

Quote

 

every 5 minutes:
    loop all players:
        loop blocks in radius 50 of loop-player:
            if loop-block is a chest or trapped chest:
                set {_chest} to loop-block

                if inventory of {_chest} contains white dye:
                    set {_ca} to amount of white dye in inventory of {_chest}
                    loop 108 times:
                        if {_ca} is greater than or equal to 32:
                            add 1 white dye named "&fCompacted White Dye" to inventory of {_chest}
                            remove 32 white dye from {_chest}'s inventory
                        else:
                            stop loop

 

@_Tarna_ so something like this should work, or is there something I am missing?

Edited by Mxnuscript
Link to comment
Share on other sites

7 minutes ago, Mxnuscript said:

@_Tarna_ so something like this should work, or is there something I am missing?

50 is still a lot of blocks to loop. that would still be looping hundreds of thousands of blocks depending on how many players are on. It would probably be better to add the location to a list variable in the on join event and loop that variable. 

Discord - tarna256

In-game name - _Tarna_

Website - https://tarna.dev
Paste Site: https://paste.tarna.dev

---------------------------------------------------------

[VIP] - 7/27/2020

Community Support - 7/8/20 - 11/3/20

Helper  - 11/3/20 - 2/21/21

Moderator - 2/21/21 - 5/17/21

❤️ - 5/17/21 - 12/20/22

Moderator - 12/20/22 - now

---------------------------------------------------------

image.png.70849a9b84e0347ce107b8e3eaee312c.pngimage.png.2111009afbd8bef10966ba9ede35a199.png

Link to comment
Share on other sites

 

Quote

It would probably be better to add the location to a list variable in the on join event and loop that variable. 

@_Tarna_ Oh okay, and how would I go about doing that? Sorry I am quite new to skript. Just a quick example would be great.

Edited by Mxnuscript
Link to comment
Share on other sites

31 minutes ago, Mxnuscript said:

 

@_Tarna_ Oh okay, and how would I go about doing that? Sorry I am quite new to skript. Just a quick example would be great.

on place of chest:
	add event-block's location to {chests::*}

then do loop {chests::*} to loop all the chests you have placed. 

Discord - tarna256

In-game name - _Tarna_

Website - https://tarna.dev
Paste Site: https://paste.tarna.dev

---------------------------------------------------------

[VIP] - 7/27/2020

Community Support - 7/8/20 - 11/3/20

Helper  - 11/3/20 - 2/21/21

Moderator - 2/21/21 - 5/17/21

❤️ - 5/17/21 - 12/20/22

Moderator - 12/20/22 - now

---------------------------------------------------------

image.png.70849a9b84e0347ce107b8e3eaee312c.pngimage.png.2111009afbd8bef10966ba9ede35a199.png

Link to comment
Share on other sites

Quote

 

every 5 minutes:
    loop {chests::*}:
        set loop-block to {_chest}

        if inventory of {_chest} contains white dye:
            set {_ca} to amount of white dye in inventory of {_chest}
        loop 108 times:
            if {_ca} is greater than or equal to 32:
                add 1 white dye named "&fCompacted White Dye" to inventory of {_chest}
                remove 32 white dye from {_chest}'s inventory
            else:
                stop loop

 

@_Tarna_So that is what I have however, I get the error; "There's no loop that matches 'loop-block' (line #: set {_chest} to loop-block')".

Do you have any clue why this is happening or how I could fix it?

Edited by Mxnuscript
Link to comment
Share on other sites

6 hours ago, Mxnuscript said:

@_Tarna_So that is what I have however, I get the error; "There's no loop that matches 'loop-block' (line #: set {_chest} to loop-block')".

Do you have any clue why this is happening or how I could fix it?

Skript doesn't know that the variable being looped is a block.

Try changing loop-block to loop-value since you are looping through a variable and skript treats variables with loop-index and/or loop-value.

 

Edit: Also, while you set {_chest}, try parsing it as a block, inventory or something similar.

Edited by CoolProgrammer

Hello there! If you're reading this, hope you're having a wonderful day!

 

Feel free to contact me via Discord (CoolProgrammer#1920) for any help.

My DMs are always open for help.

You can also message via. forum messages for help.

1604908226_ScreenShot2021-01-28at10_32_28AM.png.2646ad6be239a9d0756a99e8e15602ab.png

Also, don't hesitate to leave a like on my post if I helped you in any way.

Link to comment
Share on other sites

@CoolProgrammer

Quote

 

every 5 minutes:
    loop {chests::*}:
        set {_chest} to loop-value-1

        if inventory of {_chest} contains white dye:
            set {_ca} to amount of white dye in inventory of {_chest}
        loop 108 times:
            if {_ca} is greater than or equal to 32:
                add 1 white dye named "&fCompacted White Dye" to inventory of {_chest}
                remove 32 white dye from {_chest}'s inventory
            else:
                stop loop

 

That is what I got, it loads into the server fine, however it has no effect. I just don't know what the problem is ugh haha

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...