1. Are you planning to upload your awesome tool to Hive? Please review the rules here.
    July 9, 2018: The rules for the Tool Section have been revised. Please be sure to read the revisions.
    Dismiss Notice
  2. Seek unity between the elements in the 22nd Terraining Contest Poll.
    Dismiss Notice
  3. Seize the moment! The 18th Mini Mapping Contest has commenced.
    Dismiss Notice
  4. Gather 'round - the 20th Icon Contest Poll is out.
    Dismiss Notice
  5. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Reactive Extension for Warcraft 3 Lua

Submitted by G_Freak45
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 (Text):
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 (Text):
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)

  1. G_Freak45

    G_Freak45

    Joined:
    Jan 27, 2011
    Messages:
    11
    Resources:
    0
    Resources:
    0
    I am continuing to update this, do not download directly from hive, get from github if you want to use it, also feel free to install using WLPM
     
  2. yxq1122

    yxq1122

    Joined:
    Jun 5, 2018
    Messages:
    156
    Resources:
    1
    Tools:
    1
    Resources:
    1
    Thank you for trying to improve the coding experience! Please continue this meaningful work.
     
  3. G_Freak45

    G_Freak45

    Joined:
    Jan 27, 2011
    Messages:
    11
    Resources:
    0
    Resources:
    0
    Don't thank me yet, still a work in progress

    Need to get more testing, demos, etc