NewsUnrealEdFilesModsFragBULiandri Archives
BeyondUnreal Forums

Go Back   BeyondUnreal Forums > Unreal Development > Coding

Reply
 
Thread Tools Display Modes
Old 5th Oct 2003, 05:55 PM   #1
Dark[NSF]
Northwest Secessionalist Forces
 
Dark[NSF]'s Avatar
 
Join Date: Mar. 12th, 2003
Location: Melbourne, Florida
Posts: 632
Sarcastic typecasting ;(

How would I get my custom PlayerController class from Pawn?


Pawn.Controller(nsfplayer).blah blah?

Controller(nsfplayer.pawn).blah blah?

I'm lost, I would love some help
__________________
http://www.ReignofMilitias.com

webevolved.com || ICQ: 96970935
Dark[NSF] is offline   Reply With Quote
Old 5th Oct 2003, 11:30 PM   #2
JamesKilton
UA Coder
 
JamesKilton's Avatar
 
Join Date: Oct. 6th, 2002
Location: Everywhere and Nowhere
Posts: 210
You've got it flipped. it's:

nsfplayer(Pawn.Controller).foo;

nsfplayer(Controller).foo;

etc.
JamesKilton is offline   Reply With Quote
Old 6th Oct 2003, 02:57 AM   #3
Wormbo
 
 
Wormbo's Avatar
 
Join Date: Jun. 4th, 2001
Location: Germany
Posts: 5,750
Typecasting always works like this:

ClassToTypecastTo(ObjectToTypecast).PropertyToAccess

or

ClassToTypecastTo(ThingToGetObjectFrom.ObjectToTypecast).PropertyToAccess
__________________
Wormbo's UT/UT2004/UT3 mods | YouTube channel | PlanetJailbreak/JDN | Unreal Wiki | Liandri Archives
Everything you ever wanted to know about replication| UnrealScript security considerations
<elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
<TNSe> nono
<TNSe> its always funny to find code a week later you dont even remember writing
<Pfhoenix> what's worse is when you have a Star Wars moment
<Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
Wormbo is offline   Reply With Quote
Old 6th Oct 2003, 10:25 PM   #4
clam
Registered User
 
Join Date: Jul. 24th, 2003
Posts: 47
Wormbo that's the best explanation of typecasting ever
clam is offline   Reply With Quote
Old 7th Oct 2003, 05:25 AM   #5
Evil-Devil
silence
 
Evil-Devil's Avatar
 
Join Date: Jun. 17th, 2002
Location: somewhere in Germany
Posts: 74
Quote:
Originally Posted by Wormbo
Typecasting always works like this:
ClassToTypecastTo(ObjectToTypecast).PropertyToAccess
or
ClassToTypecastTo(ThingToGetObjectFrom.ObjectToTypecast).PropertyToAccess
Just need some little explanation.
I got two classes. One is SC_Crystal and the other SC_Blue_Crystal. The blue crystal one is a subclass of crystal. and two references. one called just crystal, and the other blue_crystal.
no i take a for loop through the navigiationpointlist and check if there is one of my crystals or blue ones

Code:
[...]
// NP is the reference to NavigationPoint
// if...found crystal -> works
Crystal = SC_Crystall(NP);

// if...found blue crystal --> works
Blue_Crystal = SC_Blue_Crystal(NP);

// if found blue crystal (another bsp) -> wont works
Blue_Crystal = SC_Crystal(NP);
[...]
Can i only cast objects which belongs to their reference? cause the third cast doesn´t work as shown in the comment.

Just want to know why.

Evil
Evil-Devil is offline   Reply With Quote
Old 7th Oct 2003, 05:30 AM   #6
Wormbo
 
 
Wormbo's Avatar
 
Join Date: Jun. 4th, 2001
Location: Germany
Posts: 5,750
The cast itself works well, the compiler moans about a different problem: You can only assign objects of the same class or a sbuclass to a variable.
Your Crystal variable can hold any SC_Crystal and any subclass of it, like SC_Blue_Crystal, but you can't assign an SC_Crystal to the Blue_Crystal variable because it's not a subclass of SC_Blue_Crystal.
__________________
Wormbo's UT/UT2004/UT3 mods | YouTube channel | PlanetJailbreak/JDN | Unreal Wiki | Liandri Archives
Everything you ever wanted to know about replication| UnrealScript security considerations
<elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
<TNSe> nono
<TNSe> its always funny to find code a week later you dont even remember writing
<Pfhoenix> what's worse is when you have a Star Wars moment
<Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
Wormbo is offline   Reply With Quote
Old 7th Oct 2003, 10:13 AM   #7
Evil-Devil
silence
 
Evil-Devil's Avatar
 
Join Date: Jun. 17th, 2002
Location: somewhere in Germany
Posts: 74
ok, thats clear to me. but in the first tries i also tried to set Crystal = SC_Blue_Crystal(NP) and it even gives me an access none. weird, isn´t it?
Evil-Devil is offline   Reply With Quote
Old 7th Oct 2003, 10:43 AM   #8
Wormbo
 
 
Wormbo's Avatar
 
Join Date: Jun. 4th, 2001
Location: Germany
Posts: 5,750
Quote:
Originally Posted by Evil-Devil
ok, thats clear to me. but in the first tries i also tried to set Crystal = SC_Blue_Crystal(NP) and it even gives me an access none. weird, isn´t it?
That statement can't give any Accessed Nones directly, only if NP isn't an SC_Blue_Crystal. If NP is an SC_Crystal (i.e. not an SC_Blue_Crystal) the typecasting result is None, which gets assigned to Crystal.
__________________
Wormbo's UT/UT2004/UT3 mods | YouTube channel | PlanetJailbreak/JDN | Unreal Wiki | Liandri Archives
Everything you ever wanted to know about replication| UnrealScript security considerations
<elmuerte> you shouldn't do all-nighters, it's a waste of time and effort
<TNSe> nono
<TNSe> its always funny to find code a week later you dont even remember writing
<Pfhoenix> what's worse is when you have a Star Wars moment
<Pfhoenix> "Luke! I am your code!" "No! Impossible! It can't be!"
Wormbo is offline   Reply With Quote
Old 7th Oct 2003, 10:50 AM   #9
Evil-Devil
silence
 
Evil-Devil's Avatar
 
Join Date: Jun. 17th, 2002
Location: somewhere in Germany
Posts: 74
Hmm, k. And thx for explenation.
Evil-Devil is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 02:50 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.

Copyright ©1998 - 2012, BeyondUnreal, Inc.
Privacy Policy | Terms of Use
Bandwidth provided by AtomicGamer