What does it do?
It creates easy aliases for your commands. For example, if you need to create a weather script and want to match many words to one type of weather, this function will return:
- the word to send to the player, for example, if you type sun it'll send sunny.
- the weather type, in this case, clear.
Snippet
Usage
The usage is pretty simple:
You can keep going forever with the 'words to match'. Just add other commas..
[ ] are not needed.
If you didn't get it, here it is line by line:
Example:
As you can see, instead of a huge code, I just had the work to write down the aliases basically.
It creates easy aliases for your commands. For example, if you need to create a weather script and want to match many words to one type of weather, this function will return:
- the word to send to the player, for example, if you type sun it'll send sunny.
- the weather type, in this case, clear.
Snippet
code_language.skript:
function alias(t: text, a: text) :: objects:
set {_t::*} to split {_t} at "|"
if {_t::*} is not set:
set {_t::*} to {_t}
loop {_t::*}:
set {_s::*} to split loop-value at ","
loop {_s::*}:
loop-value-2 = {_a}
return {_s::1} and {_s::2}
stop loop
return false
Usage
The usage is pretty simple:
code_language.skript:
set {_aliases::*} alias("[type you want to parse],[what to send],[word to match],[word to match]|[another type to be parsed],[what to send],[word to match],[word to match], "word to check""
# {_aliases::1} = object you want to parse
# {_aliases::2} = text you want to send to the player
[ ] are not needed.
If you didn't get it, here it is line by line:
code_language.skript:
alias("
[type to be parsed] - e.g. "creative"
[word to send] - e.g. "fly 'n' duplication mode"
[word to match] - e.g. "1"
[word to match] - e.g. "fly plus hacks"
| - another word to match
[type to be parsed] - e.g. "survival"
[word to send] - e.g. "just die mode"
[word to match] - e.g. "0"
[word to match] - e.g. "not creative"
")
Example:
code_language.skript:
command /weather [<text>]:
aliases: clima, tempo, time
permission: e.weather
permission message: {@P}
trigger:
set {_weather::*} to alias("sunny,ensolarado,clear,limpo,claro,clear|rain,chuvoso,chuva,rainy|thunder,tespestade,storm,tempest,raios", "%arg 1%")
if {_weather::*} is false: # False means that it didn't match anything.
send "&3ⒸⓂⒹ &7That weather &cdoes not exist&7."
else:
set weather to {_weather::1} parsed as weather # Parses the first returned value
send "&3ⒸⓂⒹ &7The weather has been changed to &a%{_weather::2}%&7." # Sends the second value
Hope you enjoy!