Snippet Event

Good to see you too, Cohadar. Was starting to wonder... :p

EventReg's are the joining point of an event and a trigger. A trigger registered to an event produces an EventReg which is only used for storing data. Typecasting Events to EventRegs is a way of restricting what users can do (wouldn't want them to call chainDestroy or something).

>Just because blizzard does not have one does not...
You're right. Is there a good way to do this with O(1) complexity? Otherwise I'll just have it do the search.

I'll find time to update this once the bulk of my exams are over. I had to release this because watching Azlier trying to write it over and over again in his systems was like watching a kid cut his finger off while slicing tomatoes. =/
 
EventReg's are the joining point of an event and a trigger. A trigger registered to an event produces an EventReg which is only used for storing data. Typecasting Events to EventRegs is a way of restricting what users can do (wouldn't want them to call chainDestroy or something).
*sigh*, learn to use keyword

>Just because blizzard does not have one does not...
You're right. Is there a good way to do this with O(1) complexity? Otherwise I'll just have it do the search.
Speed is not an issue there.
 
Haven't added unregister trigger (yet, heh), but I've updated the documentation to make this respectable. I'm aware several resources which rely on this have already been approved, and a growing number of those submitted are using it.

If a mod would like to either approve this or let me know what needs to be done to get this approved, that would be great. :)
 
It needed a documentation, which it now has.
Approved. :)
 
Why do you want the Remove Event thing?

I didn't want to add it won't be O(1) but DestroyTrigger is, and can be used in its place...

Because it is the only feature which will force me to use it instead of Table.
The price is that a resource which use that can only be approved here, for me it's definitely too much if the user can't remove the custom event.

Sometimes destroy an event is useful instead of destroy and recreate the entire trigger, in case you have multiple events on a same trigger and just want to disable one.
But if you don't do it i will live with that.
 
Even after reading everything, I have no idea how I can create an event.

I want to create an event "Player presses a key "A") e.g...
Based off the Game - Force player to press UI key
 
You trigger events yourself. Inside the system that operates the event, everything is done by triggers. From the outside, it looks and acts like a normal WC3 event. Except that it doesn't leak.
 
Here's an example of a custom event. It detects when a unit enters the playable map area. Freehand, beware.

JASS:
scope EnterWorldEvent initializer Init

globals
    private Event Ev
endglobals

function TriggerRegisterEnterWorld takes trigger whichTrigger returns nothing
    call Ev.register(whichTrigger)
endfunction

private function Fire takes nothing returns nothing
    call Ev.fire()
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterEnterRectSimple(t, bj_mapInitialPlayableArea) //I hate BJ's, but I'm lazy right now.
    call TriggerAddAction(t, function Fire)

    set Ev = Event.create() //Create Event
endfunction
 
TriggerRegisterEnterWorld(trig) would become the event of another trigger?

I don't understand the mechanic at all.

Ev.Register; Ev is the Event, register means that you register it to the function TriggerRegisterEnterWorld?

I also don't understand where do you set that Ev means



Could you give me an example with an action?

Like SetUnitFacing, Event: UnitFacingIsSet.. Something like that :p +rep if you do|
 
TriggerRegisterEnterWorld will cause the trigger to fire when a unit enters the playable map area. Just like your everyday event.

An Event is just a stack of triggers that you can add to and fire. Nothing that special.

.register adds a trigger to the stack.
.fire fires every trigger in the stack.
.create creates an Event.
.destroy destroys an Event.
 
?

Can you give me an example?
I really don't understand what you said. :D

How can I cause that when a unit's facing is changed by trigger, it will fire?
 
That isn't an easy one to do. vJass' hooks aren't developed enough for that quite yet.

EDIT: Actually, they are. vJass' hooks would work fine for that.
 
This might work. You use TriggerRegisterUnitFacingSetEvent to make a trigger fire when the native SetUnitFacing is used. Wow, thassa long function name. Oh, and this is totally untested and uncompiled. Good luck!

JASS:
library wTf initializer Init

globals
    private Event Ev
endglobals

private function Hook takes unit u, real angle returns nothing
    call Ev.fire()
endfunction

hook SetUnitFacing Hook

function TriggerRegisterUnitFacingSetEvent takes trigger t returns nothing
    call Ev.register(t)
endfunction

private function Init takes nothing returns nothing
    set Ev = Event.create()
endfunction

endlibrary
 
You understand that "fire" fires the Event, right? This is the only time the Event will ever fire.

For example, in Warcraft let's say you have your standard unit dies event. Killing a unit fires that event! Let's say you wanted an Event to fire when a unit's mana drops below half. First, you need triggers to detect that. Then you need to fire an Event when it occurs. Notice in this example that every trigger created fires the same Event, so when a trigger is registered on that Event, it will fire when any unit's mana drops below half.
JASS:
struct ManaEvent extends array
    static Event ev // A global Event.
    private trigger t // A trigger attached to every unit through AIDS.
    
    // Runs when a unit's mana drops - the condition on every unit's trigger.
    private static method fireThings takes nothing returns boolean
        call thistype.ev.fire()
        return false
    endmethod
    
    // Runs when a unit enters the map.
    private method AIDS_onCreate takes nothing returns nothing
        set this.t=CreateTrigger()
        call TriggerRegisterUnitManaEvent(this.t,this.unit,LESS_THAN_OR_EQUAL,GetUnitState(this.unit,UNIT_STATE_MANA)/2.0)
        call TriggerAddCondition(this.t,Condition(function thistype.fireThings))
    endmethod
    
    // Runs after a unit leaves the map.
    private method AIDS_onDestroy takes nothing returns nothing
        call DestroyTrigger(this.t)
    endmethod
    
    // Runs on map initialisation.
    private static method AIDS_onInit takes nothing returns nothing
        set thistype.ev=Event.create()
    endmethod
    
    static method register takes trigger t returns nothing
        call thistype.ev.register(t)
    endmethod
    //! runtextmacro AIDS()
endstruct
// Can now call ManaEvent.register(trigger) to register drop to half mana event on a trigger.

Event/AIDS combo. :) (But this particular example won't work for units whose maximum mana changes - that can be worked around fairly easily. Hey, you could even have an Event for when its maximum mana changes, and use this to recreate the trigger. :))

Feel free to keep asking for more examples and the like.

You can make Events for all kinds of things, the condition is that you can detect when they should fire using JASS.
You also will often need to write your own event responses - but in some cases GetTriggerUnit and such will work, by picking up the unit that triggered the warcraft III event that ran the trigger that fired the Event. For example, in Damage (the native GetEventDamage() and others all work, like on a normal on damage event, because that's what the Event is fired from).
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?
  • The Helper The Helper:
    I am doing my first Vibe Coding project. In installed the environment and tools according to instructions but it is all chat doing this for me at my direction. It is fun really and holy shit I might finish in 2 hours what it would have taken a day to in my Access and this would be an electron app complete new
  • Ghan Ghan:
    Good stuff.
  • Ghan Ghan:
    Just make sure it is secure. :)
  • The Helper The Helper:
    It will only be on internal network

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top