[Trigger] Order by Chat Substring Not Working

Level 21
Joined
Mar 16, 2008
Messages
955
Hi, I'm confused why this trigger isn't issueing the orders according to the corresponding substring. For example if player 5 (yellow) types "-join red" the taunt order is not issued. Any ideas?

  • Set Altar Unit Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet Unit_Yellow_Altar = Altar of Knights 0352 <gen>
      • Set VariableSet Knight_Altar_Var[5] = Altar of Knights 0352 <gen>
      • Set VariableSet Unit_OJ_Altar = Altar of Knights 0319 <gen>
      • Set VariableSet Knight_Altar_Var[6] = Altar of Knights 0319 <gen>
      • Set VariableSet Unit_LG_Altar = Altar of Knights 0320 <gen>
      • Set VariableSet Knight_Altar_Var[7] = Altar of Knights 0320 <gen>
      • Set VariableSet Unit_Pink_Altar = Altar of Knights 0342 <gen>
      • Set VariableSet Knight_Altar_Var[8] = Altar of Knights 0342 <gen>
      • Set VariableSet Unit_Grey_Altar = Altar of Knights 0340 <gen>
      • Set VariableSet Knight_Altar_Var[9] = Altar of Knights 0340 <gen>
      • Set VariableSet Unit_LB_Altar = Altar of Knights 0343 <gen>
      • Set VariableSet Knight_Altar_Var[10] = Altar of Knights 0343 <gen>
      • Set VariableSet Unit_DG_Altar = Altar of Knights 0326 <gen>
      • Set VariableSet Knight_Altar_Var[11] = Altar of Knights 0326 <gen>
      • Set VariableSet Unit_Brown_Altar = Altar of Knights 0341 <gen>
      • Set VariableSet Knight_Altar_Var[12] = Altar of Knights 0341 <gen>
      • Set VariableSet Unit_LightBrown_Altar = Altar of Knights 0225 <gen>
      • Set VariableSet Knight_Altar_Var[17] = Altar of Knights 0225 <gen>
      • Set VariableSet Unit_Peach_Altar = Altar of Knights 0226 <gen>
      • Set VariableSet Knight_Altar_Var[18] = Altar of Knights 0226 <gen>
      • Set VariableSet Unit_Lime_Altar = Altar of Knights 0504 <gen>
      • Set VariableSet Knight_Altar_Var[19] = Altar of Knights 0504 <gen>
      • Set VariableSet Unit_LightPurple_Altar = Altar of Knights 0227 <gen>
      • Set VariableSet Knight_Altar_Var[20] = Altar of Knights 0227 <gen>
      • Set VariableSet king_altar_red = Royal Altar 0771 <gen>
      • Set VariableSet king_altar_blue = Royal Altar 0882 <gen>
      • Set VariableSet king_altar_teal = Royal Altar 1549 <gen>
      • Set VariableSet king_altar_purp = Royal Altar 2491 <gen>
  • Universal Type Join
    • Events
      • Player - Player 5 (Yellow) types a chat message containing -join as A substring
      • Player - Player 6 (Orange) types a chat message containing -join as A substring
      • Player - Player 7 (Green) types a chat message containing -join as A substring
      • Player - Player 8 (Pink) types a chat message containing -join as A substring
      • Player - Player 9 (Gray) types a chat message containing -join as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -join as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -join as A substring
      • Player - Player 12 (Brown) types a chat message containing -join as A substring
      • Player - Player 17 (Wheat) types a chat message containing -join as A substring
      • Player - Player 18 (Peach) types a chat message containing -join as A substring
      • Player - Player 19 (Mint) types a chat message containing -join as A substring
      • Player - Player 20 (Lavender) types a chat message containing -join as A substring
    • Conditions
      • (Entered chat string) Equal to (Substring(-join, 1, 5))
    • Actions
      • Set VariableSet PN = (Player number of (Triggering player))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(red, 7, 9))
        • Then - Actions
          • Custom script: call IssueImmediateOrder(udg_Knight_Altar_Var[udg_PN], "taunt")
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(blue, 7, 10))
        • Then - Actions
          • Custom script: call IssueImmediateOrder(udg_Knight_Altar_Var[udg_PN], "avatar")
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(teal, 7, 10))
        • Then - Actions
          • Custom script: call IssueImmediateOrder(udg_Knight_Altar_Var[udg_PN], "burrow")
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Entered chat string) Equal to (Substring(purp, 7, 10))
        • Then - Actions
          • Custom script: call IssueImmediateOrder(udg_Knight_Altar_Var[udg_PN], "detonate")
        • Else - Actions
1744097519061.png

1744098196979.png

1744098218668.png

1744098231766.png

1744098247128.png
 
Level 8
Joined
May 13, 2023
Messages
63
I guess I can help. If what I know and remember is correct, then there are two issues:

1. In the main trigger, the condition returns false because what you've set is this:
Does the entered string (-join .....) equal to (-join)?
The first parameter of the substring has to be your full string. second parameter is starting symbol number, third is final symbol number.
So you should check this:
Substring (Entered chat string, 1, 5) = (-join).
(sorry for pseudocode, writing from phone)

2. Similarly, the conditions in the If/Then/Else cycles are giving false, as (red, 7, 9) is empty - there is no symbol 7 or 9. Instead they should be:
Substring (Entered chat string, 7, i) = (color)
(change i and color to the values you need - here i would be 12)

Remember to give these abilities to the unit types you use, as they can activate only if a unit has corresponding ability.

You can always try to add debug actions with text messages at specific points to see which actions are being processed, or in your case add separate triggers to display a message when unit uses an ability (if ability is not used, the message won't appear).
 
Top