Scripts / About keystroke combo

Author
Message
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 9th Jun 2016 15:02
Hi guys
Another question being raised.
I already know about "g_Scancode, g_InKey" , and so on , my issue comes when I need to detect 2 keys presses at time, IE: numbers like 10,11,12, etc, than user has to press 2 keys.

Someone know how to?

Thanks in advance 4 all feedback

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 9th Jun 2016 15:08
in your script can you just use a

If g_InKey = "1" and g_Inkey="0" then

---- do something here ----

end

I haven't tried that, but logically it should work, because you would need to press the 2 keys for the loop to start.
Aftershock Quad Core AMD FM2+ 3.5 GHz 8GB Motherboard and Processor, A7700k apu, AMD HD7870 gfx card.
King Korg Synth, Alesis SR18 Drum Machine, Akai MPX8 sample player, Roland Fantom XA Synth, Axus Digital AXK2 Digital Drum Kit, Novation Ultranova Synth, Waldorf Blofeld Synth.
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 9th Jun 2016 16:58
Thanks guy 4 the tip.

I already have tried both scripts below, and both does nothing.

1-



2-



3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 9th Jun 2016 17:08
hmmm same here nothing. That's odd as it should work, it may be that lua can only read one key with those commands, I will play with the scripts.
Aftershock Quad Core AMD FM2+ 3.5 GHz 8GB Motherboard and Processor, A7700k apu, AMD HD7870 gfx card.
King Korg Synth, Alesis SR18 Drum Machine, Akai MPX8 sample player, Roland Fantom XA Synth, Axus Digital AXK2 Digital Drum Kit, Novation Ultranova Synth, Waldorf Blofeld Synth.
cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 9th Jun 2016 17:14
Only the keys with their own lua reference can be checked at the same time (eg W A S D). Cheers.
Tarkus1971
Audio Media Maker
9
Years of Service
User Offline
Joined: 24th Feb 2015
Location: England, UK
Posted: 9th Jun 2016 17:22
OK thanks for that, what we need is a good lua equivalent to the old basic input$ command.

@3com - If you are trying to use the numbers for a keypad for a door try using jforths number pad pack, it works really well

https://www.tgcstore.net/pack/10621
Aftershock Quad Core AMD FM2+ 3.5 GHz 8GB Motherboard and Processor, A7700k apu, AMD HD7870 gfx card.
King Korg Synth, Alesis SR18 Drum Machine, Akai MPX8 sample player, Roland Fantom XA Synth, Axus Digital AXK2 Digital Drum Kit, Novation Ultranova Synth, Waldorf Blofeld Synth.
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 9th Jun 2016 18:13
@ cybernescence
Good point mate, unfortunatelly they are reserved keys.

@ Tarkus1971
Yeah, nice mesh, I remember it, I already own: https://forum.game-guru.com/thread/212454

Not exactly what I looking for, to make remembrances. I'm into sprite base (panel) plus 16 sprites over (fruits).
Player has to choose the right fruit.

So, for the player being able to hit some fruit, he'll nedd mouse or keys.
Since I can't get the mouse working as I want, so the only option I've is via keyboard, not the option I must want, but.

Well, back to the example, there are 16 fruits, problem raise when player has to choose fruit 10,11,12,13,14 etc.

Tha's the issue here.

And about the mouse, well, it seems (at least for me) force to create mouse sprite via "_init", and "ActivateMouse", just when
"_main" start, does not where/when I need it.
It does not good, since level start with the panel already created (does not where the player marker is), and mouse over an empty panel, and I do not want this, I want player finding ways to activate the script, so all should be start here, panel appears with all the fruits, and mouse already activate .

Mouse work fine for me, when I want to open some loadgame/savegame menu, but not the case.

Thanks again guys 4 the tips.

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 9th Jun 2016 18:29 Edited at: 9th Jun 2016 18:51
for combination keys, you need to be able to check the state of each key being pressed....
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 9th Jun 2016 18:42
@ BOTR
I had tried below code, with not to avail.


Thanks a lot 4 the tip.

