I would like to create a system based on chat commands where a player can type something similar to "Give 1 10" where "1" is the player number as it appears in my Leaderboard and "10" is the number of resources sent. This function will give 10 minerals to player 1 and reduce the number of minerals for the triggering player by 10. The point with this system is to allow flexible resource transfers in game, with exact valutes, rather than clicking a unlimited amount of times on the original send button.
I've not yet started or tried to create such a system, because i'm not sure if there is a Condition of some sort that can track the number written in in the chat window. I need something that tracks the number written in the spot where the "10" is, rather than creating 12,000 functions for a game with 12 players that allows each player to send 1-1000 minerals to one of the 12 players.
I need something that can track a number that aren't visible in the event but still are applied in a chat message.
Example:
Event
Game - Player Any Player types a chat message containing "-Give 1(space)", matching Partially
Action
Pick each player in (all players) and do actions
If, then, else
If Conditions
And
(Player (Triggering player) treats player (Picked player) as Ally (Mutual)) == true
Picked player equal to Player 1
(Epic track condition that doesn't only track "Give 1(space)" but also any possible number behind that line)
Then
Player - Modify player (Triggering player) Minerals: Set (Minerals of Triggering player - (Tracked number))
Player - Modify player (Picked player) Minerals: Set (Minerals of Picked player + (Tracked number))
Question: Is there any way to create such a number tracker from a text message?
Game - Player Any Player types a chat message containing "-give", matching Partially
Local Variables
toPlayer = 0 <Integer>
amount = "" <String>
Conditions
(Position of "-give" within (Entered chat string) (Insensitive to case)) == 1
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Substring((Entered chat string), 8, 8)) == " "
Then
Variable - Set toPlayer = (Integer((Substring((Entered chat string), 7, 7))))
Variable - Set amount = (Substring((Entered chat string), 9, (Length of (Entered chat string))))
Else
Variable - Set toPlayer = (Integer((Substring((Entered chat string), 7, 8))))
Variable - Set amount = (Substring((Entered chat string), 10, (Length of (Entered chat string))))
UI - Display (Combine ("Give ", (Text(amount)), " minerals to ", (Text(toPlayer)))) for (All players) to Subtitle area
I'm going to lunch, this might need some error handling. You had the right idea, just need to use a few substring. I also made it so there'd only have to be one trigger.
Game - Player Any Player types a chat message containing "-give", matching Partially
Local Variables
toPlayer = 0 <Integer>
amount = "" <String>
Conditions
(Position of "-give" within (Entered chat string) (Insensitive to case)) == 1
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Substring((Entered chat string), 8, 8)) == " "
Then
Variable - Set toPlayer = (Integer((Substring((Entered chat string), 7, 7))))
Variable - Set amount = (Substring((Entered chat string), 9, (Length of (Entered chat string))))
Else
Variable - Set toPlayer = (Integer((Substring((Entered chat string), 7, 8))))
Variable - Set amount = (Substring((Entered chat string), 10, (Length of (Entered chat string))))
UI - Display (Combine ("Give ", (Text(amount)), " minerals to ", (Text(toPlayer)))) for (All players) to Subtitle area
I'm going to lunch, this might need some error handling. You had the right idea, just need to use a few substring. I also made it so there'd only have to be one trigger.
However, what are these variables below good for that are located at the "else" tab? The first two variables allready tracked the numbers written at 7,7 and 9,(length of (entered chat string). Is it really nessesary to have these numbers changed before the trigger closes each time it's triggered?
Variable - Set ToPlayer = (Integer((Substring((Entered chat string), 7, 8))))
Variable - Set Amount = (Substring((Entered chat string), 10, (Length of (Entered chat string))))
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
I would like to create a system based on chat commands where a player can type something similar to "Give 1 10" where "1" is the player number as it appears in my Leaderboard and "10" is the number of resources sent. This function will give 10 minerals to player 1 and reduce the number of minerals for the triggering player by 10. The point with this system is to allow flexible resource transfers in game, with exact valutes, rather than clicking a unlimited amount of times on the original send button.
I've not yet started or tried to create such a system, because i'm not sure if there is a Condition of some sort that can track the number written in in the chat window. I need something that tracks the number written in the spot where the "10" is, rather than creating 12,000 functions for a game with 12 players that allows each player to send 1-1000 minerals to one of the 12 players.
I need something that can track a number that aren't visible in the event but still are applied in a chat message.
Example:
Event
Game - Player Any Player types a chat message containing "-Give 1(space)", matching Partially
Action
Pick each player in (all players) and do actions
If, then, else
If Conditions
And
(Player (Triggering player) treats player (Picked player) as Ally (Mutual)) == true
Picked player equal to Player 1
(Epic track condition that doesn't only track "Give 1(space)" but also any possible number behind that line)
Then
Player - Modify player (Triggering player) Minerals: Set (Minerals of Triggering player - (Tracked number))
Player - Modify player (Picked player) Minerals: Set (Minerals of Picked player + (Tracked number))
Question: Is there any way to create such a number tracker from a text message?
@Bjorne91: Go
Give Gold
Events
Game - Player Any Player types a chat message containing "-give", matching Partially
Local Variables
toPlayer = 0 <Integer>
amount = "" <String>
Conditions
(Position of "-give" within (Entered chat string) (Insensitive to case)) == 1
Actions
General - If (Conditions) then do (Actions) else do (Actions)
If
(Substring((Entered chat string), 8, 8)) == " "
Then
Variable - Set toPlayer = (Integer((Substring((Entered chat string), 7, 7))))
Variable - Set amount = (Substring((Entered chat string), 9, (Length of (Entered chat string))))
Else
Variable - Set toPlayer = (Integer((Substring((Entered chat string), 7, 8))))
Variable - Set amount = (Substring((Entered chat string), 10, (Length of (Entered chat string))))
UI - Display (Combine ("Give ", (Text(amount)), " minerals to ", (Text(toPlayer)))) for (All players) to Subtitle area
I'm going to lunch, this might need some error handling. You had the right idea, just need to use a few substring. I also made it so there'd only have to be one trigger.
Thank you :) I will have a look on it.
@ Grogian
I just got it working, thank you :)
However, what are these variables below good for that are located at the "else" tab? The first two variables allready tracked the numbers written at 7,7 and 9,(length of (entered chat string). Is it really nessesary to have these numbers changed before the trigger closes each time it's triggered?
Variable - Set ToPlayer = (Integer((Substring((Entered chat string), 7, 8))))
Variable - Set Amount = (Substring((Entered chat string), 10, (Length of (Entered chat string))))