Substrings Help

WolfieeifloW

WEHZ Helper
Reaction score
372
The "tooltip" for the substring command is cutoff in NewGen...
So I need help with this.
I'm making a little trigger just for testing purposes that when a player types "-lvlup" they level up once.
This part works ;) !
But, I also want the player to be able to type "-lvlup#" where # gets replaced with a real number.
There can be two numbers here too, so I tried to substring both:
Code:
LevelUp
    Events
        Player - Player 1 (Red) types a chat message containing -lvlup as A substring
        Player - Player 2 (Blue) types a chat message containing -lvlup as A substring
        Player - Player 3 (Teal) types a chat message containing -lvlup as A substring
        Player - Player 4 (Purple) types a chat message containing -lvlup as A substring
        Player - Player 5 (Yellow) types a chat message containing -lvlup as A substring
        Player - Player 6 (Orange) types a chat message containing -lvlup as A substring
        Player - Player 7 (Green) types a chat message containing -lvlup as A substring
        Player - Player 8 (Pink) types a chat message containing -lvlup as A substring
        Player - Player 9 (Gray) types a chat message containing -lvlup as A substring
        Player - Player 10 (Light Blue) types a chat message containing -lvlup as A substring
        Player - Player 11 (Dark Green) types a chat message containing -lvlup as A substring
        Player - Player 12 (Brown) types a chat message containing -lvlup as A substring
    Conditions
    Actions
        Set tempGroup = (Units in (Playable map area) owned by (Triggering player))
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Entered chat string) Equal to (==) -lvlup
            Then - Actions
                Unit Group - Pick every unit in tempGroup and do (Actions)
                    Loop - Actions
                        Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + 1), Show level-up graphics
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Length of (Entered chat string)) Equal to (==) 7
                    Then - Actions
                        Unit Group - Pick every unit in tempGroup and do (Actions)
                            Loop - Actions
                                Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + (Integer((Substring(-lvlup, 6, 7))))), Show level-up graphics
                    Else - Actions
                        Unit Group - Pick every unit in tempGroup and do (Actions)
                            Loop - Actions
                                Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + (Integer((Substring(-lvlup, 6, 8))))), Show level-up graphics
        Custom script:   call DestroyGroup(udg_tempGroup)
Like I said, if you type "-lvlup" it works, but if you try something like "-lvlup7", it doesn't work.

Thanks in advance TH.net!
 

Metaldrummer

New Member
Reaction score
11
Well, (6,7) would give p#, and (6,8) would give p##. The substring numbers are inclusive. Hope this helps.
 

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
(Entered chat string) Equal to -lvlup <- this should be (Substring((Entered chat string), 1, 6)) Equal to -lvlup

Because -lvlup only a sub string, you check the entire string for -lvlup so -lvlup7 will not work.
-----
I rewrote this trigger a bit:
(I haven't added the events, I'm lazy :p )
Trigger:
  • Level Up
    • Events
    • Conditions
      • (Substring((Entered chat string), 1, 6)) Equal to -lvlup
    • Actions
      • Set TempGroup = (Units in (Playable map area) owned by (Triggering player))
      • Set TempInt = (Integer((Substring((Entered chat string), 7, (Length of (Entered chat string))))))
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + TempInt), Show level-up graphics
      • Custom script: call DestroyGroup( udg_TempGroup )


-lvlup7 or -lvlup15 should add 7 or 15 levels to your heroes

I hope it works :D
 
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