Random Chest
By
thedadminCreated: 2016/12/14 10:23:43 UTC-08:00 (8 years and 10 days ago)
Edited: 2016/12/14 10:24:03 UTC-08:00 (8 years and 10 days ago)
Likes: 0
Denizen Version: 1.0.1-SNAPSHOT (build1630) Core Version 1.15 (Build 77)
Script Version: 1.0
Description:
This script is designed for those running RPG style servers. There are no dependencies for this script outside of maybe Vault if you wish to have chests filled with in game currency.
When a player clicks on a chest that has been specified as a "random chest" by the script, it will be populated with items.
The script generates a random number between 1 and 100, then using that number, determines what to populate the chest with. This script can be copied and editted as many times as you need.
Once a player opens a chest, it will not populate for that player again, but if a new player opens that same chest then the chest will populate for that player.
The practical use for this is of course having dungeons that you don't need to replace the items in when a player loots them and to also allow for random chance to come into play.
Download script |
View raw script######################################################################
#Random Chest Instructions: Simply insert this script into your #
#scripts folder. Once inserted, you can easily copy and paste, then #
#edit the appropriate sections. #
#The areas you need to edit are noted below. #
#To Make a new chest: Copy everything below "on player right clicks #
#chest:" and paste it before the last "- queue clear". #
#To add items, simply add extra "- inventory add" commands or you can#
#also add cash using the "money" command. You can add as many to #
#each #
#If statement as you'd like. #
#To change the chance of each item just change the number ranges to #
#reflect your percentages. #
#Be sure to give your new chests unique flags!!! #
######################################################################
randomchest:
type: world
events:
on player right clicks chest:
- if <context.location.simple> == -2560,61,-2932,world && <player.has_flag[testchest].not> {
- define contents <util.random.int[1].to[100]>
- wait .1s
}
- if <def[contents]> < 10 {
- inventory add d:<player.open_inventory> && <player.has_flag[testchest].not> o:i@386
- flag player testchest
- queue clear
}
- if <def[contents]> >= 10 && <def[contents]> && <player.has_flag[testchest].not> < 20 {
- inventory add d:<player.open_inventory> o:i@sand[quantity=32]
- flag player testchest
- queue clear
}
- if <def[contents]> >= 20 && <def[contents]> && <player.has_flag[testchest].not> < 30 {
- inventory add d:<player.open_inventory> o:i@gold_ingot[quantity=32]
- flag player testchest
- queue clear
}
- if <def[contents]> >= 30 && <def[contents]> && <player.has_flag[testchest].not> < 40 {
- inventory add d:<player.open_inventory> o:i@iron_ingot[quantity=32]
- flag player testchest
- queue clear
}
- if <def[contents]> >= 40 && <def[contents]> && <player.has_flag[testchest].not> < 50 {
- inventory add d:<player.open_inventory> o:i@stick[quantity=32]
- flag player testchest
- queue clear
}
- if <def[contents]> >= 50 && <def[contents]> < 60 && <player.has_flag[testchest].not> {
- inventory add d:<player.open_inventory> o:i@redstone[quantity=32]
- flag player testchest
- queue clear
}
- if <def[contents]> >= 60 && <def[contents]> < 70 && <player.has_flag[testchest].not> {
- inventory add d:<player.open_inventory> o:i@stone[quantity=32]
- flag player testchest
- queue clear
}
- if <def[contents]> >= 70 && <def[contents]> < 80 && <player.has_flag[testchest].not> {
- inventory add d:<player.open_inventory> o:i@diamond[quantity=32]
- flag player testchest
- queue clear
}
- if <def[contents]> >= 80 && <def[contents]> < 90 && <player.has_flag[testchest].not> {
- inventory add d:<player.open_inventory> o:i@dirt[quantity=32]
- flag player testchest
- queue clear
}
- if <def[contents]> >= 90 && <def[contents]> < 101 && <player.has_flag[testchest].not> {
- inventory add d:<player.open_inventory> o:i@planks[quantity=32]
- flag player testchest
- queue clear
}
- queue clear
View History