Mirreski / Skript

Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
http://njol.ch/projects/skript
7 stars 2 forks source link

enchant player's tool by {_enchantment} of {_strenght} #20

Closed xNorbig closed 9 years ago

xNorbig commented 9 years ago

enchant player's tool by {_enchantment} of {_strenght} doesn't works

Mirreski commented 9 years ago

You should use "with" instead of "by" but well yes that doesn't work.

Syntax: enchant %~item stack% with %enchantment types%

Because enchantment type is a type and not a expression it only takes literals and no variables or expressions. Which was actually not a super good idea by njol when he could have made it to a expression rather than type as then you could have used variables or expressions.

But there's actually a way for making this work because of the parse expression.

set {_strength} to 2
set {_enchant} to sharpness

set {_realEnchant} to "%{_enchant}% %{_strength}%" parsed as enchantment type

if {_realEnchant} is set:
    enchant player's tool with {_realEnchant}