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 → What's wrong with this code...?
What's wrong with this code...?
2005-06-28, 12:45 PM #1
This is supposed to make the player crouch when the key is depressed, then stand up when key is no longer depressed:

Code:
#----------------------------------------
# New crouch
#----------------------------------------

symbols

message	startup
message	activated

thing	    	player				local

vector      	playerVel			local
vector      	thrust			local

end                                                                           

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

code

startup:

   player = GetLocalPlayerThing();

   Return;
# ........................................................................................

activated:

   thrust = GetThingThrust(player);

	if((VectorY(thrust) == 0) && (VectorX(thrust) == 0))
	{
SetPhysicsFlags(player, 0x10000); // will cause player to crouch.
	}

Return;

# ........................................................................................

deactivated;

ClearPhysicsFlags(player, 0x10000); // stand player up.

Return;
#..
end


_K_
2005-06-28, 12:55 PM #2
Quote:
deactivated;


lol that should just be deactivated: and you should add deactivated to symbols ;)

ReT
2005-06-28, 1:39 PM #3
Hmmm... the following doesn't seem to work either --

Code:
#----------------------------------------
# New crouch
#----------------------------------------

symbols

message	startup
message	deactivated

thing	    	player				local

vector      	thrust			local

end                                                                           

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

code

startup:

   player = GetLocalPlayerThing();

   Return;
# ........................................................................................

deactivated:

   thrust = GetThingThrust(player);

	if((VectorY(thrust) == 0) && (VectorX(thrust) == 0))
	{
SetPhysicsFlags(player, 0x10000); // will cause player to crouch.
	}

Return;

# ........................................................................................


#..
end


_K_
2005-06-28, 2:55 PM #4
I think you misunderstood... ReT meant get rid of the semicolon and add "message deactivated" to the symbols
Code:
#----------------------------------------
# New crouch
#----------------------------------------

symbols

message	startup
message	activated

        message	deactivated
    

thing	    	player				local

vector      	playerVel			local
vector      	thrust			local

end                                                                           


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

code

startup:

   player = GetLocalPlayerThing();

   Return;
# ........................................................................................

activated:

   thrust = GetThingThrust(player);

	if((VectorY(thrust) == 0) && (VectorX(thrust) == 0))
	{
SetPhysicsFlags(player, 0x10000); // will cause player to crouch.
	}

Return;

# ........................................................................................


        deactivated:
    

ClearPhysicsFlags(player, 0x10000); // stand player up.

Return;
#..
end
May the mass times acceleration be with you.
2005-06-28, 3:05 PM #5
No worries, D_Slaw...

... but that doesn't seem to do it either.... Hmmm...

_K_
2005-06-28, 7:29 PM #6
Put a Print("Started"); in, to make sure the cog's actually being run. Do same thing with activated. I'm guessing this isn't a cog problem.
_ _ _____________ _ _
Wolf Moon
Cast Your Spell On Me
Beware
The Woods At Night
The Wolf Has Come
2005-06-29, 7:27 AM #7
I'm gonna go out on a limb and ask, is that line of equal signs (highlighted red in my post) separated like that in the cog on your computer?
The reason I ask is b/c, while the forums do like to break those lines (and not the ones using periods) it looks like a blank line has been inserted between them, something the forums don't do.

[edit]hmm... it's only like that in my post and not your first one... if it was the forums, I've never seen them do that...
May the mass times acceleration be with you.
2005-06-29, 6:04 PM #8
D_Slaw: I dunno if the " #======= (etc.)" lines were separated in my COG... I threw it out in favor of this:

Code:
#----------------------------------------
# New crouch
#----------------------------------------

symbols

message	startup
message	activated
message	deactivated

thing	    	player				local

vector      	playerVel			local
vector      	thrust			local

end                                                                           

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

code

startup:

   player = GetLocalPlayerThing();

   Return;
# ........................................................................................

activated:
Print("activated");
   thrust = GetThingThrust(player);

	if((VectorY(thrust) == 0) && (VectorX(thrust) == 0))
	{
SetPhysicsFlags(player, 0x10000); // will cause player to crouch.
	}

Return;

# ........................................................................................

deactivated:
Print("de-activated");

ClearPhysicsFlags(player, 0x10000); // stand player up.

Return;
#..
end


the "activated" message pops up...
the "de-activated" message does _NOT_....

Hmmmmm......

_K_
2005-06-29, 6:55 PM #9
Well, it parsecs okay... hmm... I'm willing to bet it's a hotkey issue.
Make sure your hotkey entry in items.dat does NOT have the 0x2 bin flag (it should be 0x120). 0x2 prevents the deactivated message from being sent (God knows why LEC did it this way... :rolleyes: )
May the mass times acceleration be with you.
2005-06-29, 7:48 PM #10
Nope: it's set to 0x120....

_K_
2005-07-03, 8:11 AM #11
That flag doesn't work for the player. Quoting DM "[The 0x10000] Physics Flag is used by creatures..."

Creature = Actor

Actor != Player

Therefore, this flag will NOT force the player into a crouch.

PS - I've tried somethin like that before accually....

PPS - And whenever you start a new line (ie, hit enter giving a /0 {null} at the end) you should always put in #'s or //'s to be safe, I dunno if anything between the symbols and code section will provide any problems, but its good habits.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack

↑ Up to the top!