eventually all end up drunk in this thread.

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 9th Jun 2016 19:46
Personally, I've yet to look at available key commands. I will have a play around when I get a spare few mins. Normally, you just test each key state to see if they have been pressed at the same time.



Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
J_C
16
Years of Service
User Offline
Joined: 9th Nov 2007
Location:
Posted: 9th Jun 2016 20:07
maybe as a quick fix you could try to use the shift key
-- to get 10 use shift and 0
if g_KeyPressSHIFT == 1 and GetInKey() == "0" then
-- to get 11 use shift and 1
if g_KeyPressSHIFT == 1 and GetInKey() == "1" then
-- to get 12 use shift and 2
if g_KeyPressSHIFT == 1 and GetInKey() == "2" then

PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 9th Jun 2016 20:21
@ J_C
I remember me using that option, but so, when I press let's say "1" and going to press "0", the fruit #1 was already out, like choossen, does not wait the second key, and ignoring shift key.

Anyway I plane to done a second try, maybe I has to do this than I won't (the cause I abandoned the idea), programing timer + delay.

Thanks mate 4 the tip.

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Bored of the Rings
GameGuru Master
19
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 9th Jun 2016 20:56
unfortunately, both those commands won't work in conjunction with each other. Would need a command that tests the state of each key being pressed that would be able to detect more than one key at a time.
Professional Programmer: Languages- SAS (Statistical Analysis Software) , C++, SQL, PL-SQL, JavaScript, HTML, Darkbasic Pro (still love this language), Purebasic, others
Hardware: Dell Precision 490; AMD Radeon HD 7570; LG TFT monitor (widescreen). Wanting a new PC at some point.
Interests: Drumming, Saxophone, Art, Theatre, Music.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 9th Jun 2016 20:58
What is your problem with getting the mouse to work? I've had no issues myself and done quite a lot of 2D stuff. Should be no problem. Alien invasion uses it to upgrade stuff. I can also get multi keys working normally but it is dodgy. The new commands were added because I was having this issue with a demo, that I never ended up showing (as yet, we will see.)


SPECS: Q6600 CPU. Nvidia 660GTX. 8 Gig Memory. Win 7.
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 9th Jun 2016 22:05
Quote: "What is your problem with getting the mouse to work?"


https://forum.game-guru.com/thread/215639

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Northern
13
Years of Service
User Offline
Joined: 5th Nov 2010
Location: Brazil
Posted: 11th Jun 2016 03:58
Hi 3com,

Perhaps, the script in the link shown below, it might be helpful to you and others in this community.

https://www.dropbox.com/s/qpy8g19vhmmqfe9/plrinzoneshowkeys.7z?dl=0

After to download and unzip the file, all you need to do is copy it and paste it in the scriptbank folder. Next, you should create a trigger zone in the map editor of the GG, and replace the original file plrinzone.lua, by the file you have just downloaded, named plrinzoneshowkeys.lua.

The script mentioned (plrinzoneshowkeys.lua) has three application examples and some comments as well.

Have fun!

Northern
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 11th Jun 2016 05:14
Moving this to the script thread.

Thanks.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit, Screen resolution 1680 x 1050.

3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 11th Jun 2016 11:18
@ Northern
Thanks alot mate!
At firts look it works fine 4 the purpose pointed above.

I know the goal here is capturing 2 keys at time, and your scripts cover it very well, so thanks again mate.

Now I'll try to depth into a bit, so I'll have to modified scripts a bit, to get my new challenge.

continue with the example above:
When player press let's say 14 (1 and 4), how diferentiate the player want fruit(14), or otherwise the player want 2 fruits, fruit(1) and fruit(4). Today I plane work on that.

I continue thinking the mouse is the right way here.

I'll post here the results as far as I've done.

@ Myke
Yep mate, it becomes a script issue, so here is the right place, thanks 4 moving.

3com


Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Northern
13
Years of Service
User Offline
Joined: 5th Nov 2010
Location: Brazil
Posted: 16th Jun 2016 05:31 Edited at: 20th Jun 2016 09:57
Hi there,

3com wrote:

Quote: "Thanks alot mate!"


You're welcome.

I am glad you find the script useful; however, it had a bug not spotted, when I tested it. Sorry!

In fact, the script in my previous post, had other problems, such as, besides the one reported by 3com, the user should click on the keys following an specific numeric sequence.

