Retrieving the package name of an Actor
Retrieving the package name of an Actor
How to get the package name an Actor is defined in?
Examples:
Actor 'Botpack.UT_Eightball' -> 'Botpack' is needed
Actor 'UnrealShare.DispersionPistol' -> 'UnrealShare' is needed
Examples:
Actor 'Botpack.UT_Eightball' -> 'Botpack' is needed
Actor 'UnrealShare.DispersionPistol' -> 'UnrealShare' is needed
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
-
- Inhuman
- Posts: 958
- Joined: Wed Mar 31, 2010 9:02 pm
- Personal rank: I am quite rank.
- Location: MrLoathsome fell out of the world!
Re: Retrieving the package name of an Actor
I think all you have to do is parse Actor.Self
*Or maybe Actor.Self.Class
** Or maybe Actor.Self.Class.Outer
*Or maybe Actor.Self.Class
** Or maybe Actor.Self.Class.Outer
Last edited by MrLoathsome on Sun Jun 12, 2016 9:32 am, edited 2 times in total.
blarg
Re: Retrieving the package name of an Actor
ucc.exe wrote:Error, Unrecognized member 'self' in class 'Actor'
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
-
- Inhuman
- Posts: 958
- Joined: Wed Mar 31, 2010 9:02 pm
- Personal rank: I am quite rank.
- Location: MrLoathsome fell out of the world!
Re: Retrieving the package name of an Actor
Whoops. I left off a bit, (.Class), as I was going by memory when I posted that. And was sort of posting pseudo-code.
(I thought you guys would figure that out.... )
Here is a tested example.
This line of code in a mutator actor class named SwarmSpawn.SS:
Will result in this log line:
You should be able to parse that somehow....
Unless I am not understanding your question completely.
In which case, ignore all of the above.
(I thought you guys would figure that out.... )
Here is a tested example.
This line of code in a mutator actor class named SwarmSpawn.SS:
Code: Select all
log(Self.Class);
Code: Select all
ScriptLog: SwarmSpawn.SS
Code: Select all
Self.Class
Unless I am not understanding your question completely.
In which case, ignore all of the above.
Last edited by MrLoathsome on Sun Jun 12, 2016 7:02 am, edited 4 times in total.
blarg
-
- Inhuman
- Posts: 958
- Joined: Wed Mar 31, 2010 9:02 pm
- Personal rank: I am quite rank.
- Location: MrLoathsome fell out of the world!
Re: Retrieving the package name of an Actor
W.T.F. does that mean?Higor wrote:Do not bother for he who does not bother.
blarg
- sektor2111
- Godlike
- Posts: 6410
- Joined: Sun May 09, 2010 6:15 pm
- Location: On the roof.
Re: Retrieving the package name of an Actor
I have something but I'm not sure how well does it work from inside of an iterator (any) because simply STRINGS operations are like a doggy slow. Something in engine rejects such a "lag" crap. Look at GetItemName and do some modifications. Mutator calling that thing a single time return good results. If gets called from PawnList or Foreach looks garbled...
Look at a log operated by a small mutator + trying to retrieve package for a few monsters - looks nasty:
The only good thing was Mutator itself, the rest is trash.
Aside, I was wonder why do you need that, I did not see many coders using craps slowing down servers. Like I said you have a "string" problem which is not a charm in UnrealEngine.
Gotta do more research... I'll be back.
Edit: See this - simply is garbled or I don't have a clue how to speed it up. Mutator responds well but not really the restENJOY
Look at a log operated by a small mutator + trying to retrieve package for a few monsters - looks nasty:
Code: Select all
ScriptLog: GetPackageOrigin:: for Behemoth3
ScriptLog: Behemoth3 belongs to package
ScriptLog: GetPackageOrigin:: for Behemoth2
ScriptLog: Behemoth2 belongs to package
ScriptLog: GetPackageOrigin:: for Behemoth1
ScriptLog: Behemoth1 belongs to package
ScriptLog: GetPackageOrigin:: for Behemoth0
ScriptLog: Behemoth0 belongs to package
ScriptLog: GetPackageOrigin:: UNREAL for Gasbag0
ScriptLog: Gasbag0 belongs to package UNREAL
ScriptLog: GetPackageOrigin:: LOGGER_A for Informer0
ScriptLog: Informer0 belongs to package LOGGER_A
Aside, I was wonder why do you need that, I did not see many coders using craps slowing down servers. Like I said you have a "string" problem which is not a charm in UnrealEngine.
Gotta do more research... I'll be back.
Edit: See this - simply is garbled or I don't have a clue how to speed it up. Mutator responds well but not really the rest
Spoiler
class Informer expands mutator;
var DeathMatchPlus MyGame;
var bool Initialized;
function PostBeginPlay()
{
if (Initialized)
return;
Initialized = True;
Level.game.registerdamagemutator(Self);
Level.game.registermessagemutator(Self);
log ("A test mutator has been initiated...");
MyGame = DeathMatchPlus(Level.Game);
SetTimer(5,True);
}
function CallManure()
{
Local ScriptedPawn S;
Local Pawn P;
Local String Strg;
for ( P=Level.PawnList; P!=None; P=P.nextPawn )
{
if ( ScriptedPawn(P) != None && P.Health > 0 )
{
S=ScriptedPawn(P);
strg=GetPackageOrigin(S);
log(S.Name@"belongs to package"@strg);
}
}
strg=GetPackageOrigin(Self);
log (Self.Name@"belongs to package"@strg);
}
event Timer()
{
CallManure();
}
function String GetPackageOrigin(Actor AnActor)
{
Local string FullName, Temp;
Local int pos;
Temp="None";
if (AnActor == None) return Temp;
FullName="";
pos=0;
FullName=CAPS(AnActor.Class);
pos = InStr(FullName, ".");
StillMove:
if ( pos != -1 )
{
FullName = Left(FullName, Len(FullName) - pos - 1);
pos = InStr(FullName, ".");
Goto StillMove;
}
log ("GetPackageOrigin::"@FullName@"for"@AnActor.Name);
return FullName;
}
var DeathMatchPlus MyGame;
var bool Initialized;
function PostBeginPlay()
{
if (Initialized)
return;
Initialized = True;
Level.game.registerdamagemutator(Self);
Level.game.registermessagemutator(Self);
log ("A test mutator has been initiated...");
MyGame = DeathMatchPlus(Level.Game);
SetTimer(5,True);
}
function CallManure()
{
Local ScriptedPawn S;
Local Pawn P;
Local String Strg;
for ( P=Level.PawnList; P!=None; P=P.nextPawn )
{
if ( ScriptedPawn(P) != None && P.Health > 0 )
{
S=ScriptedPawn(P);
strg=GetPackageOrigin(S);
log(S.Name@"belongs to package"@strg);
}
}
strg=GetPackageOrigin(Self);
log (Self.Name@"belongs to package"@strg);
}
event Timer()
{
CallManure();
}
function String GetPackageOrigin(Actor AnActor)
{
Local string FullName, Temp;
Local int pos;
Temp="None";
if (AnActor == None) return Temp;
FullName="";
pos=0;
FullName=CAPS(AnActor.Class);
pos = InStr(FullName, ".");
StillMove:
if ( pos != -1 )
{
FullName = Left(FullName, Len(FullName) - pos - 1);
pos = InStr(FullName, ".");
Goto StillMove;
}
log ("GetPackageOrigin::"@FullName@"for"@AnActor.Name);
return FullName;
}
Re: Retrieving the package name of an Actor
Not None-safe: (logs two warnings for None input, but returns correct value)
None-safe version:
This works because all objects have a class and classes are always directly located in a top-level package.
Code: Select all
function String GetPackageOrigin(Actor AnActor)
{
return string(anActor.Class.Outer);
}
Code: Select all
function String GetPackageOrigin(Actor anActor)
{
if (anActor == None)
return string(None);
return string(anActor.Class.Outer);
}
- sektor2111
- Godlike
- Posts: 6410
- Joined: Sun May 09, 2010 6:15 pm
- Location: On the roof.
Re: Retrieving the package name of an Actor
Small errata
But I have to try other options of course.
But related to Wormbo's suggestion I think I got an idea for my MHReplacer...
Code: Select all
function String GetPackageOrigin(Actor AnActor)
{
Local string FullName, Temp;
Local int pos;
Temp="None";
if (AnActor == None) return Temp;
FullName="";
pos=-1;
FullName=CAPS(AnActor.Class);
log (FullName);
pos = InStr(FullName, ".");
log (pos);
if ( InStr(FullName, ".") > 0 )
{
FullName=Left(FullName, InStr(FullName, "."));
}
log ("GetPackageOrigin::"@FullName@"for"@AnActor.Name);
return FullName;
}
But related to Wormbo's suggestion I think I got an idea for my MHReplacer...
Re: Retrieving the package name of an Actor
Let me translate:MrLoathsome wrote:W.T.F. does that mean?Higor wrote:Do not bother for he who does not bother.
Don't bother helping someone who does not bother to understand. In this case barbie was joking, Higor knows that, therefore Higor is joking too.
-
- Inhuman
- Posts: 958
- Joined: Wed Mar 31, 2010 9:02 pm
- Personal rank: I am quite rank.
- Location: MrLoathsome fell out of the world!
Re: Retrieving the package name of an Actor
I hope so. Otherwise my next reply to Higor was gonna get me kicked off the forum.Chris wrote:Let me translate:MrLoathsome wrote:W.T.F. does that mean?Higor wrote:Do not bother for he who does not bother.
Don't bother helping someone who does not bother to understand. In this case barbie was joking, Higor knows that, therefore Higor is joking too.
I like Wormbo's response better.
It extends my 2nd, more detailed post.
@Sektor. Nice job on re-inventing the ".Outer" wheel.
Exactly what I had in mind when I was suggesting parsing Actor.Class
In matters such as this, we should ALL just wait a bit to see what Wormbo has to say about it.
blarg
Re: Retrieving the package name of an Actor
That was it, thanks. I was already on the track with "Outer" but "anActor.Outer" returns the map name only.Wormbo and MrLoathsome wrote:anActor.Class.Outer
I want to replace some non stock items. Detecting if an item belongs to a class can usually be done by »ThisActor.IsA('WhatEver')« or »WhatEver(ThisActor) != None«, but then the server and the clients have to include the foreign package for all maps just to get rid of some items in a single map. So I decided to identify these items by their class name with »if (ThisActor.Class.Name == 'WhatEver')«. But what happens, if items of another package has the same class name? Then this method may detect wrong items and so I want to make sure that the item of interest belongs to the package XYZ:sektor2111 wrote:Aside, I was wonder why do you need that
Code: Select all
if (ThisActor.Class.Name == 'WhatEver' && String(ThisActor.Class.Outer) == "xyz")
Yep, the theory of everything isn't fully developed yet:sektor2111 wrote:Like I said you have a "string" problem
But seriously, I have no idea what you mean by this.
<EDIT>
added string typecasting to "ThisActor.Class.Outer"
</EDIT>
Last edited by Barbie on Sun Jun 12, 2016 5:47 pm, edited 1 time in total.
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
- sektor2111
- Godlike
- Posts: 6410
- Joined: Sun May 09, 2010 6:15 pm
- Location: On the roof.
Re: Retrieving the package name of an Actor
Because you can spy "Other.Class" if "left" from "string class" whatever letters match some evil creature just put it down... that is easy. Btw formula above I guess can save AttitudeToPlayer right ?
Now The Credit Section
Because you set me on a research I could figure some things today... that's another story off topic here... I have to rewrite a few things at my MH2 then...
Now The Credit Section
Because you set me on a research I could figure some things today... that's another story off topic here... I have to rewrite a few things at my MH2 then...
If you check well the last one shown by me is able to get package-name even from current class ( mutator itself or whatever ) - credit goes at LoathSome (or Core ?) - stuff already done...MrLoathsome wrote: @Sektor. Nice job on re-inventing the ".Outer" wheel.
Re: Retrieving the package name of an Actor
Whoo, its even simpler then:sektor2111 wrote:Because you can spy "Other.Class"
Code: Select all
if (String(A.class) == "PackageName.Classname")
"Multiple exclamation marks," he went on, shaking his head, "are a sure sign of a diseased mind." --Terry Pratchett
Re: Retrieving the package name of an Actor
See, that's why you state your root intent, not the problem you ran into while pursuing one particular approach of which you don't even know whether it will actually solve your problem.