Hello UT friends:
A native project, but I am not familiar with C艹(C++) code .
I want to change a name variable to String, is it possible to create a function in uscript?
Tks
Ag Blue
How Name to String…?
-
- Novice
- Posts: 22
- Joined: Fri Oct 28, 2022 12:46 am
- Personal rank: 10
-
- Average
- Posts: 43
- Joined: Fri Jul 10, 2020 9:22 am
Re: How Name to String…?
Code: Select all
FName SomeName(TEXT("NameContent"));
const TCHAR* s = *SomeName;
// s now contains "NameContent"
Edit: wrapped string literal with TEXT macro.
Last edited by Deaod on Sun Jul 09, 2023 3:27 pm, edited 1 time in total.
-
- Godlike
- Posts: 6438
- Joined: Sun May 09, 2010 6:15 pm
- Location: On the roof.
Re: How Name to String…?
Name to String is simple, more complex is String to Name.
Task StringToName
#1 XC_Engine has this capability.
#2 I wrote such function in UScript inside MapGarbage builder - viewtopic.php?p=142521#p142521
Code: Select all
class MapGarbage expands BrushBuilder;
...
var string tmp, AText;
var name NullName;
...
...
final function name StrToName(string AString)
{
local Name TempName;
tmp = AString;
SetPropertyText("NullName",GetPropertyText("tmp"));
TempName = NullName;
NullName = '';
tmp = "";
return TempName;
}
Task NameToString
Reversal Name to String doesn't need mainly anything - also no C++ is required - this is how Teleporters are linked by builder helping editing.
Code: Select all
...
...
SourceTel.URL = string(TheTeleporter.Tag); //Assign the URL String as the Text format for Tagged Destination.
...
...
And then ? And then you can simply assign String variable from a Name without any function. Core.Object has already this capability.
Another STOCK example is placed in Actor - here were used functions...
Code: Select all
function String GetHumanName()
{
return GetItemName(string(class));
}
Code: Select all
function String GetItemName( string FullName )
{
local int pos;
pos = InStr(FullName, ".");
While ( pos != -1 )
{
FullName = Right(FullName, Len(FullName) - pos - 1);
pos = InStr(FullName, ".");
}
return FullName;
}
-
- Novice
- Posts: 22
- Joined: Fri Oct 28, 2022 12:46 am
- Personal rank: 10