HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Converting chat message to a real variable

06-15-2008, 09:25 AM#1
Fluff
I'm working on a map right now in which Player 1 can set the score limit. I have a real variable called "Victory" and when a team reaches that number they win. Player 1 has 10 seconds in the beginning of the game to type in a number (between 1 and 100 or whatever) and then this will be set as "udg_Victory". But I'm not sure how to go about doing this because Player 1 may type in something other than numbers during that time or he may type in a number too large. If he types in nothing, that's okay because the variable is set to 50 by default. Any help will be appreciated.

EDIT: Sorry I meant to post this in Scripting :/
06-15-2008, 10:08 AM#2
Spec
Hmm, similar problem was discussed here - http://wc3campaigns.net/showthread.php?t=100216
Just add check for ranges of variable:
Trigger:
VictorySetting
Collapse Events
Player - Player 1 (Red) types a chat message containing -win as A substring
Conditions
Collapse Actions
Set tempstr = (Substring((Entered chat string), 5, (Length of (Entered chat string))))
Collapse For each (Integer A) from 1 to (Length of tempstr), do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Substring(tempstr, (Integer A), (Integer A))) Equal to
Collapse Then - Actions
Set Victory = (Integer((Substring(tempstr, ((Integer A) + 1), (Length of tempstr)))))
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Victory is greater than 100)
Collapse Then - Actions
Set Victory = (100)
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Victory is lesser than 1)
Collapse Then - Actions
Set Victory = (1)
Else - Actions
Else - Actions
Trigger - Turn off (This trigger)
06-15-2008, 06:36 PM#3
Fluff
Thank you very much. That works out perfectly. (+rep)