When i tried accessing %arg 0% Skript throwed ArrayOutOfBoundsException
(I expected that %arg 0% will give me command alias used by player to execute the command)
Here's the whole error:
#!#!
#!#! [Skript] Severe Error:
#!#! Could not load MyScript.sk
#!#!
#!#! Something went horribly wrong with Skript.
#!#! This issue is NOT your fault! You probably can't fix it yourself, either.
#!#! You should report it at https://github.com/SkriptLang/Skript/issues. Please copy paste this report there (or use paste service).
#!#! This ensures that your issue is noticed and will be fixed as soon as possible.
#!#!
#!#! Stack trace:
#!#! java.lang.ArrayIndexOutOfBoundsException: -1
#!#! at java.util.ArrayList.elementData(Unknown Source)
#!#! at java.util.ArrayList.get(Unknown Source)
#!#! at ch.njol.skript.expressions.ExprArgument.init(ExprArgument.java:96)
#!#! at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:253)
#!#! at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:180)
#!#! at ch.njol.skript.lang.SkriptParser.parseSingleExpr(SkriptParser.java:323)
#!#! at ch.njol.skript.lang.SkriptParser.parseExpression(SkriptParser.java:625)
#!#! at ch.njol.skript.lang.VariableString.newInstance(VariableString.java:241)
#!#! at ch.njol.skript.lang.VariableString.newInstance(VariableString.java:145)
#!#! at ch.njol.skript.lang.SkriptParser.parseSingleExpr(SkriptParser.java:491)
#!#! at ch.njol.skript.lang.SkriptParser.parseExpression(SkriptParser.java:812)
#!#! at ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1530)
#!#! at ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1460)
#!#! at ch.njol.skript.lang.SkriptParser.parse_i(SkriptParser.java:1487)
#!#! at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:225)
#!#! at ch.njol.skript.lang.SkriptParser.parse(SkriptParser.java:180)
#!#! at ch.njol.skript.lang.Statement.parse(Statement.java:59)
#!#! at ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:972)
#!#! at ch.njol.skript.lang.TriggerSection.<init>(TriggerSection.java:54)
#!#! at ch.njol.skript.lang.Conditional$1.<init>(Conditional.java:76)
#!#! at ch.njol.skript.lang.Conditional.loadElseClause(Conditional.java:76)
#!#! at ch.njol.skript.lang.Conditional.loadElseClause(Conditional.java:70)
#!#! at ch.njol.skript.ScriptLoader.loadItems(ScriptLoader.java:1032)
#!#! at ch.njol.skript.command.Commands.loadCommand(Commands.java:496)
#!#! at ch.njol.skript.ScriptLoader.loadScript(ScriptLoader.java:623)
#!#! at ch.njol.skript.ScriptLoader.lambda$1(ScriptLoader.java:391)
#!#! at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:403)
#!#! at ch.njol.skript.ScriptLoader.lambda$0(ScriptLoader.java:333)
#!#! at ch.njol.skript.ScriptLoader.loadScripts(ScriptLoader.java:363)
#!#! at ch.njol.skript.Skript.reloadScripts(Skript.java:771)
#!#! at ch.njol.skript.SkriptCommand.onCommand(SkriptCommand.java:158)
#!#! at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
#!#! at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
#!#! at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648)
#!#! at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:634)
#!#! at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:444)
#!#! at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:407)
#!#! at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679)
#!#! at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577)
#!#! at java.lang.Thread.run(Unknown Source)
#!#!
#!#! Version Information:
#!#! Skript: 2.2-dev37c (latest)
#!#! Bukkit: 1.12.2-R0.1-SNAPSHOT
#!#! Minecraft: 1.12.2
#!#! Java: 1.8.0_181 (Java HotSpot(TM) 64-Bit Server VM 25.181-b13)
#!#! OS: Windows 10 amd64 10.0
#!#!
#!#! Server platform: Spigot
#!#!
#!#! Current node: send "Usage: /%arg 0% start|stop" (MyScript.sk, line 99)
#!#! Current item: null
#!#!
#!#! Thread: Server thread
#!#!
#!#! Language: english
#!#! Link parse mode: DISABLED
#!#!
#!#! End of Error.
#!#!
Should we make this show an error or actually return the alias? The former I suppose? Also is there already a way to get the alias?
I think there is no other way, but i might be wrong
Anyway, it would be better if %arg 0% will return alias
There is no way to get the exact command they used in a normal command event; as far as I know you can only do so in an on command event. It'd be nice to see this added but I don't think it should be arg-0, it should just be %command% like in an on command event.
arg 0 doesn't make sense and it should show an error, the argument expression uses regex for the number input: https://skriptlang.github.io/Skript/expressions.html#ExprArgument
So ^[1-9]\d*$ can be used or we can make it using literal expressions (%*number%) and give warning in parse time for numbers below 1. Also this would be better for docs.
Like @TheBentoBox said it should be %command%.
while we're at it how about %arguments% too
That would be great as well, partly just for seeing the number of arguments entered because there's no way to do so currently.
Has this been added? I'm running version 2.4-beta5 and %arg 0% or %command% didn't work.
Most helpful comment
arg 0 doesn't make sense and it should show an error, the argument expression uses regex for the number input: https://skriptlang.github.io/Skript/expressions.html#ExprArgument
So
^[1-9]\d*$can be used or we can make it using literal expressions (%*number%) and give warning in parse time for numbers below 1. Also this would be better for docs.Like @TheBentoBox said it should be
%command%.