Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → GetLocalPlayerThing + GetThingSector usage
GetLocalPlayerThing + GetThingSector usage
2006-05-23, 3:27 PM #1
I posted this at the hub, but there's like 20 different forums, so on the off chance anybody reads this thread:

Code:
# Change to a different camera when the player enters the sector 


//flags=0x240 

symbols 

thing       camera1                          
thing       camera2               
int         kyle 

message     entered 
sector      room2 
sector       room1 
end 

# ================================================================== 

code 

entered: 
    
   kyle == GetLocalPlayerThing(); 
   PrintInt(kyle); 

   if(GetThingSector(0) == room2) 
   { 
      SetCurrentCamera(0); 
      SetCameraFocus(0, camera1); 
   } 
   return; 
    
end 
 


I think I'm confused about GetLocalPlayerThing and GetThingSector. GetLocalPlayerthing returns an integer value, right? 0 is the number of the walkplayer thing, but I'm still not getting any love with the camera changing.

The goal is to change the cameras when the player enters a sector.
COUCHMAN IS BACK BABY
2006-05-23, 7:02 PM #2
Faulty coding. Walkplayer is not 0, apparently.

Try this code:

Code:
flags=0x240 

symbols 
thing           camera1                          
thing           camera2               
int               player 

message     entered 
sector          room2
sector          room1 
end 

# ========================================================

code 

entered: 
    
   player = GetLocalPlayerThing();  //THIS, was a boolean, not an assignment.
   PrintInt(player);

   if(GetThingSector(player) == room1){    //Shouldn't assume player = 0.
      if(GetCurrentCamera() != 0){
         CycleCamera(); 
      SetCameraFocus(0, camera1); 
   }else if(GetThingSector(player) == room2){ 
      if(GetCurrentCamera() != 0){
         CycleCamera(); 
      SetCameraFocus(0, camera2); 
   }
   return; 
end
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2006-05-23, 9:27 PM #3
Thanks, that did it. It didn't work at first, but when I made these alterations it was fine:

Code:
   if(GetThingSector(player) == room1){    //Shouldn't assume player = 0.
      //if(GetCurrentCamera() != 0){
         //CycleCamera(); 
      SetCurrentCamera(0);
      SetCameraFocus(0, camera2); 
   }else if(GetThingSector(player) == room2){ 
      //if(GetCurrentCamera() != 0){
         //CycleCamera(); 
    SetCurrentCamera(0);  
    SetCameraFocus(0, camera1); 
"Time is an illusion. Lunchtime doubly so."
2006-05-23, 9:28 PM #4
Er, that was Tracer. I forgot to log this account out.
"Time is an illusion. Lunchtime doubly so."
2006-05-24, 6:25 AM #5
... Tracer == Matterialize? :eek:
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2006-05-24, 7:05 AM #6
What's he doing editing JK?

Not that there's anything wrong with that but... :eek:
2006-05-24, 7:45 AM #7
Hey, don't you still edit JK?
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2006-05-24, 6:47 PM #8
Originally posted by GHORG:
What's he doing editing JK?

Not that there's anything wrong with that but... :eek:


Dude, buddy, thats a bannable offense! ;)
And when the moment is right, I'm gonna fly a kite.
2006-05-25, 12:58 PM #9
I suggest you try what I had originally. That method helps prevent camera problems whenever these get turned off (if at all). The problem was the opening brace after the if statement, that shouldn't have been there.

(JK doesn't track the camera change when you use SetCurrentCamera()... It's not critical to gameplay, just sloppy and somewhat annoying. SetCurrentCamera() is more useful if you want to set one of the less common cameras such as the death or idle cams)
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2006-06-10, 10:59 PM #10
Decided to browse the few topics that have been posted since the last time I came here, and saw a nasty error in the cog:

Code:
entered: 
    
   player = GetLocalPlayerThing(); 


Um, I believe that would work fine for the host, but not for other players. An earlier conversation with Zeq yielded some nifty info about how messages are handled and how messages that are ran on the host, not clients, would have GetLocalPlayerThing() always returning the host. Although, upon checking the cog again, it's flagged 0x240, so it should be fine. None the less, this should help if the cog doesn't work for other players:

Code:
entered: 
    
   player = GetSourceRef();
   if(GetThingType(player) != 10) return;
-Hell Raiser
2006-06-11, 9:58 AM #11
GetLocalPlayerThing() doesn't return the host. It returns the local computer's player. However, your code probably would work better for what he wants. I based mine around his, however, I'm not sure if he wants it so that any time a thing, ie, projectile, player, or otherwise enters the sector, the local player's camera changes...
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2006-06-11, 10:56 AM #12
If I remember right, GetLocalPlayerThing does return the host if the cog isn't local. Been a while since I bothered with that, but I think it did.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2006-06-11, 11:11 AM #13
If the cog is set to run on the server, GetLocalPlayerThing() will return the host. 0x240 would however make it run locally on each computer, and GLPT() would work "properly." Yea, that's it. :)
-Hell Raiser
2006-06-11, 8:21 PM #14
The good thing about using Hell Raiser's piece of code is, that this script gets executed as much as it wants when anything enters the sector (but of course not inside 'if' statements), unless it's masked to only trigger entrance to player thing, which I forgot if it was possible or how (don't have clearest memory of 5 years ago...)

Right now, when anything enters the sector, it checks to see if the player is in the sector or not, then does the rest of the code, but naturally, you should see if a thing entered the sector using GetSourceRef() is a player or not, then

box = GetSenderRef();
if(box == room1) do this;
else if(box == room2) do that;

and it would probably be the cleaner approach.

But this is just a way of coding, and current code still works too though.

↑ Up to the top!