able to convert from 'Object' to 'TPlayer'

BlitzMax Forums/BlitzMax Beginners Area/able to convert from 'Object' to 'TPlayer'

Matt McFarland(Posted 2005) [#1]
Local Player:TPlayer = PlayerList.Last()

What am I doing wrong?


Sean Doherty(Posted 2005) [#2]
You have to caste, for example:

pTSentinel = TSentinel(m_pTSentinelList.Last())

Matt, do you know particles?


Matt McFarland(Posted 2005) [#3]
I know particles, yes..

What is the casting, use TPlayer and PlayerList :)


Sean Doherty(Posted 2005) [#4]
Local Player:TPlayer = TPlayer(PlayerList.Last())

What is a good way to go about creating a warp point (Andromeda Style 2D Top Down).


Matt McFarland(Posted 2005) [#5]
Not sure what you mean?
We can chat via IRC (if you dont have any IRC client go here: http://cgiirc.blitzed.org/ )

channel is #blitzbasic


degac(Posted 2005) [#6]
from what I understand, with the casting you can 'convert' a generic Object (the basic type of Bmax) in another type

Local Player:TPlayer = PlayerList.Last()

must be rewritten linke this

Local Player:TPlayer = Tplayer(PlayerList.Last())

in other words you force bmax to convert the object returned by playerList to an object 'TPlayer'.


taxlerendiosk(Posted 2005) [#7]
The name of a new type also becomes a sort of function. If it is possible to turn an object into that type (casting), it will do so, otherwise it will return Null.