Solved Apple Drop

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

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

Mashhhyyy

Member
Mar 8, 2021
13
1
3
19
USA
Hello, I am having trouble with my apple drop skript...I'm trying to make it so when you break a leaf block with shears, it will have a custom chance to drop an apple. but at the moment it's just dropping out of every leaf block I break even though the appleRate is set to 0.1% PLEASE HELP!

Code:
variables:
    {noLeaves} = 1
    {dropApples} = 1
    {appleRate) = 0.1%

on break of leaves:
    if {noLeaves} is 1:
        if player's held item is shears:
            cancel event
            set the event-block to air
            if {dropApples} is 1:
                if {appleRate} is not 0:
                    chance of {appleRate}:
                        drop 1 apple at event-block
            else:
                stop
 
Hello, I am having trouble with my apple drop skript...I'm trying to make it so when you break a leaf block with shears, it will have a custom chance to drop an apple. but at the moment it's just dropping out of every leaf block I break even though the appleRate is set to 0.1% PLEASE HELP!

Code:
variables:
    {noLeaves} = 1
    {dropApples} = 1
    {appleRate) = 0.1%

on break of leaves:
    if {noLeaves} is 1:
        if player's held item is shears:
            cancel event
            set the event-block to air
            if {dropApples} is 1:
                if {appleRate} is not 0:
                    chance of {appleRate}:
                        drop 1 apple at event-block
            else:
                stop
Just out of curiosity, have you tried putting the chance without the variable?

Like
code_language.skript:
chance of 0.1%:

Instead of

code_language.skript:
chance of {variable}:
[doublepost=1616127926,1616127358][/doublepost]Nvm, I misread the code. In that case, you would have to make the variable as a number. And then do this:

code_language.skript:
variable:
   {chance} = 0.1

on break of leaves:
   chance of {chance}%:
       #do stuff
 
Hmm this seems to be working better but I set the chance to get apples to 0.1 and I still managed to get 10 apples from one tree...

Any idea as to what could be causing this??

Code:
variables:
    {appleRate} = 0.1

on break of leaves:
    if player's held item is shears:
        chance of {appleRate}:
            drop 1 apple at event-block
    else:
        set event-block to air
        cancel event

Also my bad I should've simplified my code so it was a little more readable lol
 
Hmm this seems to be working better but I set the chance to get apples to 0.1 and I still managed to get 10 apples from one tree...

Any idea as to what could be causing this??

Code:
variables:
    {appleRate} = 0.1

on break of leaves:
    if player's held item is shears:
        chance of {appleRate}:
            drop 1 apple at event-block
    else:
        set event-block to air
        cancel event

Also my bad I should've simplified my code so it was a little more readable lol
This was answered by ShaneBee to me a long time ago, so I will write you the same code(or similar) that he wrote me.

In these cases, I recommend using this method.

code_language.skript:
set {_random} to random integer between 0 and 1000
if {_random} is 1:
    drop 1 apple at event-block
 
Status
Not open for further replies.