Jump to content

Item Limit


Rat3440

Recommended Posts

So I made a skript that spawns items at a specific place but it adds up too much. I can't figure out how to add a limiter to the skript. I need it to start generating again after it has been collected.
This is some of my code:


every 10 ticks:
if {summon} is "enabled":
drop {boost::gen} of sand at location(27.5, -57, 2.5, world "testworld") without velocity
drop {boost::gen} of stone at location(17.5, -55, -32.5, world "testworld") without velocity
drop {boost::gen} of iron ingots at location(-37.5, -47, -20.5, world "testworld") without velocity

(this is for 3 dif gens)

Any help would be great

Link to comment
Share on other sites

i cant really understand you want to spawn it every 10 tick but make it so if there is 3 of them spawned it well spawn another one? also this is better
 

every 10 ticks:
 {summon} is enabled
 drop {boost::gen} of sand at location(27.5, -57, 2.5, world "testworld") without velocity
 drop {boost::gen} of stone at location(17.5, -55, -32.5, world "testworld") without velocity
 drop {boost::gen} of iron ingots at location(-37.5, -47, -20.5, world "testworld") without velocity

so you want there to be only 1 {boost::gen} at 1 loaction at all time?

Edited by gabinun
Link to comment
Share on other sites

Basically it is a "gen" that spawns items at those cords. The boost variable is for a different skript that lets me change the output of the gens but, the gens add up way too much before my item clear. So I was wondering if I can limit how much can be in the stack before it stops spawning.

Link to comment
Share on other sites

21 hours ago, Rat3440 said:

Basically it is a "gen" that spawns items at those cords. The boost variable is for a different skript that lets me change the output of the gens but, the gens add up way too much before my item clear. So I was wondering if I can limit how much can be in the stack before it stops spawning.

 

options:
    prefix: replace with your prefix

function checkGenLimit(loc: location, type: string) :: boolean:
    loop dropped items in radius 2 around {_loc}:
        set {_drop} to "%loop-entity%"
        if {_drop} contains {_type}:
            set {_split::*} to split {_drop} by " "
            set {_amount} to {_split::2} parsed as integer
            add 1 to {_i}
            if {_amount} is set:
                add {_amount} - 1 to {_i}
    if {_i} >= {genLimit::%{_type}%}:
        return true

command /genlimit [<string>] [<integer>]:
    trigger:
        if player has permission "gen.limit":
            if arg 1 is set:
                if arg 2 is set:
                    if arg 2 >= 1:
                        set {genLimit::%arg 1%} to arg 2
                        send "{@prefix} Set the &e%arg 1% &fgen limit to &e%arg 2%&f!"
                    else:
                        send "{@prefix} Limit must be greater than 0!"
                else:
                    send "{@prefix} Enter the number limit!"
            else:
                send "{@prefix} Enter the gen you want to set a limit for!"

every 10 ticks:
    if {summon} is "enabled":
        set {_check} to checkGenLimit(location(27.5, -57, 2.5, world "testworld"), "sand")
        if {_check} isn't true:
            drop {boost::gen} of sand at location(27.5, -57, 2.5, world "testworld") without velocity
        set {_check} to checkGenLimit(location(17.5, -55, -32.5, world "testworld"), "stone")
        if {_check} isn't true:
            drop {boost::gen} of stone at location(17.5, -55, -32.5, world "testworld") without velocity
        set {_check} to checkGenLimit(location(-37.5, -47, -20.5, world "testworld"), "iron ingot")
        if {_check} isn't true:
            drop {boost::gen} of iron ingots at location(-37.5, -47, -20.5, world "testworld") without velocity

(Not tested)

Edited by Dead07

Discord: dead_is4

Anime Enthusiast!


Solo Leveling GIF - Solo Leveling - Discover & Share GIFs

Link to comment
Share on other sites

3 hours ago, Dead07 said:

 

options:
    prefix: replace with your prefix

function checkGenLimit(loc: location, type: string) :: boolean:
    loop dropped items in radius 2 around {_loc}:
        set {_drop} to "%loop-entity%"
        if {_drop} contains {_type}:
            set {_split::*} to split {_drop} by " "
            set {_amount} to {_split::2} parsed as integer
            add 1 to {_i}
            if {_amount} is set:
                add {_amount} - 1 to {_i}
    if {_i} >= {genLimit::%{_type}%}:
        return true

command /genlimit [<string>] [<integer>]:
    trigger:
        if player has permission "gen.limit":
            if arg 1 is set:
                if arg 2 is set:
                    if arg 2 >= 1:
                        set {genLimit::%arg 1%} to arg 2
                        send "{@prefix} Set the &e%arg 1% &fgen limit to &e%arg 2%&f!"
                    else:
                        send "{@prefix} Limit must be greater than 0!"
                else:
                    send "{@prefix} Enter the number limit!"
            else:
                send "{@prefix} Enter the gen you want to set a limit for!"

every 10 ticks:
    if {summon} is "enabled":
        set {_check} to checkGenLimit(location(27.5, -57, 2.5, world "testworld"), "sand")
        if {_check} isn't true:
            drop {boost::gen} of sand at location(27.5, -57, 2.5, world "testworld") without velocity
        set {_check} to checkGenLimit(location(17.5, -55, -32.5, world "testworld"), "stone")
        if {_check} isn't true:
            drop {boost::gen} of stone at location(17.5, -55, -32.5, world "testworld") without velocity
        set {_check} to checkGenLimit(location(-37.5, -47, -20.5, world "testworld"), "iron ingot")
        if {_check} isn't true:
            drop {boost::gen} of iron ingots at location(-37.5, -47, -20.5, world "testworld") without velocity

(Not tested)

Excuse me as I am new to skript but i pasted this in and it gave me a few errors on the messages so I just got rid of the {@prefix} but now when I do it and run the command nothing seems to be happening. I'm not sure if i'm doing something wrong some more help would be great. I also still don't understand functions so this is difficult for me.

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