[Trigger] What is the variables type of a chat message?

Level 7
Joined
Feb 22, 2009
Messages
260
I tried string but it didn't show up in the dropdown list.

1728017059550.png
 

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
It is string but you can't use the variable for events in GUI.
So instead you should do it in action.
  • Fel
    • Events
      • Player - Player 1 (Red) types a chat message containing -fel as An exact match
    • Conditions
    • Actions
      • Set EnteredString = (Entered chat string)
EnteredString is a string variable.
Perhaps you can elaborate more on what you're trying to achieve with this string variable.

Interestingly, this is achieveable in JASS.
JASS:
function WhatYouWantToDo takes nothing returns nothing
    // Do your actions here
endfunction

//===========================================================================
function InitTrig_Fel takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer index = 0
   
    loop
        call TriggerRegisterPlayerChatEvent( t, Player(index), udg_YourStringVariable, true )
        set index = index + 1
        exitwhen index == bj_MAX_PLAYER_SLOTS
    endloop
   
    call TriggerAddAction( t, function WhatYouWantToDo )
endfunction
 
Last edited:
Level 7
Joined
Feb 22, 2009
Messages
260
I use it for faction change. You know the type -fel to change from playing normal orc to fel orc.

  • Fel orc
    • Events
    • Conditions
    • Actions
      • Set ReplaceUnitGroup = (Units owned by (Triggering player))
      • Unit Group - Pick every unit in ReplaceUnitGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Peon
            • Then - Actions
              • Unit - Replace (Picked unit) with a Fel Orc Peon using The old unit's relative life and mana
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Great Hall
            • Then - Actions
              • Unit - Replace (Picked unit) with a War Chamber using The old unit's relative life and mana
            • Else - Actions
      • Custom script: call DestroyGroup (udg_ReplaceUnitGroup)

  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • Trigger - Add to Fel orc <gen> the event (Player - (Picked player) types a chat message containing -fel as An exact match)
 

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
Yeah, that should work. :)
I completely forgot you can do this as well
  • Player Group - Pick every player in (All players) and do (Actions)
    • Loop - Actions
      • Trigger - Add to YourTrigger the event (Player - (Picked player) types a chat message containing YourText as An exact match)
this way you can use string variable for the event. YourText is a string variable.
 
Top