On eat of specific food - drop random item from set list

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

bobsilowski

Member
Apr 20, 2021
12
1
3
22
Hi guys, I am trying to work out two things.

1. How to specify an on eat of COOKIE
2.
How to make it drop a random item from a list of specific items (not all blocks)
 
Haven't tested this so let me know if it doesn't work.

Code:
on load:
    add diamond_block to {blocklist::*}
    add enchantment_table to {blocklist::*}
    add anyblock to {blocklist::*}

on consume:
    if event-item is cookie:
        set {drop} to random element out of {blocklist::*}
        drop 1 {drop} at player's location
    else:
        stop

Sources
 
Last edited:
Haven't tested this so let me know if it doesn't work.

Code:
on load:
    add diamond_block to {blocklist::*}
    add enchantment_table to {blocklist::*}
    add anyblock to {blocklist::*}

on consume:
    if event-item is cookie:
        set {drop} to random element out of {blocklist::*}
        drop 1 {drop} at player's location

Sources

Thank you so much! I will check the code out later today!
 
  • Like
Reactions: Mashhhyyy
hey! you mean something like this?

Code:
on load:
    add diamond_block to {blocklist::*}
    add enchantment_table to {blocklist::*}
    add anyblock to {blocklist::*}
 
on consume:
    if event-item is cookie:
        set {drop} to random element out of {blocklist::*}
        chance of 25%:
            drop 1 {drop} at player's location
        else:
            stop
    else:
        stop

In this case, when the player eats a cookie, there will be a 1/4 (25%) chance of it dropping an item from the list.

Hope this helps :emoji_slight_smile:
 
  • Like
Reactions: bobsilowski
hey! you mean something like this?

Code:
on load:
    add diamond_block to {blocklist::*}
    add enchantment_table to {blocklist::*}
    add anyblock to {blocklist::*}
 
on consume:
    if event-item is cookie:
        set {drop} to random element out of {blocklist::*}
        chance of 25%:
            drop 1 {drop} at player's location
        else:
            stop
    else:
        stop

In this case, when the player eats a cookie, there will be a 1/4 (25%) chance of it dropping an item from the list.

Hope this helps :emoji_slight_smile:
G E N I U S
 
The
Code:
else:
    stop
lines aren't needed at all, so delete those. Also, you'd need to do
Code:
drop 1 of {drop}
since Skript doesn't understand just putting an integer and a variable right next to each other. I'm not entirely sure item aliases with underscores work, so...

Code:
on load:
    set {blocklist::*} to diamond block, enchantment table, sponge
    set {blocklist::*} to {blocklist::*}, diamond and coal # Best form of doing this without hurting parse time
 
on consume of cookie:
    chance of 25%:
        drop 1 of (random element out of {blocklist::*}) at player's location # No need to set a variable

You could also do
Code:
drop 1 of {blocklist::%random integer between 1 and (size of {blocklist::*}%} at player's location
although I'm not sure if that would work.
 
Woah I didn't even know you could do those things! That's actually gonna make my life so much easier!
 
Status
Not open for further replies.