| 04-10-2007, 09:34 PM | #1 |
I've been lingering on my trig editor for about 3 hours now and i still can't figure it out. I want a trigger that would change my kills to win goal (currently 30) into something that a player would want. Example : they typed -kills 50 Then the trigger should change the kill goal(30) to 50. But I just can't! How am I gonna do this? |
| 04-10-2007, 09:39 PM | #2 |
example: Trigger: *my editor displays that in german ..i translated it ...maybe wrong -.- |
| 04-10-2007, 09:42 PM | #3 |
Set the number of kills required to a variable, and just change it when a player types a message. Example: |
| 04-10-2007, 09:45 PM | #4 |
say what? Some of it didn't make sense... |
| 04-10-2007, 09:45 PM | #5 |
Basically that, except make sure that kills is in the proper location: Trigger: Conditions![]() Substring((Entered Chat String), 1, 7 equals -kills ) <-- space at the endSo the entire script is |
| 04-10-2007, 09:50 PM | #6 |
But it has a value thingy on the end of the line? Set Kills[(Integer((Substring((Entered chat string), 30, (Length of (Entered chat string))))))] = Value What do i put? I don't even know if I did the script right... |
| 04-10-2007, 09:53 PM | #7 | |
you have not told us that your kills variable is an array ...what is supposed to be its index ? (the value should be its current array index ...) @Pyrogasm and Ammorth is much cooler*
|
| 04-10-2007, 09:53 PM | #8 |
Array 12 |
| 04-10-2007, 10:04 PM | #9 | |
To be honest, you're not even close. Here's an explaination of the "substring" function: It returns part of a string, so Substring((Darth Vader) 2, 4) would return "art", because "art" is what is from the 2nd to 4th character in "Darth Vader". Likewise, Substring((-kills 65) 8, 9) would return the string "65". Now, we have to convert that to an integer to use as a kill count: Integer(Substring((-kills 65) 8, 9)). Then we only have to set your killcount variable equal to that. To make it work for whatever is typed after "-kills " (with the space, as Ammorth said), we'll have to modify which string is evaluated and what substring gets turned into an integer, because Integer(Substring((-kills 6585) 8, 9)) would still return 65. Thus, we use the Length of (Entered Chat string) function, like so: Integer(Substring((Entered chat string) 8, (Length of (Entered Chat String)))) Note that the "8" doesn't change, since the start of the number is always the 8th character. We'll also want to make sure that the new number isn't 0, so we'll add that in Here's what your full trigger would look like: Trigger: Quote:
|
| 04-10-2007, 10:16 PM | #10 |
Do i Make another variable? TempInt? Cuz when I use Kills I get that value at the end again... |
| 04-10-2007, 10:24 PM | #11 | |
Quote:
i know that ...i could add irony tags in the future xD but i tought "^^" would express the irony quite well ^^ Nevertheless it will not "ensure that the command will still work if someone forgets to type the space" since we have Code:
...that contains -kills as a substring [b]<NOTE THE EXTRA SPACE AFTER "-kills">[/b] and Substring((Entered Chat String), 1, 7) equals "-kills " |
| 04-10-2007, 10:32 PM | #12 |
So at the value i need to put -kills? God it's only GUI and it hurts my head. Wonder how bad I'll fare in JASS... Could someone pleaaase explain this to me in a transparently clear manner? BTW: Nobody answered my Do i need to make a tempint variable question... |
| 04-10-2007, 10:34 PM | #13 |
| 04-10-2007, 10:49 PM | #14 |
The problem, akolyt0r, is: what if someone doesn't type a number after it? If someone types "-kills OMGIMANUB", It will set "kills" equal to 0. That's what TempInt is for. If it's going to set the kills to 0, it catches it and doesnt. Oh, and I know that by changing what the entered chat string is, it removes the "forgot the space" failsafe, but that was just an explaination :D EDIT: Oh. Why didn't I think of putting it in the condition? >< |
| 04-10-2007, 10:56 PM | #15 |
Yeah ...its a quite common mistake ^^ |
