You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Heloo88 edited this page Jan 28, 2012
·
7 revisions
Tools
Terraria Source
ModClass
Adding the Hook
Open Player.cs
Navigate to Keys[] pressedKeys = Main.keyState.GetPressedKeys(); [Line 3003]
Add ModClass.onKeys(pressedKeys); below it
Open ModClass.cs
Add the following declaration using Microsoft.Xna.Framework.Input. (or using Microsoft.XNA.Framework.Input)
Add the following variable private static Keys[] previousKeys;
Add the following function public static void onKeys(Keys[] pressedKeys) {previousKeys = pressedKeys;}
Using the Hook
Change the following example to your needs:
if(pressedKeys.Contains(Keys.N) && !previousKeys.Contains(Keys.N)) {//Do something if N was just pressed;previousKeys = pressedKeys;}
Explanation
The previousKeys Array is used to enable "Toggle-Keys".
Toggle-Keys are keys that only run their action once even if you hold them for a longer time