ItsDeltin / Overwatch-Script-To-Workshop

Converts scripts to Overwatch workshops.
208 stars 24 forks source link

Operations always presume that a variable's type is Number, even when variable is explicitly typed #325

Open CactusPuppy opened 3 years ago

CactusPuppy commented 3 years ago

For example, the following script

globalvar Player target = HostPlayer();

rule: "Teleport everyone above the target"
{
    Teleport(AllPlayers(), target + Vector(0,1,0));
}

will fail to compile with the error

Error at 4, 27: Cannot convert type 'Number' to 'Player | Vector'

despite the fact that target is very much a Player type.

Protowalker commented 3 years ago

What happens if you do PositionOf(target) + Vector(0,1,0)? From what I see here it's possible that the compiler doesn't know what to do when adding a player to a vector. That's still an issue, obviously, since you can do this in workshop, but one that makes more sense.

CactusPuppy commented 3 years ago

@Protowalker Forgot to mention originally, but wrapping with PositionOf works as expected. This is mainly an issue due to the fact that the decompiler doesn't wrap players in PositionOf, meaning decompiled modes often fail to compile if the mode's author uses the shortcut of allowing Workshop to cast the player to a position.