Replacing parts of string variables.

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Techno JF

He Who Has Powerful Words
I need to know how to replace parts of string variables with user-defined information. For example, whenever someone kills someone else with a particular weapon, the %k, %o, and %w elements in a string in the weapon's properties are replaced with the killer's name, the victim's name, and the weapon's name. I need a similar construction for my project, and I either need to find a sample of code that does it, or I need someone to tell me how it's done.

I have one theory. In most languages, there is a Mid() function used to return a piece of another string variable. However, there is also a Mid() command in some of these languages that is used to replace that part of the string with some other string content. Does this command exist in UnrealScript?
 

butto

Red Orchestra Coder
Yea, that tutorial on Chimeric should help. You can create your own parser function in UScript quite easily. It is easy to manipulate strings in UScript. In fact, it's easy with the native FString class (the class that Uscript strings get changed into) that they use in C++ too.
 

Techno JF

He Who Has Powerful Words
I'd say it works rather well. My parser function is actually a bit easier to read than the one in that tutorial, so I'm happy with it for now. However, I have some other problems.

First, I have been using the ClientMessage(msg) function to display my message. However, if it's possible, I would prefer to use the style of messaging that is used when an Inventory item is picked up. (i.e. it's displayed across the bottom of the screen.) As best as I can tell, this is also the ClientMessage function, but I can't find any differences between that function and what I'm using.

I was going to ask a question about the ClientPlaySound function, but I got it to work just now.

I'll be back in a minute. I still have a problem with the parsing of numbers in the strings.
 

Techno JF

He Who Has Powerful Words
Oh great. Now my script won't compile for some reason that I've never encountered before. Has anyone ever heard of a compile error that goes like "Unexpected End of File at End of Class"? All I did was export my script (i.e. export changed scripts) and then I get this lunacy when I try to recompile!
 

Techno JF

He Who Has Powerful Words
I'm taking a half-and-half route with this script. I have it open in a text file, and then I paste it into UnrealEd when I get a piece that works out. Since I'm embedding my script into a map right now (for testing purposes), I figure that this is the way to go.

Oh, and because I think you're right, I just put a closing bracket at the end of the script. I don't know why it works, but it does.