Saturday, April 21, 2012

set variables through chat messages?

hey. Is there an easy way to use the


Code:
Player - Player 1 (Red) types a chat message containing *** as An exact match

to set variables? for example:


Code:
Events
Player - Player 1 (Red) types a chat message containing 3 as An exact match
Conditions
Actions
Set integer = 3

that would be sweet, and i think its do-able because ive seen maps where one can choose from 1-99 lives etc.

pwease answer :)|||sure, here is an example.


Code:
Melee Initialization
Events
Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
Conditions
Actions
Set chatnumber = (Entered chat string)
Set Number = (Integer(chatnumber))

The event detects, any chat (keep in mind with any I mean anything that is written, so you might want to toy around with that)

The first variable is a string variable, to save what has been written, the second is an integer variable, that converts the string to an actual number.|||Quote:






View Post

sure, here is an example.


Code:
Melee Initialization
Events
Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
Conditions
Actions
Set chatnumber = (Entered chat string)
Set Number = (Integer(chatnumber))

The event detects, any chat (keep in mind with any I mean anything that is written, so you might want to toy around with that)

The first variable is a string variable, to save what has been written, the second is an integer variable, that converts the string to an actual number.




hmmm. im afraid im not fully getting it. here's what i made:


Code:
Untitled Trigger 001
Events
Player - Player 1 (Red) types a chat message containing -L1 as A substring
Player - Player 1 (Red) types a chat message containing -L2 as A substring
Player - Player 1 (Red) types a chat message containing -L3 as A substring
Conditions
Actions
Set stringvariable = (Entered chat string)
Set numbervariable = (Integer(stringvariable))
Game - Display to (All players) the text: (String(stringvariable))

but all this displays is 0, when -L1/2/3 has been entered

edit:

okay, i sort of fixed it...


Code:
Untitled Trigger 001
Events
Player - Player 1 (Red) types a chat message containing 1 as A substring
Player - Player 1 (Red) types a chat message containing 2 as A substring
Player - Player 1 (Red) types a chat message containing 3 as A substring
Conditions
Actions
Set stringvariable = (Entered chat string)
Set integervariable = (Integer(stringvariable))
Game - Display to (All players) the text: (String(integervariable))

but i still need to add an event for each possible number typed. is there no way to like detect any integer chat message? also, this way only numbers can be detected, not -L<number>

im not making myself very clear am i? xD|||If you are trying to allow people to type an amount of lives between 1 and 99 via a chat string, you can use the following code, or something alike.


Code:
Melee Initialization
Events
Player - Player 1 (Red) types a chat message containing <Empty String> as A substring
Conditions
Actions
Set Chatnumber = (Entered chat string)
Set number = (Integer(Chatnumber))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
number Greater than 0
number Less than 100
Then - Actions
Game - Display to (All players) the text: (You typed to set the amount of lives to: + (String(number)))
Else - Actions
Game - Display to (All players) the text: You did not type an...

Explaination:

The event detects if the player has typed anything.

The string is than loaded into a string variable, which is called "Chatnumber" in this case, you can assign your own name to it off course.

The second action, then puts the typed string (that is loaded into the string variable) into a integer variable (a whole number variable).

Then comes the If/then/else action.

The condition checks if the integer value is between 1 (greater than 0) 99 (less than 100).

The then happens when the typed string is between 1 and 99, you can add your actions in there you would like to use to set those lives for that player.

The else, basically informs the player that he/she did not press any value between 1 and 99.

Hope this is clear enough.

No comments:

Post a Comment