Skript: Getting a uuid of a var inside code

Created on 2 Sep 2017  路  9Comments  路  Source: SkriptLang/Skript

Screenshot from Gyazo

This bug occurs when you try to get add a number to a var with a uuid in a function

bug low

Most helpful comment

Not sure if the priority can be escalated but I can confirm that this is really annoying. Basically any time you want to pass players into a function and get their UUID you have to break it up into multiple lines because of this exact bug.

All 9 comments

:white_check_mark: confirmed with 1.12.1 PaperSpigot + Skript dev29:

Can use this: send "%{_%player's uuid%}%"
But can't use this: send "%{_%{_p}'s uuid%}%"

Confirming for dev31 / paper 1.12

set {jaygolf_temp::%{_player}'s uuid%} to {_latest_hole}

https://snag.gy/MQ9GxU.jpg

however this
set {_latest_hole} to {jaygolf_temp::%command sender's uuid%}
called in a different script works and doesnt generate errors

The problem is that the Player ClassInfo parser changes the player/offlineplayer input to a String because of the configuration option where you can change players into their String uuid's. This causes every expression with a player being used in the variable to be seen as a String, and that would then cause it to not be understood.

To fix set the option to true as it's intended and just use player in the variables. It only changes the VariableString when used in variables, not basic expressions.

https://github.com/SkriptLang/Skript/blob/96edae20d15aa8b1bb9db0fcd9e29c0be2c15cb9/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java#L820

https://github.com/SkriptLang/Skript/blob/96edae20d15aa8b1bb9db0fcd9e29c0be2c15cb9/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java#L812

Njol adding this addition: https://github.com/SkriptLang/Skript/commit/dcb94b41fa3eb22d350811be3a838dfb3d988526

Pretty much happens on every expression that uses a local variable

Still persists

Not sure if the priority can be escalated but I can confirm that this is really annoying. Basically any time you want to pass players into a function and get their UUID you have to break it up into multiple lines because of this exact bug.

This has been a bug for almost three years now. It's a really annoying bug. Is anything planned to fix this?

@Runakai1 parser bugs like this are hard to spot, hence why we didn't fix it yet. After we release the next alpha I can take a look at it again and see what's up with this for once and all.

Alright so I've had enough of this bug, so I decided to find the cause of it. Apparently, it's literally just SkriptParser line 271. If you change ((the )?var(iable)? )?\{([^{}]|%\{|\}%)+\} to ((the )?var(iable)? )?\{.+\} (replace [^{}]|%\{|\}% with .), it works just fine. I presume the reason this was added, so people wouldn't try using variables in variables like so: {var::{_p}}, but they should've only made it fail on any curly brackets which is not between a pair of %, not make it fail on any curly bracket which isn't directly next to a %.

I was going to PR this, but I thought it would be better to first ask if it's important to keep it failing on variables like {var::{_p}}. The easist way to fix this is by changing the regex, as said above, but because the regex is only used is in the parseVariable method from SkriptParser, a simple parser could be made in there to make sure there isn't any weird stuff going on.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TrademarkTM picture TrademarkTM  路  4Comments

ghost picture ghost  路  3Comments

GiraffeCubed picture GiraffeCubed  路  3Comments

Coolfire02 picture Coolfire02  路  3Comments

wohahobg picture wohahobg  路  3Comments