ID:154696
 
I've learned how to use interface to setup macros and I want to able to allow player to enter a cobination of keys to execute verbs. EX ASDF(Spacebar) = nameOfAttack. I was thinking that I could have detectable key combinations setup as macros and then have a proc that checks to see if the executed combinations fit whats in a specific list. I'm not sure whether this is the most effecient way but regardless how would I be able to track what keys or macros a player presses?
If you have a suggestion of a method that would be better to use please don't hesitate to ask.
You could use key-down states in procs to gether which keys are being pressed. Then gather that info into a centralized proc for the nameOfAttack.

Ex;

mob
var
keyA = 0
keyS = 0
keyD = 0
keyF = 0
verb
keyA()
src.keyA = 1
keyAOff()
src.keyA = 0
keyS()
src.keyS = 1
keySOff()
src.keyS = 0
keyD()
src.keyD = 1
keyDOff()
src.keyD = 0
keyF()
src.keyF = 1
keyFOff()
src.keyF = 0

nameOfAttack()
if(src.keyA && src.keyS && src.keyD && src.keyF)
world << "Super Omega Almighty Verb of Something Useful!"
else
world << "Well, that didn't go quite as planned!"


Then you would need to edit your interface file's Macro list and have A,S,D,F keys execute their corresponding verbs. Ex:

A:
Key - A
Command - keyA

AOff:
Key - A
Command - keyAOff
Check-Mark - When key is released

To go more in-depth, if you want the nameOfAttack() to happen automatically, you would simply put a check in preferably keyF() like so:

mob
var
keyA = 0
keyS = 0
keyD = 0
keyF = 0
verb
keyA()
src.keyA = 1
keyAOff()
src.keyA = 0
keyS()
src.keyS = 1
keySOff()
src.keyS = 0
keyD()
src.keyD = 1
keyDOff()
src.keyD = 0
keyF()
src.keyF = 1
if(src.keyA && src.keyS && src.keyD && src.keyF)
src.nameOfAttack()
keyFOff()
src.keyF = 0

proc
nameOfAttack()
world << "Super Omega Almighty Verb of Something Useful!"
In response to Mr. Robert (#1)
I'll try it out thanks
In response to Raruno (#2)
Edited my post.
In response to Mr. Robert (#3)
Thanks again for the help. This along with some of my own adjustments is just what I needed
You can use my Keyboard library. It creates macros to manage the state of each key. You'd just have to do this:

client
key_down(k)
if(keys["a"] && keys["s"] && keys["d"] && keys["f"])
mob.special_attack()

mob
proc
special_attack()
world << "[src] does the special attack."


Four keys is a lot to be holding at the same time. Some keyboards won't be able to recognize all of those keys being pressed at the same time. For instance, on my keyboard if I hold down A, S, and D, pressing F won't even be recognized.
In response to Forum_account (#5)
The amount of keys that can be pressed is both limited by the keyboard maker and the type of keyboard it is. Most PS/2 keyboards can only have two keys pressed at the same time, while most USB keyboards have an unlimited amount on the hardware end, but tend to be limited to three or four keys by the keyboard software/drivers. It is pretty rare to find a non-gaming keyboard with more than three key support. Most will let you use all four arrow keys and three/four standard keys at the same time.