SwitchCase - Case Inline (Effect) — SkBee

Addon: SkBee · Category: Effect · Since: 3.8.0

Syntax

case %objects% -> <.+>

Description

Inline version of case section where you can return/run an effect all in one line. Multiple objects are supported in cases. - **Switch Expression** = Return an object based on the case matching the switched value. - **Switch Section** = Run 1 effect based on the case matching the switched value. Default will run if all other cases fail to match. Default must go last or all cases after it will be ignored.

Examples

# As Effect
on damage of a sheep by a player:
	switch type of attacker's tool:
		case wooden sword -> give attacker yellow wool
		case stone sword -> give attacker light gray wool
		case iron sword -> give attacker gray wool
		case golden sword -> give attacker orange wool
		case diamond sword -> give attacker light blue wool
		case netherite sword -> give attacker black wool
		default -> give attacker white wool

# As Return
function getRoman(i: number) :: string:
	return switch return {_i}:
		case 1 -> "I"
		case 2 -> "II"
		case 3 -> "III"
		case 4 -> "IV"
		case 5 -> "V"
		default -> "potato"

function getName(e: entity) :: string:
	return switch return {_e}:
		case sheep -> "Mr Sheepy"
		case cow -> "Mr Cow"
		case pig -> "Señor Pig"
		default -> strict proper case "%type of {_e}%"

on break:
	set {_b} to event-block
	set {_i} to switch return {_b}:
		case stone -> 1 of stone named "Hard Stone"
		case grass block -> 1 of grass block named "Green Grass"
		case dirt -> 1 of dirt named "Dry Dirt"
		default -> 1 of {_b} named "Some Other Block"
	give player {_i}

on damage of a mob by a player:
	set {_item} to switch return type of victim:
		case sheep, cow, pig, chicken -> 1 of potato
		case zombie, drowned, husk -> 1 of rotten flesh
		case skeleton, stray, wither skeleton, bogged -> 1 of bone
		default -> 1 of stick
	give {_item} to attacker

View source