• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Reactive Extension for Warcraft 3 Lua

This bundle is marked as pending. It has not been reviewed by a staff member yet.
I have started work on RxW3, a port of RxJS/RxLua to be used with Warcraft 3
This particular way of development is far more intuitive to the way that event based programming is done than the trigger based functional programming we are used to.

It is still a work in progress, I am working on the fromEvent helper function as there is a lot of information that will need to go into it.

Example of code being written using the typical trigger/condition format:

Code:
function StartEffectOfAbility()
    local trigger = CreateTrigger()
    TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    TriggerAddAction(trigger, function()
        local caster = GetTriggerUnit() --GetTriggerUnit references the Triggering Unit
        if GetSpellAbilityId() == FourCC('AUan') then --If the ability being cast is equal to Animate Dead
            KillUnit(caster) --Kill the triggering unit (casting unit) to show that it worked
        end
    end)
end

Here is the same example using RxW3:


Code:
local Observable = importWM('RxW3', 'Observable');
local filter = importWM('RxW3', 'Operators/Filter');
local EVENT_TYPE_ANY_UNIT = importWM('RxW3', 'Events/AnyUnit');

Observable.fromEvent(EVENT_TYPE_ANY_UNIT, EVENT_PLAYER_UNIT_SPELL_EFFECT):pipe(
    filter(function (args) return args[1] == FourCC('AUan') end), --Filter for the animate dead ability (event args used to get spell ability id instead)
):subscribe(function (args) KillUnit(args[0]) end); --Kill the triggering unit (casting unit) to show it worked (event args used to get caster instead)

Github:
elliotmendiola/RxW3
Contents

Reactive Extension for Warcraft 3 Lua (Binary)

Top