wurstscript / WurstStdlib2

WurstScript Standard Library Version 2
Apache License 2.0
55 stars 53 forks source link

"AbilityDefinitionIllidanMetamorphosis" doesn't work #289

Closed DoctorRyner closed 5 years ago

DoctorRyner commented 5 years ago

It simply doesn't work if I set alternative form that way, maybe we need to create a simple morphing preset like with channel?

@compiletime function morphGen ()
    new AbilityDefinitionIllidanMetamorphosis (morphId)
        ..presetNormalFormUnit    (_ -> heroId.toString ())
        ..presetAlternateFormUnit (_ -> heroId2.toString ())
        ..presetCooldown          (_ -> 5)
        ..presetDurationHero      (_ -> 2)
        ..presetDurationNormal    (_ -> 0.5)
Frotty commented 5 years ago

Specify "doesn't work" 😐 .

If heroId is an int, .toString() is simply wrong. Check the generated output.

DoctorRyner commented 5 years ago

presetAlternateFormUnit is lambda (int -> string), how should I convert that then?

Frotty commented 5 years ago

IdGenerators return ints and if you write int i = 'h000' it is quite obvious that i is an int. Single quotes in jass and wurst are just base 256 ints (with some restrictions) to have more recognizable format. int.toString() returns the numerical representation in base 10 e.g. 34123974, not base 256.


Use int.toRawCode() or even better commaList from the ObjectIds package, the second supporting a variable amount of arguments, returning a comma separated list of ids used for e.g. normal spells, built structures, etc.

..presetNormalFormUnit    (_ -> commaList(heroId))

There are also examples on the doc pages https://wurstlang.org/stdlib/unit_objed

DoctorRyner commented 5 years ago

Thank you, that works perfect! Im just not used to these low level things, we in Haskell include something like this in a type level :)

Frotty commented 5 years ago

You're welcome. You can suggest information to be added to the website if you think something is missing. https://github.com/wurstscript/wurstscript.github.io