Convert text to string

salem

New Member
Reaction score
3
How do i convert a text to string? There is so built-in function that does this. I'm willing to code a custom script for it but i don't know where to start (I know some C++ but i'm not sure how custom script work in SC2 editor).

Also, is there a way to modify some built-in function definitions ? For example can i modify the funciton Get player name () so that it returns a String in stead of a Text ?
 

Dan

The New Helper.Net gives me great Anxiety... o.O;;
Reaction score
159
You're better off saving all information as a String and then converting it to text whenever necessary from what I have seen and heard. That seems like it would be a very messy function to write at first thought. but maybe you could think of an easier way than what's on my mind atm.
 

DarkRevenant

Mad Scientist
Reaction score
13
As of right now, it seems to be fundamentally impossible. It might even cause desync problems if it somehow was possible.
 

salem

New Member
Reaction score
3
You're better off saving all information as a String and then converting it to text whenever necessary from what I have seen and heard. That seems like it would be a very messy function to write at first thought. but maybe you could think of an easier way than what's on my mind atm.

I though of that, but we can't use any kind of "Text" in any condition (comparison) whatsoever so i won't be able to do any thing with Texts...

I had a system set up to convert the strings to text and then compare the texts , but soon realized that in condition comparisons you can't have texts...
 

SerraAvenger

Cuz I can
Reaction score
234
Always create the texts only when you need them. Texts>strings and cannot be converted back, just like strings>ints and can not be converted downwards (but in very limited circumstances).

Strings are merely the reference based representation of a byte array, texts can have formatting and such.
 
Reaction score
54
You can always use a 128-case switch statement and substrings to convert string to int.

Isn't there any way to retrieve single elements from Text? Parsing it to a string would be trivial then.
 

SerraAvenger

Cuz I can
Reaction score
234
You can always use a 128-case switch statement and substrings to convert string to int.

You can get an integer representation of the string, but "a" is no integer.
On a slightly offtopic note, please convert a five byte string to a SC2 four byte int using your method.

Isn't there any way to retrieve single elements from Text? Parsing it to a string would be trivial then.
Well... "I though of that, but we can't use any kind of "Text" in any condition (comparison) whatsoever so i won't be able to do any thing with Texts..." --salem
 
Reaction score
54
You can get an integer representation of the string, but "a" is no integer.
On a slightly offtopic note, please convert a five byte string to a SC2 four byte int using your method.

Now, now, why would you nicely ask for me to write a long and tedious function if you already know it's going to overflow? You are an evil person! :(
A valid point for my case would be converting "42" to 42, though.


On the brighter side, Blizzard seems to still be implementing new functions with patches. It might not be too late, unless they plan to hold it off for an expansion.

Well... "I though of that, but we can't use any kind of "Text" in any condition (comparison) whatsoever so i won't be able to do any thing with Texts..." --salem

I was thinking more along the lines of a function that takes a Text and an Index as arguments and returns a char.
 

SerraAvenger

Cuz I can
Reaction score
234
Now, now, why would you nicely ask for me to write a long and tedious function if you already know it's going to overflow? You are an evil person! :(
A valid point for my case would be converting "42" to 42, though.

That is because '42' is the string representation of an integer, while 'hello'(<- 5 bytes) isn't.
Just like 'text' might be the text representation of a string, while 'text' is not.

On the brighter side, Blizzard seems to still be implementing new functions with patches. It might not be too late, unless they plan to hold it off for an expansion.
We can always hope.

I was thinking more along the lines of a function that takes a Text and an Index as arguments and returns a char.

Ah. I was thinking you meant substrings, just for texts (which would've returned a text again), and then parsing the string like you would do with the ASCII conversion.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top