type stuff

Blitz3D Forums/Blitz3D Beginners Area/type stuff

Ruz(Posted 2003) [#1]
how do i refer to a type from outside the type
ie

shadowpiv=CreatePivot()
EntityParent shadowpiv,p\model

this returns an error, 'variable must be a type'


the p\model is from the type
below

Function CreatePlayer.Player( x#,y#,z# )
p.Player=New Player
p\entity=CreatePivot()
p\model=CopyEntity( player_model,p/entity )
p\player_y=y
p\walk=walk
p\jump=jump
p\still=still
PositionEntity p/entity,x,y,z
EntityType p\entity,TYPE_PLAYER
EntityRadius p\entity,1.7
ResetEntity p\entity
Return p

End Function


skidracer(Posted 2003) [#2]
You are still using the divide operator (p/model) instead of the field separator (p\model).


Ruz(Posted 2003) [#3]
ahh, thats cause the backslash was coming out as a weird 'w' character in the web browser.Changed the above now

(my code is typed the correct way in blitz BTW)

If that was my error it would have returned an arithmetic operator error.


skidracer(Posted 2003) [#4]
Ah, yes sorry I got confused.

In your code above the p.Player variable is local to the function so is unknown outside the "scope" of the function.

However you are returning the p.Player type handle from your function so from the main body of your code if you want a variable to track this particular instance created by the function you go:

myplayer.Player=CreatePlayer(...)

which means myplayer will point to the same type you created and were manipulating with the local p variable inside the function

you can then access the type's fields from the main program using:

myplayer\model


Ruz(Posted 2003) [#5]
ahh cool, thanks
there was this in the code( which i borrowed from the castle demo)

Player1.Player=CreatePlayer( -20,0,0 )

Obviously I was using the wrong syntax to try and call from the type. i think i tried something like player1\p\model