Computer Science Canada

Key Module To Import

Author:  copthesaint [ Wed Apr 08, 2009 12:01 pm ]
Post subject:  Key Module To Import

Here is a Key Module I made today. Thought It would be usefull to me, and so I am sharing for people who may also find it usefull.
Commands are

Key.Hit (Function) of Boolean

Key.Down (Function) of Boolean

Key.DisableTimer (Procedure)

Key.Enable (Procedure)

Key.DisableCheck (Function) of Boolean

Enjoy. This can be usefull in many programs from chat to draw to games.

How To Use :

Turing:
Key.Hit (Char : char) : boolean

This will Check to see if you have pressed a Character such as (KEY_ENTER). Also the Hit will ensure that You have to RELEASE the key and press it.

Turing:
Key.Down (Char : char): boolean

This Will Check to see if you have a key down. You can keep the key down to make the statement true.

Turing:
DisableTimer (New : int, Char : char, Timer : real)

This will create a new Disable Timer for The char you choose. The "New" is the number you give to identify your Timer.
If you disable a key for the timer The Key.Hit and Key.Down statements will result as false until the timer has finished.

Turing:
DisableCheck (New : int) : boolean

This will Check to see if the Timer of set ID number (New) hasn't expired. Then the function will return the Value as true if done or false if still running.

Turing:
Enable (New : int) : boolean

This will clear the Disable Timer and And allow you to hit the key.

Here is an examaple for importing the module and some ways you can use this program.
Turing:
import (Key in "Key.tu") /*Imports the program*/
put "Please press enter"

Key.DisableTimer (1, KEY_ENTER, 5.000) /*Disables the enter key for 5 seconds*/
View.Set ("offscreenonly")

loop
    View.Update
    delay (5)
    cls
    if Key.Hit (KEY_SHIFT) = true then /*Hitting this will enable the key enter*/
        put "You Enabled the enter key"
        Key.Enable (1)
    end if
    if Key.DisableCheck (1) = true then /*Checks to see if the key is still disabled*/
        put "Key Still Disabled"
    else
        put "Key Enabled"
        if Key.Hit (KEY_ENTER) = true then /*Checks to see if the key is hit*/
            put "You hit the enter key"
        end if
    end if
end loop

[/strike]

Author:  corriep [ Wed Apr 08, 2009 2:44 pm ]
Post subject:  RE:Key Module To Import

pretty cool, if I could make one suggestion it would be that instead of the timer variable being the time in seconds, why not make it the time in milliseconds, then you would not have to make that variable a real

Author:  copthesaint [ Wed Apr 08, 2009 8:23 pm ]
Post subject:  Re: Key Module To Import

Opps Sorry about that. Thought that Time>sec could work as real.

Here is the fixed file and Example.

How To Use:

Turing:
Key.DisableTimer (New : int, Char : char, Timer : int)


This will create a new Disable Timer for The char you choose. The "New" is the number you give to identify your Timer.
If you disable a key for the timer The Key.Hit and Key.Down statements will result as false until the timer has finished.
Change* The timer is in millisecs so 1000 for the timer = 1 second.
*Attachments Deleted.

Author:  copthesaint [ Tue Apr 21, 2009 2:16 pm ]
Post subject:  Re: Key Module To Import

Turing:
/*
 **********************************************************************************
 *****                                                                        *****
 ***                         Copthesaint's SKey Module                          ***
 *****                             Normal Version                             *****
 **********************************************************************************
 ***                                Version 1.2                                 ***
 **********************************************************************************
 *  Instructions:                                                                 *
 * #1: Save the file next to the file you                                         *
 *    want to inculde this key module                                             *
 *    to.                                                                         *
 *                                                                                *
 * #2: Open your Program                                                          *
 *                                                                                *
 * #3: At the start of your program,                                              *
 *    Paste the following text to your                                            *
 *    program:                                                                    *
 *                                                                                *
 *  import (SKey in "SKey.tu")                                                    *
 *                                                                                *
 * #4: Save your program and you should                                           *
 *    be able to use the following                                                *
 *    commands.                                                                   *
 **********************************************************************************
 **********************************************************************************
 *****                                                                        *****
 ***                         Copthesaint's SKey Module                          ***
 *****                              Commands:                                 *****
 **********************************************************************************
 *  -Function  : SKey.Hit (Char : char) : boolean                                 *
 *                                                                                *
 *  -Function  : SKey.Down (Char : char) : boolean                                *
 *                                                                                *
 *  -Function  : SKey.DisableCheck (NewDisable : int) : boolean                   *
 *                                                                                *
 *  -Procedure : SKey.DisableTimer (NewDisable : int, Char : char, Timer : int)   *
 *                                                                                *
 *  -Procedure : SKey.Enable (Enable : int)                                       *
 *                                                                                *
 *  -Procedure : SKey.Disable (NewDisable : int, Char : char)                     *
 *                                                                                *
 *  -Procedure : SKey.Force : (Char : char, Timer : int)                          *
 **********************************************************************************
 */

Author:  Aange10 [ Sat Mar 10, 2012 2:37 pm ]
Post subject:  RE:Key Module To Import

Sorry to Necro post, but this forum post is in a stickie anyways.

There is nowhere to download or copy/paste the module?

Author:  copthesaint [ Mon Jun 04, 2012 10:57 am ]
Post subject:  RE:Key Module To Import

Sorry I deleted this download, It is old and I bet other people have made better.


: