HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Setting variables by chat command

05-02-2008, 11:00 AM#1
v16
So i made a trigger for winning in my map that needs to make 80 lumber but i want to make it a selectable number not only 80. i'm alittle stuck on the how to get the substrings = number so i don't know how .
P.S. 10x in advance
05-02-2008, 12:39 PM#2
Deaod
Trigger:
TextEntered
Collapse Events
Player - Player 1 (Red) types a chat message containing -set as A substring
Conditions
Collapse Actions
-------- filter out the "-set " --------
Set tmpstr = (Substring((Entered chat string), 5, (Length of (Entered chat string))))
-------- now the actual filtering of the text --------
Collapse For each (Integer A) from 1 to (Length of tmpstr), do (Actions)
Collapse Loop - Actions
-------- Search for a white space --------
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Substring(tmpstr, (Integer A), (Integer A))) Equal to
Collapse Then - Actions
-------- and then check if the user wants lumber to be changed and set the variable to the given value --------
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Substring(tmpstr, 1, ((Integer A) - 1))) Equal to lumber
Collapse Then - Actions
Set Lumber = (Integer((Substring(tmpstr, ((Integer A) + 1), (Length of tmpstr)))))
Else - Actions
Else - Actions

that should be it.
Oh and what you are looking for is the Conversion function.
05-02-2008, 05:29 PM#3
v16
just one thing (Substring(tmpstr, (Integer A), (Integer A))) Equal to

whats it equal to?
05-02-2008, 06:04 PM#4
Deaod
a white space " "
05-03-2008, 09:30 AM#5
v16
How can i put the variable Lumber in becouse when i try to add the integer it says that there isn't any generated variables
Trigger:
Win
Collapse Events
Player - Player 1 (Red)'s Current lumber becomes Greater than or equal to 80.00
Conditions
Collapse Actions
Collapse Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
Collapse Loop - Actions
Game - Victory (Picked player) (Show dialogs, Show scores)
Collapse Player Group - Pick every player in (All enemies of Player 1 (Red)) and do (Actions)
Collapse Loop - Actions
Game - Defeat (Picked player) with the message: Defeat!
05-03-2008, 10:02 AM#6
Spec
Add to Deaod's trigger (in the end) this:
Trigger:
TextEntered
-------- Registering events --------
Collapse Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
Collapse Actions
Trigger - Add to Win <gen> the event (Player - (Picked Player)'s Current lumber becomes >= Lumber)
and remove existing event in "Win".
05-03-2008, 10:24 AM#7
v16
i can't find Lumber :(
05-03-2008, 11:04 AM#8
Spec
"Lumber" is integer variable (if you still don't created it, press [ctrl]+[b] and do it).
05-03-2008, 11:20 AM#9
v16
it's a integer but it only shows reals not integer
05-03-2008, 11:48 AM#10
Spec
Hmm, sorry, I missed types). Use "conversion - integer to real":
Trigger:
TextEntered
-------- Registering events --------
Collapse Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
Collapse Actions
Trigger - Add to Win <gen> the event (Player - (Picked Player)'s Current lumber becomes >= Real(Lumber))
By the way, if player 1 will type "-set" twice (or more), there can be some bugs in registering events. For example, player wrote "-set 44" and then "-set 77" - trigger will proc, if lumber of any player becomes >= 44.
To prevent this bug, create boolean variable Lumber_set and modify trigger:
Trigger:
TextEntered
Collapse Events
Player - Player 1 (Red) types a chat message containing -set as A substring
Collapse Conditions
Lumber_set equal to No
Collapse Actions
set Lumber_set = Yes
-------- filter out the "-set " --------
Set tmpstr = (Substring((Entered chat string), 5, (Length of (Entered chat string))))
-------- remaining actions --------
05-03-2008, 02:21 PM#11
v16
can't i just turn off the trigger in the end?
05-03-2008, 02:43 PM#12
v16
Ok this is a kill selection.when the computer kills someone even if i set it to 1000000 1 kill and the game is finished
Trigger:
Untitled Trigger 080
Collapse Events
Player - Player 1 (Red) types a chat message containing -kill 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
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Substring(tempstr, 1, ((Integer A) - 1))) Equal to Lumber
Collapse Then - Actions
Set lumber = (Integer((Substring(tempstr, ((Integer A) + 1), (Length of tempstr)))))
Else - Actions
Else - Actions
Collapse Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Win <gen> the event (Player - Player 1 (Red)'s Current gold becomes Greater than or equal to (Real(lumber)))
Trigger - Add to Win Copy 2 <gen> the event (Player - Player 2 (Blue)'s Current gold becomes Greater than or equal to (Real(lumber)))
Collapse Player Group - Pick every player in (All allies of Player 3 (Teal)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Win Copy <gen> the event (Player - Player 3 (Teal)'s Current gold becomes Greater than or equal to (Real(lumber)))
Trigger - Add to Win Copy 3 <gen> the event (Player - Player 4 (Purple)'s Current gold becomes Greater than or equal to (Real(lumber)))
Collapse Player Group - Pick every player in (All allies of Player 5 (Yellow)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Win Copy 4 <gen> the event (Player - Player 5 (Yellow)'s Current gold becomes Greater than or equal to (Real(lumber)))
Trigger - Add to Win Copy 5 <gen> the event (Player - Player 6 (Orange)'s Current gold becomes Greater than or equal to (Real(lumber)))
Collapse Player Group - Pick every player in (All allies of Player 7 (Green)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Win Copy 6 <gen> the event (Player - Player 7 (Green)'s Current gold becomes Greater than or equal to (Real(lumber)))
Trigger - Add to Win Copy 7 <gen> the event (Player - Player 8 (Pink)'s Current gold becomes Greater than or equal to (Real(lumber)))
Collapse Player Group - Pick every player in (All allies of Player 9 (Gray)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Win Copy 8 <gen> the event (Player - Player 9 (Gray)'s Current gold becomes Greater than or equal to (Real(lumber)))
Trigger - Add to Win Copy 9 <gen> the event (Player - Player 10 (Light Blue)'s Current gold becomes Greater than or equal to (Real(lumber)))
Collapse Player Group - Pick every player in (All allies of Player 11 (Dark Green)) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Win Copy 10 <gen> the event (Player - Player 11 (Dark Green)'s Current gold becomes Greater than or equal to (Real(lumber)))
Trigger - Add to Win Copy 11 <gen> the event (Player - Player 12 (Brown)'s Current gold becomes Greater than or equal to (Real(lumber)))
Wait 1.00 seconds
Trigger - Turn off (This trigger)
05-03-2008, 03:38 PM#13
Spec
Why there are so many copies of trigger "Win"? I think that these copies contains similar actions, so they can be compiled in one flexible trigger.
And watch out where you place event registration. I realized that second condition is unneeded.
Trigger:
KillSetting
Collapse Events
Player - Player 1 (Red) types a chat message containing -kill as A substring
Conditions
Collapse Actions
Set tempstr = (Substring((Entered chat string), 6, (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 lumber = (Integer((Substring(tempstr, ((Integer A) + 1), (Length of tempstr)))))
Collapse Player Group - Pick every player in (All Players) and do (Actions)
Collapse Loop - Actions
Trigger - Add to Win <gen> the event (Picked Player)'s Current gold becomes Greater than or equal to (Real(lumber)))
Else - Actions
Trigger - Turn off (This trigger)
This should work properly, I hope.
05-03-2008, 04:26 PM#14
v16
WORKS :D 10x man for the help +rep for the time.i had an unneeded condition and the lumber was set to gold