Warcraft III resources & community, 2003–2006 · archived

Variables

11 posts
#1

Variables

Alright I need some help for a mode I'm making for my map. It is similar to the Deathmatch mode in dota except that instead of using up all the heroes you enter a command such as: -deathmatch (#). In this I want the variable to be filled by the number they place inside the brackets but I can't find a way to do it. Any help is appreciated.
#2
im not familiar to deathmatch in dota but from the sounds of it you probably want to make an integer variable.
#3
Well yes obviously, I'm not a total noob I just need to know how to fill it.
#4
I think you have to use a string conversion to interger. so i think it would be somthing like.

Event - Player enters (-deathmatch )+(X) as a substring
" " " 2 " "
ect....
Action -
For each (integer A) from 1 to (X) so (actions)
IF/THEN/ELSE
IF: entered chat string equal to (-deathmatch )+(String(Integer A)))
THEN
Set DeathmatchVariable = (Integer A)

That works, I tested it. Since its a pretty complicated trigger ill step by step it for you.
The "event" is a "Player chat event" with a CONCENTRATE string. the first part of the concentrate string is (-deathmatch ). the second part is (1). You will need to make as many events as you want your max variable to be. There is a space after death match, so when you type it, it will look like -deathmatch 1.

Next is actions. First action is a "For each integer A do multiple". You want it to be form 1 to X (where x is the max number of deathmatch you can have.
After that, you want to add an "IF/THEN/ELSE" action into the loop action. With condition "entered chat string equal to (-deathmatch )+(String(Integer A)))". Then you simply set a variable = to ineger A and there you have it. All that does is give you a number predicated on what they type. You will have to figure out what to do with that number in a different trigger.
#5
S2I(substring(entered chat, first char value to start reading, end char value to start reading))

ex:
substring("-deathmatch 1234", 7, 11) = "match"
S2I(substring("-deathmatch 1234", 13, 16)) = 1234
#6
yeah see, i didn't undersand the substring format, with the string,#,#. What are those 2 values after the first string value?

EDIT: ooooo I get it now, wow that is really nice. I really wish that blizzard would include the values in their triggers. I know some functions they do, in grey text at the bottom of the window, but they didn't realy give a good example for the substring. so the 2 values after the comma's are the character #. Like the phrase "Dogs bark" if i just wanted the word "bark" i would say "Dogs bark, 6,9". Is that correct?
#7
Draqzyeah see, i didn't undersand the substring format, with the string,#,#. What are those 2 values after the first string value?

EDIT: ooooo I get it now, wow that is really nice. I really wish that blizzard would include the values in their triggers. I know some functions they do, in grey text at the bottom of the window, but they didn't realy give a good example for the substring. so the 2 values after the comma's are the character #. Like the phrase "Dogs bark" if i just wanted the word "bark" i would say "Dogs bark, 6,9". Is that correct?


yes
#8
Yeah okay, what you wrote is what I was hoping I could do. For the X in the Loop function I just place an X? Well frig when I put in my stuff for the loop how the hell do I put the max to be the number that they entered? I can't find any function that allows me to.
#9
no no, X is the max number that they CAN chose. so like if you only have 5 heroes in your game, then the max would be 5. like, there is no -deathmatch 6. so, X is just whatever you want it to be really. I only use X as an example because it could be whatever you want it to be.

however, if you understood raptor's suggestion, i would recomend using that instead, much cleaner and more efficient, no loops.
#10
Event:
Player - Player 1 (Red) types a chat message containing -deathmatch as A substring

Action:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Integer((Substring((Entered chat string), 13, 13)))) Less than or equal to X
Then - Actions
Set YourInteger = (Integer((Substring((Entered chat string), 13, 13))))
Else - Actions
Set YourInteger = 0

X is the maximum number

This trigger is short and easy, its should work for you :D
#11
Ha I was so confused, but then I reread what the raptor guy posted, so I have -deathmatch as a substring then I get it the pick out the substring that is between 13 and 14? since that is where they would place the number? then I can set that as the variable? Okay well thx guys, I will implement it soon.