• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] Substring issue

Status
Not open for further replies.
Level 9
Joined
Dec 31, 2016
Messages
320
  • DestroyBases
    • Events
      • Player - Player 2 (Blue) types a chat message containing -Destroy as A substring
    • Conditions
    • Actions
      • Set ChatString = (Entered chat string)
      • For each (Integer A) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit - Kill Castle[(Integer((Substring(ChatString, (9 + (Integer A)), (9 + (Integer A))))))]
This trigger should kill the castle as its number is written by a player. For example you can type "-destroy 1234" or "24" and the appropriate castle will be destroyed. The thing is, it works only for the first number you type. Castle variable is set properly and the loop also worked fine when I change the action to something else. So I've run out of ideas of what is causing that issue.
 
If you type -destroy 1234 then the first loop will return 1, the second loop will return 2, the third 3 and the fourth 4. If your castle variables are 4 numbers long as you say, this is why nothing is happening.

The sub-string you are interested in from positions 9 to 12 (1-8 are taken up by "-destroy ". Using a loop is inappropriate, all you need to do is kill Castle[(Integer((Substring(ChatString, 9, 12))))]
 
Status
Not open for further replies.
Back
Top