• 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.

Is it bad to do it like this:

Status
Not open for further replies.
Level 8
Joined
Aug 2, 2006
Messages
346
I have an array of booleans to correspond to a button being down (true), or up (false) for each player.

To setup this trigger, is it better to do it this way:

Code:
function InitTrig_UpArrowDepress takes nothing returns nothing
    set gg_trg_UpArrowDepress = CreateTrigger(  )
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(0), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(1), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(2), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(3), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(4), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(5), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(6), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(7), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(8), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(9), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(10), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress, Player(11), EVENT_PLAYER_ARROW_UP_UP)
    call TriggerAddAction( gg_trg_UpArrowDepress, function Trig_UpArrowDepress_Actions )
endfunction
or this way:

Code:
function InitTrig_UpArrowDepress_Copy takes nothing returns nothing
    local integer i = 0
    set gg_trg_UpArrowDepress_Copy = CreateTrigger(  )
    loop
        exitwhen i >= 12
        call TriggerRegisterPlayerEvent(gg_trg_UpArrowDepress_Copy, Player(i), EVENT_PLAYER_ARROW_UP_UP)
        set i = i + 1
    endloop
    call TriggerAddAction( gg_trg_UpArrowDepress_Copy, function Trig_UpArrowDepress_Actions )
endfunction

Part of me thinks that it's just not right to have a loop in the events... but I barely understand how events work in JASS anyways so... that's why I'm here.
 
Last edited:
Level 6
Joined
Mar 20, 2008
Messages
208
It depends. Do you want map space or load time?

The loop will increase load time, since there is overhead, but save you some space, which is fairly negligable since we got another 4mb to work with.

The non looped version will take up a bit more space but give you faster load time.
 
Level 8
Joined
Feb 15, 2009
Messages
463
It depends. Do you want map space or load time?

The loop will increase load time, since there is overhead, but save you some space, which is fairly negligable since we got another 4mb to work with.

The non looped version will take up a bit more space but give you faster load time.

Bulls**t

the loop is definitely the better way to initialize this and loops will always be better then copy & paste with changed indexes

and we talk about space with a size of äääääm about 3bytes?1 kb? they all are useless to look and where do you know from that loops take more time please? loops are defintely faster i would say
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,287
Loops technically are slower to exectue as they require more variable setting. Lists are slower to compile as they require more conversion.

I would say in the end loops probably save more time as they are shorter to compile and use less map space as well as the execution time diffeence is minial (few nano seconds).
 
Level 6
Joined
Mar 20, 2008
Messages
208
Alright alright geeze! I'll go with the damned loops then!

What he says is true, but as I have mentioned above, we do have another 4mb to work with.

So its really dependant on what other things your map has going. If its negligable on load time then go with loops.

Bulls**t

the loop is definitely the better way to initialize this and loops will always be better then copy & paste with changed indexes

and we talk about space with a size of äääääm about 3bytes?1 kb? they all are useless to look and where do you know from that loops take more time please? loops are defintely faster i would say

Common sense would tell you loops take more processing time than hardcoding it all out. One takes a counter as well as a boolean check, the other just does it straight forward.

As for saving space, its worth is really dependant on the map. If you have 20 triggers using similiar events, then thats maybe 20kb give or take right there.
Tact that on to whatever else you can do to reduce code size and it all adds up.
 
Status
Not open for further replies.
Top