SwitchCase - Switch Return (Expression) — SkBee
Addon: SkBee · Category: Expression · Since: 3.8.0
Syntax
(switch return|return switch) %object%Description
Switch an object and have it return a value.
Examples
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 {_i} to switch return event-block:
case stone -> "Stoney Stone"
case dirt -> "Dirty Dirt"
case grass block -> "Grassy Grass"
default:
if gamemode of player = creative:
return "&c%type of switched object%"
else:
return "&a%type of switched object%"
send "Broken: %{_i}%" to player