Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / a few 'key' functions

Author
Message
Yian
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: Nicosia, Cyprus(the Greek half)
Posted: 26th Apr 2006 14:56
these two functions will convert a scancode to the actual key name (as a string ) and vice versa.



Mouseclick() detects when the mouse is pressed in.I made two functions which tell you when the mouse or any key was pressed out, ie. released.Some may find this useful since mouseout() or keyout() can't happen continually like mouseclick() for example you have a menu and when you click a button and it goes to the next screen and there is a new button at the same location,if you use mouseclick() it will detect it and will act as if you pressed the second button too.There are a few other uses.



"hello my brother. hello and goodbye."
-black man on drugs outside a big white house
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 27th Apr 2006 23:29
Alternatively ... just look at this:



Yian
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: Nicosia, Cyprus(the Greek half)
Posted: 28th Apr 2006 01:48
the first function was designed to allow the programmer the freedom of not having to peek at that every now and then... but its up to you ,whatever rocks your boat

A study done by William Speyer, who was a victim of prison rape in 1989, shows that 34% of [prison] rape victims released from prison become child molestors.
RiiDii
19
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Inatincan
Posted: 30th Apr 2006 10:02
For other options, here is all the codes encoded as various constants. They are very easy to use. Example: Just use "ks" in place of "keystate(31)" for the "s" key.



[shameless plug] We have a lot of other usefull code from the Open MMORPG Project. Just click on my sig. [/shamelss plug]


Open MMORPG: It's your game!
Underworld 1020
20
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 5th May 2006 07:06 Edited at: 5th May 2006 07:10
Quote: "these two functions will convert a scancode to the actual key name (as a string ) and vice versa."


-------------------------------------------------------------------

Quote: "CHR$

This command will return a character string equivalent to the ASCII character number provided. ASCII is a standard way of coding the characters used to construct strings. The value provided should be an integer value.

Syntax

Return String=CHR$(Value)"


-------------------------------------------------------------------

Quote: "ASC

This command will return an integer value that represents the ASCII code for the first character of the provided string.

Syntax

Return Integer=ASC(String)"


IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 6th May 2006 00:56
If speed is an issue, you would not use a function to convert scancode to key names - you'd load all of the names into a 255 item array, and just index that directly.

Converting key names back to scancodes (can't think of a reason why you would ...) can be made fast by storing the names and their values in an array sorted by name, and using a binary search on the array. For 256 values, that would give you 8 or less comparisons to find any one of the values.

For free Plug-ins and source code http://www.matrix1.demon.co.uk
Yian
21
Years of Service
User Offline
Joined: 16th Jun 2003
Location: Nicosia, Cyprus(the Greek half)
Posted: 8th May 2006 20:31
thanks for the feedback! did you try the mouse/keyout functions?

A study done by William Speyer, who was a victim of prison rape in 1989, shows that 34% of [prison] rape victims released from prison become child molestors.
CuCuMBeR
21
Years of Service
User Offline
Joined: 11th Jan 2003
Location: Turkey
Posted: 9th May 2006 11:10
Try this,
it makes a button (clicked once even if you keep pressing it)
and it makes a statement for the button (on or off states, can be easily increased)



Too Sexy
Lukas W
21
Years of Service
User Offline
Joined: 5th Sep 2003
Location: Sweden
Posted: 9th May 2006 19:42
this reminds me:

in a game im making i'd like to convert asc to scancode values.
is it possible?

this is the code i use:



this is for the "customizable controls" thingie.
in previous versions of the game, i created something along the lines as the first post in this thread, but it was too much of code.

i'm using DBC.

my forum - now partly finished

Login to post a reply

Server time is: 2024-11-23 07:41:41
Your offset time is: 2024-11-23 07:41:41