ucc rejects hyphen in name

Discussions about Coding and Scripting
Post Reply
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

ucc rejects hyphen in name

Post by Barbie »

Often I have the server patching a map on the fly while loading. Now I stumbled over a Tag the mapper has set to "BOATRIDE-LOCKIN". If I feed the compiler with the following code

Code: Select all

foreach AllActors(class 'Actor', A, 'BOATRIDE-LOCKIN')
the compiler says "Error, Illegal character in name" although the editor and the wiki accept hyphens as part of a Name.
declaration of AllActors

Code: Select all

native(304) final iterator function AllActors ( class<actor> BaseClass, out actor Actor, optional name MatchTag );
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: ucc rejects hyphen in name

Post by sektor2111 »

Should not check TAG then, or a string check would be needed...

Code: Select all

var name ThatBadTag;

ThatBadTag='Some-Hypens-Trash';
/*
SetPropertyText...
ConsoleCommand...
*/
foreach AllActors(..,.., ThatBadTag )
...
I would try a different way.
User avatar
Chamberly
Godlike
Posts: 1963
Joined: Sat Sep 17, 2011 4:32 pm
Personal rank: Dame. Vandora
Location: TN, USA
Contact:

Re: ucc rejects hyphen in name

Post by Chamberly »

Did you try UCC2? Just wondering if that make any result.
Image
Image
Image Edit: Why does my sig not work anymore?
Higor
Godlike
Posts: 1866
Joined: Sun Mar 04, 2012 6:47 pm

Re: ucc rejects hyphen in name

Post by Higor »

It's the script compiler.
The compiler would need to be rebuilt, otherwise resort to workarounds like preallocating the name elsewhere or generating it in runtime using a string method.
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: ucc rejects hyphen in name

Post by sektor2111 »

You can fool UCC after all...

Code: Select all

class TheStart expands Mutator config;

var config float stDelay;
var config bool bStartGames;
var String Map;
var bool bFirstTime, bCheckedMap;
var name Badie;
....
event Timer()
{
	local Pawn P;
	local StatLog SL;
	local Actor A;
...
	SetPropertyText("Badie","Ugly-Tag");
	log (Badie);
	foreach AllActors (class 'Actor',A,Badie)
	{
		log ("Found badie, yo...");
	}
...
Then log says:
  • ScriptLog: UT-Logo-Map.Ticker0 > Ideal Tick Interval has been computed at 36
    ScriptLog: Liche has new score.
    ScriptLog: Ugly-Tag
    ScriptLog: Game ended at 9.623474
    ScriptLog: !!!!!!!!!!!!!!! CALC END STATS
I'm not sure if you need to call a string directly.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: ucc rejects hyphen in name

Post by Barbie »

Thanks for the solutions; that additional name tag in "ForEach AllActors" is just used to make the search faster and can be left out without worries. (I run into that string -> name type casting problem earlier already; your solution is described in the wiki also.)
Higor wrote:It's the script compiler. The compiler would need to be rebuilt
Can I rebuild UCC with UCC? ^^
Chamberly wrote:Did you try UCC2?
Just did it with UCC2_2 - same error.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
sektor2111
Godlike
Posts: 6403
Joined: Sun May 09, 2010 6:15 pm
Location: On the roof.

Re: ucc rejects hyphen in name

Post by sektor2111 »

Yes tagged iterator is used even at monsters triggering events and actors generally - and they do work called indirectly VIA variables, aside for this subject I really did not check Wiki, sometimes I'm pissed off by NONE info and examples, or bad Info, maybe Gusty can fix it speaking about NavigationPoints-Keypoints etc :ironic: or some new U2-U1 morphing solution.
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: ucc rejects hyphen in name

Post by Wormbo »

While name values may contain all kinds of awkward characters, name literals may not. That simple.
You can enter pretty much anything in the editor's text box or a defaultproperties section (by giving a string literal), but name literals may only contain standard identifier characters, although (unlike actual identifiers) they may begin with a digit.

Easiest non-hack solution:

Code: Select all

var name FooTag;

// ...

foreach AllActors(class'Foo', FooActor, FooTag) {
  // ...
}

// ...

defaultproperties
{
  FooTag="Tag-With-Hyphens"
}
(Note the double quotes.)

The next best thing (if you need dynamically created names) would be the SetPropertyText() hack as described by sector above, but that's about it.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: ucc rejects hyphen in name

Post by Barbie »

Wormbo wrote:While name values may contain all kinds of awkward characters, name literals may not. That simple.
:shock:
Whow, thanks - that made me really head shaking. A data type is a data type is a ... oh wait. Not this one.
(Let's compare it to data type byte: it can contain numbers between 0 and 255, but you are allowed to assign values from 0 to 99 literally only?)
Is there any reasonable reason for this behaviour? Except less work for the programmer of the parser code?
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
User avatar
Wormbo
Adept
Posts: 258
Joined: Sat Aug 24, 2013 6:04 pm
Contact:

Re: ucc rejects hyphen in name

Post by Wormbo »

Barbie wrote:
Wormbo wrote:While name values may contain all kinds of awkward characters, name literals may not. That simple.
:shock:
Whow, thanks - that made me really head shaking. A data type is a data type is a ... oh wait. Not this one.
(Let's compare it to data type byte: it can contain numbers between 0 and 255, but you are allowed to assign values from 0 to 99 literally only?)
Is there any reasonable reason for this behaviour? Except less work for the programmer of the parser code?
It's a parser thing. Well, actually a tokenizer thing. The UnrealScript compiler never was great in terms of consistency. The defaultproperties block is not even UnrealScript code, but T3D content, so allowing strings as name values there doesn't tell anything about name literals in UnrealScript. (There's no separate name literal in T3D files.)

I think it is safe to assume that names weren't intended to contain all possible weird stuff in the context of the UnrealScript language. Every class, variable and function you declare also becomes a name, and you are restricted to identifiers there. So if you spawn an actor from UnrealScript, there's hardly any chance to give it a weird tag - and thus not much reason to allow anything different for other places where names could be used. In fact, the way the tokenizer needs to decide between name literals and object literals is quite fragile. (It's also the reason nobody will ever write a syntax highlighter that is 100% precise, as it simply can't know about all valid class names. That's a requirement for correctly distinguishing between a simple identifier followed by a name literal and an object literal.)

BTW: The UnrealScript compiler also has a pretty peculiar way to parse numbers. Try figuring it our yourself - what will the following code output? (I'm pretty sure it will compile, even if parts of it looks weird.)

Code: Select all

log(0123456789abcedfx);
log(123456789abcedfx);
log(0123456789abcedf);
log(123456789abcedf);
log(0123456789abcedf.x);
log(123456789abcedf.x);
log(0123456789abced.f);
log(123456789abced.f);
log(0123456789abced.fx);
log(123456789abced.fx);
log(012e3);
log(12e3);
log(1.2e+3);
log(1.2d3);
log(1.2a3);
log(1.2x3);
tl;dr: There's no reason, except sloppy parser code.
User avatar
Barbie
Godlike
Posts: 2792
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: ucc rejects hyphen in name

Post by Barbie »

Thanks for putting some lights here. :)
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Post Reply