Mirreski / Skript

Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them.
http://njol.ch/projects/skript
7 stars 2 forks source link

'a' needed when checking what entity it is. #10

Open Mirreski opened 9 years ago

Mirreski commented 9 years ago

Example: http://pastebin.com/Ppw0QqLB

The check doesn't work properly without the 'a'.

Mirreski commented 9 years ago

Hard to fix actually.

When writing "if loop-entity is skeleton", Skript read that as "if loop-entity is the skeleton". Skript doesn't know who "the skeleton" is and it doesn't find the needed comparator because of that and fails to work. Therefore the "a" is needed before the "skeleton" to clarify it as a type not an object.

I am not sure how to fix this at all.

Mirreski commented 9 years ago

The expression "[the] [event(-| )]entity/skeleton/player...." and so on, is the expression Skript reads from just "skeleton".

By making "event" required it would probably fix this problem but it would break like every script in the community, so that doesn't seem like a option.

Mirreski commented 9 years ago

Perhaps fixed without any problems. But it is possible for another issue/bug to appear because of my fix.

Used the same "hack" I got from Njol's code in Issue https://github.com/Mirreski/Skript/issues/9

Needs more testers.

Mirreski commented 9 years ago

Seems to add another issue/bug. A rather big one for current scripts.

Example code which doesn't work:

command /test:
    trigger:
        set {_player} to player
        message "Location of player: %location of {_player}%"

Example code which works:

command /test:
    trigger:
        set {_player} to event-player
        message "Location of player: %location of {_player}%"

Basicly it's going the other way now. Now you have to prefix it with "event-" for it to work. This would break like every script. So I don't think this fix will work. I have even started to doubt that it is possible to fix this issue without making "event-" or "the" mandatory.

set {_player} to player sets the variable to the TYPE Player not the actual player entity.

This solution seems like a nono. So it will not be added unless I fix this new bug.

Mirreski commented 9 years ago

I found a new fix(could be called quickfix or a little trick) which works perfectly. Passed all my tests. Still can't guaruantee it's bugfree but it's unlikely to give birth to a new bug since the only code change is to the Compare condition (if entity is skeleton for example).

Mirreski commented 9 years ago

Previous fix had a problem. It was a miss in my code so I have fixed it. But still there's some "issues" with this fix:

if loop-entity is player: This and similar ones gets read a "if loop-entity is a player" which would probably break a lot of scripts.

I made a quick check for this so my "quick" fix doesn't include the "player" so: if loop-entity is player: Will work normally and check "if loop-entity is the player"/"if loop-entity is event-player".

This means in other events such as this(Check the broadcasts to see what I mean):

on spawn of zombie:
    wait 1 tick
    loop all entities:
        if loop-entity is a zombie:
            broadcast "This loop-entity is a zombie"
        if loop-entity is zombie:
            broadcast "This loop-entity is a zombie"
        if loop-entity is event-zombie:
            broadcast "This loop-entity is the zombie that got spawned!"

In the older version(2.1.2, 2.2 and my older versions) this works like:

on spawn of zombie:
    wait 1 tick
    loop all entities:
        if loop-entity is a zombie:
            broadcast "This loop-entity is a zombie"
        if loop-entity is zombie:
            broadcast "This loop-entity is the zombie that got spawned!"
        if loop-entity is event-zombie:
            broadcast "This loop-entity is the zombie that got spawned!"

This seems to be the best result of the fixes I have tried for this.

Don't worry I stated high up in this comment that code involving comparing with players like:

command /doiexist:
    trigger:
        loop all players:
            if loop-player is player:
                message "Loop-player is the player who called the command."
                stop

Will work just fine!

Either this "fix" or I will attempt to find another one or scrap this bug.