- Joined
- Nov 30, 2007
- Messages
- 1,202
What happens is that the system splits up a chat string into an array of strings "words" but I want to replace this array of string with array of start and end positions as integers are much smaller to store and I am already saving the entire chat string.
So to remove this duplication of data I wanted to use opreators. But I can't quite figure out how to write them. I'm also trying to avoid regular methods here.
Here is psuedo code I wrote on notepad (since WEX is on vacation, and I got no other tool to write jass in...)
Hope it was clear what I want to achieve.
So to remove this duplication of data I wanted to use opreators. But I can't quite figure out how to write them. I'm also trying to avoid regular methods here.
Here is psuedo code I wrote on notepad (since WEX is on vacation, and I got no other tool to write jass in...)
JASS:
struct PlayerChat
string chatStr
string word[100] // I want to replace this
integer wordStart[100] // With this
integer wordEnd[100] // While still keeping the syntax that i had before: playerChat.word[n]
method operator word[] takes integer index returns string
return SubString(.chatStr, wordStart[index], wordEnd[index])
endmethod
methd operator wordLength[] takes integer index returns integer
return .wordEnd[index] - .wordStart[index]
endmethod
method oprator wordLower[] takes integer index returns string
return StringCase(SubString(.chatStr, .wordStart[index], .wordEnd[inde]), false)
endmethod
So the syntax I'm trying to acomplish here is:
playerchat.word[3]
playerchat.wordLength[3]
playerchat.wordStart[3] // Already exists
playerchat.wordEnd[3] // Already exits
playerchat.wordLower[3]
playerchat.wordUpper[3]
endstruct
Hope it was clear what I want to achieve.
Last edited: