Simplifying this particular Multiple Event in a trigger..

LearningCode

New Member
Reaction score
24
Trigger:
  • Events
    • Player - Player 1 (Red) types a chat message containing -help as An exact match
    • Conditions
    • Actions
      • Game - Display to .........


THAT event is repeated another 8 TIMES in a trigger in GUI.
Is there a way to shorten it in JASS?
 

LearningCode

New Member
Reaction score
24
If I want this to repeat forever?
Because the Players can just type -help at any point of the game..

The code up there just stays active till it hits 11 and then stops working all together, right? o.0

I don't see how it'd repeat
 

millz-

New Member
Reaction score
25
This is what shows when you convert a GUI to JASS
JASS:

function InitTrig_Camera takes nothing returns nothing
    set gg_trg_Camera = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(0), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(1), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(2), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(3), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(4), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(5), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(6), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(7), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(8), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(9), "-zoom ", false )
    call TriggerAddAction( gg_trg_Camera, function Trig_Camera_Actions )
endfunction

You can change it to work the same with:
JASS:

function InitTrig_Camera takes nothing returns nothing
    local integer i = 0
    set gg_trg_Camera = CreateTrigger()
    loop
        exitwhen i > 9
        call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(i), "-zoom ", false )
        set i = i + 1
    endloop

    call TriggerAddAction( gg_trg_Camera, function Trig_Camera_Actions )
endfunction
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
If I want this to repeat forever?
Because the Players can just type -help at any point of the game..

The code up there just stays active till it hits 11 and then stops working all together, right? o.0

I don't see how it'd repeat

What you do in GUI, is add each player manually.

ie.
Player(0), Player(1), Player(2), etc. all the way up to Player(11)
(note: Player(0) = red, Player(11) = brown)

Instead of doing:
JASS:

    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(0), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(1), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(2), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(3), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(4), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(5), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(6), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(7), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(8), "-zoom ", false )
    call TriggerRegisterPlayerChatEvent( gg_trg_Camera, Player(9), "-zoom ", false )

You can simplify it with a loop which goes through all the players.

What the loop does, is that instead of using Player(0), Player(1), etc., you use Player(i), and i will iterate from 0 to 11, therefore you register the trigger for players 0 to 11 (all the human players).
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
epic indenting rite der azlier

you are HYPERPRO


Also, I think this guy doesn't use vJASS (do you have Jass NewGen Pack installed? If so, I guess you COULD Azlier's solution...)
 

Nestharus

o-o
Reaction score
84
epic indenting rite der azlier

you are HYPERPRO


Also, I think this guy doesn't use vJASS (do you have Jass NewGen Pack installed? If so, I guess you COULD Azlier's solution...)

He no have vJASS, but I gave him a link multiple times that tells him in a step-by-step manner with pics included how to get JassHelper, vJASS, and cJASS and keep them updated ><. There's no reason he shouldn't have vJASS at this point : )
 

LearningCode

New Member
Reaction score
24
That's about the same as what Narks suggested, I tried and failed =(

JASS:
function GiveAid takes nothing returns nothing
    call DisplayTextToPlayer( GetTriggerPlayer(),0,0, &quot;TRIGSTR_3235&quot; )
endfunction

//===========================================================================
function InitTrig_Help takes nothing returns nothing
    local integer i = 0
    local trigger t = CreateTrigger()
    loop
        call TriggerRegisterPlayerChatEvent(t, Player(i), &quot;-help&quot;, true)
        exitwhen i == 8
        set i = i + 1
    endloop
    call TriggerAddAction(t, function GiveAid)
endfunction


[Edit]
I haz teh NewGen 1.5d pack xD

[Edit 2]
How do I implement Azlier's solution?

But isn't implementing his solution a shortcut to my learning? =(
I don't want to learn less and be spoon-fed.. T.T
 

Azlier

Old World Ghost
Reaction score
461
First, create a trigger named OnChat.

Second, convert it to Jass.

Third, replace the contents of that trigger with the OnChat code.

Fourth, use the OnChat function to... ugh. So lazy.
 

LearningCode

New Member
Reaction score
24
Read? yes.
Downloaded cJASS? no xD

I'll go get it now, kay? =x
I really don't know what all this v and c JASS is

Done: cJASS
Done: JassHelper Updated

[Edit]
Okay, Azlier, I GOT IT!!!
Don't get all grumpy >;(
 

Azlier

Old World Ghost
Reaction score
461
You don't need to bother with cJass at this point in time.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
That's about the same as what Narks suggested, I tried and failed =(

JASS:

function GiveAid takes nothing returns nothing
    call DisplayTextToPlayer( GetTriggerPlayer(),0,0, &quot;TRIGSTR_3235&quot; )
endfunction

//===========================================================================
function InitTrig_Help takes nothing returns nothing
    local integer i = 0
    local trigger t = CreateTrigger()
    loop
        call TriggerRegisterPlayerChatEvent(t, Player(i), &quot;-help&quot;, true)
        exitwhen i == 8
        set i = i + 1
    endloop
    call TriggerAddAction(t, function GiveAid)
endfunction
Huh? This doesn't work? You sure?
This should work.

What player are you? Cause this won't work for Player(9) to Player(11) (I think that's dark green, light blue, and brown). Maybe your actions don't work? You could add a BJDebugMsg in the GiveAid function. Maybe your Init function isn't being called?
 

Nestharus

o-o
Reaction score
84
Ok offtopic for a second I know, but my guide goes over enough so that you can implement and use systems developed by other people (libraries, scopes, etc).

From there, just read documentation on that system and you'll be able to use it : )
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
I have no idea what's wrong. It should work.
 

LearningCode

New Member
Reaction score
24
It MIGHT be my computer being all screwy again =.=
This would make it the THIRD time to happen with this map.

And the umpteenth gazillion times to happen while I am learning JASS. =.=
Code seems screwy, not working.
I screw it up a bit.
Code works.
I fix it.
Code remains functional.

pfft.
 

LearningCode

New Member
Reaction score
24
Double post here,
But it works now =.=

And all I did was to change This:

JASS:
    call TriggerAddAction(t, function GiveAid)


To this:
JASS:
    call TriggerAddAction(t, (function GiveAid))



[Edit]
So.
Now that it's working..
Is there anything unnecessary here?

JASS:
function GiveAid takes nothing returns nothing
    call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), &quot;TRIGSTR_3238&quot; )
endfunction

//===========================================================================
function InitTrig_Help takes nothing returns nothing
    local integer i = 0
    local trigger t = CreateTrigger()
    loop
        exitwhen (i == 8)
        call TriggerRegisterPlayerChatEvent(t, Player(i), &quot;-help&quot;, true)
        set i = i+1
    endloop
    call TriggerAddAction(t, (function GiveAid))
endfunction


Can I null triggers and not remove them?
Does nulling a trigger make it non-functional, even if it isn't removed?
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Really? That worked? Strange.

TRIGSTR's suck. Slow, and you don't even know what you are displaying.

You see how TESH and TH.net highlight certain functions in red? That's because they are Blizzard functions - which are usually wrapper functions that do not do anything. Most of them are garbage and you should avoid using them.

JASS:
call DisplayTextToForce( GetForceOfPlayer(GetTriggerPlayer()), &quot;TRIGSTR_3238&quot; )


Did you know you can display text directly to players? I suggest you see exactly what DisplayTextToForce is (look it up on the function list - in TESH, you can hold CTRL and click on this function in your code, and it will show you).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top