• 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.

Debug Trigger

Status
Not open for further replies.
Level 3
Joined
Jul 13, 2007
Messages
34
How can I make it so if like Player 1 enters -incomeset (player number) amount. So for example: -incomeset 1 1000. Which would set Income[1] which is player one's income. Or -incomeset 2 1000. Which would set Income[2] which is player two's income. How would I do that. I know its like:
  • Player - Player 1 (Red) types a chat message containing -incomeset as A substring
Then what?
 
Level 8
Joined
May 27, 2007
Messages
170
Maybe something like this could work:

  • Set PlayerIncome[(Integer((Substring((Entered chat string), 12, 12))))] = (Integer((Substring((Entered chat string), 14, 17))))

This is only a guess on my part I'm afraid as I don't have any proper experience with all that substring jazz. Hope it helps anyway! That would only work if spaces are counted as characters, and I don't know if they are or not. It would only work with player 1-9 also, I'm not sure what you would do if you needed to detect double digit player numbers aswell.
 
Level 3
Joined
Jul 13, 2007
Messages
34
Maybe something like this could work:

  • Set PlayerIncome[(Integer((Substring((Entered chat string), 12, 12))))] = (Integer((Substring((Entered chat string), 14, 17))))

This is only a guess on my part I'm afraid as I don't have any proper experience with all that substring jazz. Hope it helps anyway! That would only work if spaces are counted as characters, and I don't know if they are or not. It would only work with player 1-9 also, I'm not sure what you would do if you needed to detect double digit player numbers aswell.

That worked..But what does the 12,12 and 14,17 mean? I understand how it worked, just not the 12,12 and 14,17. I only need it for players 1-8 luckily, and I could only enter 1000...
 
Level 8
Joined
May 27, 2007
Messages
170
The numbers tell the computer what characters to take from the string. Each number refers to the characters place in the scentence, for example:

1 2 3 4 5
H E L L O

H is number 1, so if I wanted to set my variable to whatever value the player entered in the place where H is, I would use Substring, 1, 1. This means it just takes the first character in the string. When the two numbers are different, this means it's taking a range of characters, and the two numbers give the start and end points. So using the word hello again Substring, 1, 4 would take every letter between and including those at positions 1 and 4, so you would end up with the word HELL.

So basically, in that trigger I gave you, the first bit, Substring, 12, 12 is taking the 12th character in the entered chat string. I use 12 because that is the postion in the scentence that the player number is going to be located:

1. -
2. i
3. n
4. c
5. o
6. m
7. e
8. s
9. e
10. t
11.
12. 1
13.
14. 1
15. 0
16. 0
17. 0

Then I used Substring 14, 17 to find the range of characters in the positions that the income amount should've been entered into.

I hope that makes sense :D And I'm glad I could help you sort your problem!
 
Level 3
Joined
Jul 13, 2007
Messages
34
The numbers tell the computer what characters to take from the string. Each number refers to the characters place in the scentence, for example:

1 2 3 4 5
H E L L O

H is number 1, so if I wanted to set my variable to whatever value the player entered in the place where H is, I would use Substring, 1, 1. This means it just takes the first character in the string. When the two numbers are different, this means it's taking a range of characters, and the two numbers give the start and end points. So using the word hello again Substring, 1, 4 would take every letter between and including those at positions 1 and 4, so you would end up with the word HELL.

So basically, in that trigger I gave you, the first bit, Substring, 12, 12 is taking the 12th character in the entered chat string. I use 12 because that is the postion in the scentence that the player number is going to be located:

1. -
2. i
3. n
4. c
5. o
6. m
7. e
8. s
9. e
10. t
11.
12. 1
13.
14. 1
15. 0
16. 0
17. 0

Then I used Substring 14, 17 to find the range of characters in the positions that the income amount should've been entered into.

I hope that makes sense :D And I'm glad I could help you sort your problem!

Thanks! That makes perfect sense.
 
Status
Not open for further replies.
Top