That should only happen if the variable before the .clamp() is not a number.
Speaking which, the first line I recommended to change above was the wrong one. Instead of the "change" line it should have been this one:
current = State.getVar(this.args[2]),
and change it to:
current = State.variables[this.args[2]].clamp(0, maximum),
However, if "this.args[2]" isn't a valid story variable name, then you'll get that "undefined" error.
You can do something like this if you want to make sure that the variable exists:
if (hasOwnProperty.call(State.variables, this.args[2])) {
current = State.variables[this.args[2]].clamp(0, maximum);
} else {
throw new Error("Invalid 'current' variable name of '" + this.args[2] + "'.");
}
That will only set "current" variable if the variable name passed as a parameter is valid, otherwise it will throw an error. You can use something like that to check the other parameters as well.
Hopefully that should do the trick.