• 🏆 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!

[snippet]Trigger

Level 31
Joined
Jul 10, 2007
Messages
6,306
JASS:
library Trigger
    struct Trigger extends array
        private static trigger array triggers
        
        private static integer instanceCount = 0
        private static integer array recycle
        private static integer recycleCount = 0
        
        public static method create takes nothing returns thistype
            if (recycleCount != 0) then
                set recycleCount = recycleCount - 1
                set triggers[recycle[recycleCount]] = CreateTrigger()
                return recycle[recycleCount]
            endif
            set instanceCount = instanceCount + 1
            return instanceCount
        endmethod
        
        public method destroy takes nothing returns nothing
            if (triggers[this] != null) then
                call DestroyTrigger(triggers[this])
                set triggers[this] = null
                set recycle[recycleCount] = this
                set recycleCount = recycleCount + 1
            endif
        endmethod
        
        public method add takes boolexpr c returns nothing
            call TriggerAddCondition(triggers[this], c)
        endmethod
        
        public method fire takes nothing returns nothing
            call TriggerEvaluate(triggers[this])
        endmethod
    endstruct
    
    function OnEvent takes boolexpr c, integer eventId returns nothing
        call Trigger(eventId).add(c)
    endfunction
endlibrary

Why?
JASS:
globals
    integer EVENT_UNIT_REMOVE //set on init
    integer EVENT_UNIT_DEATH //set on init
endglobals

function test takes nothing returns nothing
    call OnEvent(Condition(function myFunc), EVENT_UNIT_REMOVE)
endfunction
 
Last edited:
Level 8
Joined
Oct 3, 2008
Messages
367
There doesn't seem to be any real point to this. I can't see a single scenario where I would use this. I would recommend making your other scripts not require this, because I doubt it will go anywhere.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
There doesn't seem to be any real point to this. I can't see a single scenario where I would use this. I would recommend making your other scripts not require this, because I doubt it will go anywhere.

aye, that point was made and I stopped using it ;).

edit
Actually, I'm thinking of something like this now for just trigger evaluations as it will let you do something like-
OnEvent(boolexpr c, Event event)

so like-
OnEvent(Condition(function ehh), UNIT_REMOVE_EVENT))

And then a library, like an indexer, would just do like UNIT_REMOVE_EVENT = Trigger.create()

Interesting idea? : P

Then again, I don't mind if it gets graveyarded. It was primarily an idea that I quickly used to begin with and then stopped using. This next version is just an idea that I'm bleh about (not sure if i'd use it).
 
Last edited:
Top