So, after reading your post, I tried to fix the original script, but, unfortunately no success at all.

Furthermore, I had to give up the first script approaching completely, and start over a new one from scratch.

The good news is that, after several codes approaching, finally a got it working right.

Now, the user, no longer, will not be forced to follow a particular numeric order, as well as, the script will be able to differentiate, if the user has clicked on 01, 04 or 14 keys, for example, in any numeric sequence, ranging from 01 until 99, since the game programmer has written or fed, previously all the data in the script.

I am still finishing some tests, before release it, replacing the first script, during this week if possible.

It's no way a complete solution still or bug free, though, for sure, hopefully, a bit better than its previous release, in my opinion; at no cost.

Cheers,
Northern

P.S: Edit on 06/20/2016 [mm/dd/yyyy notation]

Hi there,

The script, it's not finished still, but I am almost there! It's coming soon.

All the best,
Northern

PM
Northern
13
Years of Service
User Offline
Joined: 5th Nov 2010
Location: Brazil
Posted: 30th Jun 2016 15:17 Edited at: 1st Jul 2016 04:46
@All:

Hi everyone,

Aliquam laoreet, magna eget faucibus tincidunt, massa diam interdum massa, at bibendum lorem urna et ex. Phasellus fringilla tortor vitae felis bibendum semper. Duis faucibus cursus nisi, vel consequat ipsum maximus a. Sed euismod semper nulla, sed vulputate diam convallis vel. Duis mollis dictum massa, vitae imperdiet ligula rhoncus vel. Praesent in nisl sagittis, blandit risus in, lobortis ipsum. Nulla mollis sed elit ac interdum.

Features:

Proin vehicula nisi a risus fermentum, ac viverra ipsum molestie. Vestibulum eu hendrerit nulla. In hac habitasse platea dictumst. Ut nec pulvinar leo. Sed ac vehicula turpis, vitae sagittis tortor. Etiam ut magna neque. Maecenas auctor dui eu orci suscipit dapibus. Pellentesque purus enim, efficitur in ultrices vitae, facilisis nec ante. Maecenas ut dolor enim. Mauris lorem ex, iaculis ut fringilla sed, laoreet non erat. Etiam aliquet aliquam ligula, a efficitur magna. Sed urna felis, mollis in semper id, mattis et neque. Donec non auctor urna, vel rhoncus enim. Maecenas libero justo, pellentesque at pretium in, interdum sit amet mauris. Aenean vel mauris vitae tortor auctor volutpat. Quisque pharetra ornare accumsan.

Aenean mattis tellus eget erat viverra ullamcorper. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum dignissim mi a ex blandit, eget malesuada purus feugiat.
Cras hendrerit rhoncus enim, aliquam placerat arcu finibus a. Proin a egestas nibh, non ornare nunc. Nam ornare elit eget rhoncus molestie.

Enjoy!
Northern
PM
3com
9
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 30th Jun 2016 17:34
@ Northern
Thanks a lot mate 4 take your time into it.
However I've solved it via mouse, finally I've got mouse working as I wanted. I think mouse is better option than player pressing a combo keys he has to remember, if he want to use them.

Honestly, my project is a bit most complex than a simple fruits games, in fact it was an example to recreate what I want; this is a model going to store, so I'm forced to write all the used code myself, and that cause me prevent to post the code.

I've downloaded your code for testing next weekend, if I get some bug, I'll post here.

Anyway great work, you not only did the code, but also documented it, add the meshes, decals, even a map; mate that`s a great job!, and very kindly for your side to share it, so thanks again mate.

Great addition for the community.

3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Northern
13
Years of Service
User Offline
Joined: 5th Nov 2010
Location: Brazil
Posted: 1st Jul 2016 04:37
@3com:

Hi,

“The most expected thing you can expect is what's unexpected.”
Dick Allen, Zen Master Poems

No problem! You're welcome.

Besides, the solution presented in the video above (already disabled), is not the best nor the worst solution for combo key issue, it's just one more solution among several others possible, for the combo key problem.

I wish you luck with your project.

Cheers,
Northern

PM

Login to post a reply

Server time is: 2024-05-04 10:15:49
Your offset time is: 2024-05-04 10:15:49