color switch
val colors = [
"light_blue",
"red",
"lime",
"yellow",
"orange",
"purple",
"pink",
"blue",
"green"
]
val floor = "light_blue_wool,red_wool,lime_wool,yellow_wool,orange_wool,purple_wool,pink_wool,blue_wool,green_wool"
var gameRunning = false
var roundDelay = 3
var round = 0
var pvpOn = false
var pvpIntroduced = false
function colorName(name) {
when (name) {
"light_blue" -> { return "LIGHT BLUE" }
"red" -> { return "RED" }
"lime" -> { return "LIME" }
"yellow" -> { return "YELLOW" }
"orange" -> { return "ORANGE" }
"purple" -> { return "PURPLE" }
"pink" -> { return "PINK" }
"blue" -> { return "BLUE" }
"green" -> { return "GREEN" }
else -> { return "WHITE" }
}
}
function colorCode(name) {
when (name) {
"light_blue" -> { return "&b" }
"red" -> { return "&c" }
"lime" -> { return "&a" }
"yellow" -> { return "&e" }
"orange" -> { return "&6" }
"purple" -> { return "&5" }
"pink" -> { return "&d" }
"blue" -> { return "&9" }
"green" -> { return "&2" }
else -> { return "&f" }
}
}
// when its round 10 pvp enables while the full floor is out
function syncPvp(floorFull) {
if (round < 10) {
return
}
if (pvpOn == floorFull) {
return
}
// only do the pvp announcement one time
if (!pvpIntroduced) {
pvpIntroduced = true
for (player in Katton.players.all()) {
player.sendMessage("PvP is &aON &fwhile the full color floor is out, and &cOFF &fonce it disappears to the safe color, be careful!")
}
}
pvpOn = floorFull
Katton.makeAdminExecuteCommand("pvp")
}
@Katton.command(name = "colorswitch", permission = "admin")
function startColorSwitch(sender, args) {
if (gameRunning) {
sender.sendMessage("&ecolor switch is already running")
return
}
for (player in Katton.players.all()) {
player.sendTitle("&x&E&C&8&C&8&Ccol&x&F&F&C&5&8&Bors&x&F&F&F&F&9&Ewit&x&C&D&F&F&9&Cch &x&9&A&F&F&9&Ais &x&9&7&C&F&F&5sta&x&A&3&9&A&F&Frti&x&E&E&A&0&F&Fng!", "")
}
gameRunning = true
roundDelay = 3
round = 0
pvpOn = false
Katton.makeAdminExecuteCommand("pvp false")
pvpIntroduced = false
Katton.makeAdminExecuteCommand("//pos1 -83,88,60")
Katton.makeAdminExecuteCommand("//pos2 -62,88,82")
Katton.makeAdminExecuteCommand("//set " + floor)
round = round + 1
syncPvp(true)
Katton.after(3.seconds) {
nextRound()
}
}
function nextRound() {
if (!gameRunning) {
return
}
val chosen = Katton.pick(colors)
val chosenStr = colorName(chosen)
val code = colorCode(chosen)
for (player in Katton.players.all()) {
player.sendTitle(code + chosenStr, code + roundDelay + " second(s)!")
}
Katton.after(roundDelay.seconds) {
if (!gameRunning) {
return
}
Katton.makeAdminExecuteCommand("//replace !" + chosen + "_wool air")
syncPvp(false)
Katton.after(2.seconds) {
if (!gameRunning) {
return
}
Katton.makeAdminExecuteCommand("//set " + floor)
round = round + 1
syncPvp(true)
roundDelay = Math.max(1, roundDelay - 0.25)
Katton.after(1.seconds) {
nextRound()
}
}
}
}
@Katton.command(name = "stopcolorswitch", permission = "admin")
function stopColorSwitch(sender, args) {
gameRunning = false
if (pvpOn) {
Katton.makeAdminExecuteCommand("pvp")
pvpOn = false
}
sender.sendMessage("&ccolor switch stopped")
}
try it yourself
edit the code to change the location of where the game starts
Katton.makeAdminExecuteCommand("//pos1 -83,88,60")
Katton.makeAdminExecuteCommand("//pos2 -62,88,82")
/katton import
/katton run colorswitch
wait a bit then do /katton run stopcolorswitch once you're ready to end it