Jojonew wrote: ↑Sat Jul 08, 2023 3:19 pm
I want to change a name variable to String, is it possible to create a function in uscript?
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;
}
I do not need C++ for such a simple task - EPIC already have samples in
Teleporter.uc about probing matches.
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.
...
...
Doing these because Tag of Destination is a "Name" type, and URL is a "String" type, but they have similar TEXT as data.
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));
}
because
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;
}
This is how it was originally dodged as
NameToString.