Difference between revisions of "FF7/Field/Script/Opcodes/31 IFKEYON"

From Final Fantasy Inside
< FF7‎ | Field‎ | Script‎ | Opcodes
Jump to navigation Jump to search
my_wiki>Synergy Blades
m (4 revisions imported)
 
(2 intermediate revisions by 2 users not shown)
Line 19: Line 19:
 
Similar to [[FF7/Field/Script/Opcodes/30_IFKEY|IFKEY]], '''IFKEYON''' checks if a button is being pressed with the given ID (matching those in IFKEY). However, the body of the "if" statement only executes if this is the first time the button has been recorded as being pressed. If this is not the first time it is being pressed (that is, the user has held the key down), the condition evaluates to false, and the "if" statement body does not execute, moving the script pointer forward by ''A''.
 
Similar to [[FF7/Field/Script/Opcodes/30_IFKEY|IFKEY]], '''IFKEYON''' checks if a button is being pressed with the given ID (matching those in IFKEY). However, the body of the "if" statement only executes if this is the first time the button has been recorded as being pressed. If this is not the first time it is being pressed (that is, the user has held the key down), the condition evaluates to false, and the "if" statement body does not execute, moving the script pointer forward by ''A''.
  
This is an effective way to stop repeatedly executing the body if the "if" statement due to the user holding the key down; thus, the body of the statement will only execute once. The button state is reset when the user lets go of the button, and at this point, IFKEYON may evaluate to true once more when the button is repressed.
+
This is an effective way to stop repeatedly executing the body of the "if" statement due to the user holding the key down; thus, the body of the statement will only execute once. The button state is reset when the user lets go of the button, and at this point, IFKEYON may evaluate to true once more when the button is repressed.

Latest revision as of 05:16, 23 May 2019

  • Opcode: 0x31
  • Short name: IFKEYON
  • Long name: If Key Pressed (First Time)

Memory layout

0x31 B A

Arguments

  • const UShort (Bit field) B: Button ID to check for.
  • const UByte A: Amount to jump if condition is false.

Description

Similar to IFKEY, IFKEYON checks if a button is being pressed with the given ID (matching those in IFKEY). However, the body of the "if" statement only executes if this is the first time the button has been recorded as being pressed. If this is not the first time it is being pressed (that is, the user has held the key down), the condition evaluates to false, and the "if" statement body does not execute, moving the script pointer forward by A.

This is an effective way to stop repeatedly executing the body of the "if" statement due to the user holding the key down; thus, the body of the statement will only execute once. The button state is reset when the user lets go of the button, and at this point, IFKEYON may evaluate to true once more when the button is repressed.