PDA

View Full Version : Disable 'A' and 'B' when facing...



CJC
12-26-2006, 01:42 AM
I know this is probably going to turn out to be very simple, but I don't know anything about programming or scripting, so please bear with me.



I'm making a quest that's entirely side-scroller, and I want to disable items when facing up and down. Partially because the player will be on a ladder when pointed that way, but mostly because I don't want to animate attacks for those directions. So, basically I need a way to log Link's facing and disable the two main item controls when he's facing up and/or down.

Saffith
12-26-2006, 03:03 PM
No problem.
NoUpOrDownActions.z (http://users.wpi.edu/~absutman/zscript/NoUpOrDownActions.z)

ShadowTiger
12-26-2006, 03:38 PM
Hm. Intriguing. Nice script, Saffith, as always. May I ask a stupid question though?


while(true)
{
if(Link->Dir==DIR_UP || Link->Dir==DIR_DOWN)
{
Link->InputA=false;
Link->InputB=false;
}

Waitframe();
}


This is a "while" operation. The pseudocode is easy enough to comprehend, but seeing as it's a while operation, it states that -while- Link is facing up or down, A and B are set to False. Why doesn't it have to reactivate them? Is a state of "true" already assumed if it's not in the while loop? How or why is it assumed? O.o It's like it set it to false but doesn't set it to true anywhere.

It's fairly obvious how it can be true outside of the while loop, as it's the default, but why does it automatically assume the default of being true when the while loop deactivates?

Saffith
12-26-2006, 04:02 PM
Ah, see, the InputXes don't enable or disable the buttons; rather, at the beginning of each frame, they're set to true if the corresponding button is being pressed and false if it's not. The script doesn't actually disable the buttons, it just tells the game they're not being pressed every frame.