• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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