Skript: Interesting Bug About Variable Indexes

Created on 7 Oct 2017  路  14Comments  路  Source: SkriptLang/Skript

Test Skript:

set {test::%type of player's tool%} to "test"
set {test::%player's tool%} to "test"
loop {test::*}:
    send "%loop-index% - %loop-value%"

Result:

image
image

Versions

Skript: 2.2-dev31c
Server: PaperSpigot 1.12 (b1169)and1.12.2 (b1234)

Note:

Some checks like {test::%type of player's tool%} is set works if i'm holding the same items.

bug

Most helpful comment

Yeah, don't think this is a bug, it's how objects are represented when stored as an index. It's useful because it lets you parse out the type from the index.

All 14 comments

I think this is intended behavior, but I'm not sure. I actually like it -- it happens with locations too (when used in variables the world is also printed) which is nice for parsing.
image

Yeah, don't think this is a bug, it's how objects are represented when stored as an index. It's useful because it lets you parse out the type from the index.

What? Are you serious? ..

Seems to be unintentional change in some recent version.

So, i'm looking at this and I totally cannot understand how this could ever have been an unintentional change. the toVariableString was purposefully changed at some point (this has been like this since at least 2013 https://github.com/bensku/Skript/blob/ae20a83b91768523f69dc410b03586188e4dd360/src/main/java/ch/njol/skript/classes/data/BukkitClasses.java#L239). I think that it should just stay at this point as this issue has been around for quite a while and it provides utility in recreating a Location and an ItemStack/Type. What do you guys think?

It doesn't even work fine for player's tool. It shouldn't be a feature, even in Skript, it is ugly. Variable indexes always known as texts. {%tool%} and "%tool%" works same. Already there is no way to get the object from the variable index because it is a text, still you need to use parse. Also it works only for some specified Skript types.

{%expression%} and "%expression%" aren't always meant to work the same way. thats why a type's parser has seperate methods for both. The reason this is more useful for parsing is because the world is included, which it usually isnt (e.g. when broadcasted). The reason it doesn't work for player's tool is because tool (annoyingly) returns a Slot, not a ItemStack/ItemType.

They used to work same until this weird issue. If you want world, use "%world%: %location%". This is not useful or something, I haven't seen it used as technically in Skript too. It looks like unnecessary.

if you look in the commit history it's been this way since 2012 or so

Next build has rather big changes to slot handling. I advise you to check again when it hits.

Can this be closed now?

Maybe when that unnecessary and unlogical thing is removed

Use type of player's tool

This is an internal naming

No lol

I mean, variable indexes are visible to the user. It is not like values. And the user shouldn't see those weird things also doesn't work properly.

Variable indexes should be normal texts always (at least until rework of variables).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TrademarkTM picture TrademarkTM  路  4Comments

Anoniempje1234 picture Anoniempje1234  路  3Comments

GiraffeCubed picture GiraffeCubed  路  3Comments

jaylawl picture jaylawl  路  3Comments

wohahobg picture wohahobg  路  3Comments