| 07-02-2002, 05:00 PM | #1 |
How does a substring works? |
| 07-02-2002, 07:15 PM | #2 |
Erm, it's right in the editor! substring("Grunts stink", 2, 4) = "run" Basically slices a string up into pieces that you want and can use. A little more info: If you're doing string parsing from chat message and you're not sure how long the message is, you can take additional characters that may or may not be there. I tried it with Tex's map (I can't remember the numbers behind your name, sorry!) and it works. player types "time 5" substring(entered string, 6,7) seems to convert fine into integer. Dunno if it'll crash if you try 6,8. 7 might turn out to be the null terminator or \n\r. |
| 07-03-2002, 04:20 AM | #3 |
substring("Grunts stink", 2, 4) = "run" Basically slices a string up into pieces that you want and can use. What value to use for the number? and how do we get "run" form "Grunts stink",2,4 |
| 07-03-2002, 04:26 AM | #4 |
"Grunts stink",2,4 r is the second letter, and n is the fourth. It takes those two letters and everything inbetween them: "Grunts stink",2,4 See "run" in "G-run-t"? |
| 07-03-2002, 04:32 AM | #5 |
How about those with 3 word? E.g in Mr. 123 tower map, "give 5 gold" ,13, 15 and does that interpret to player numbers? |
| 07-03-2002, 04:46 AM | #6 |
Yup. Totally forgot that I already had this in my triggers and didn't need to poke around to get Tex's map working. example: "give 5 gold 4" position 13 in the string is 4 and position 14 is nothing. Hm, wonder why I did 13,15 instead of just 13,14. Anyway, to make sure the user doesn't just type some junk and mess up the trigger, I made conditions to check so after I convert the 13th, 14th, and 15th character to an integer, it's between 1 and 12 (allowable player numbers.) You have to count every character in the string including spaces. |
| 07-03-2002, 04:49 AM | #7 |
Oh, upon sawing the answer, I was wondering where did the 15 character came from! But after pondering for a while, player from 10-12 requires 2 characters! |
