script running inconsistently
8 posts
• Page 1 of 1
script running inconsistently
Can anyone tell me why this really simple code would be inconsistent?
For now I want it simply to change the led colour from red to green when I push 'E'
It works but only randomly, maybe 50% of the time..
For now I want it simply to change the led colour from red to green when I push 'E'
It works but only randomly, maybe 50% of the time..
- Code: Select all
#include <keyboard.gph>
#include <display.gph>
#include "light_k.gph"
#include <mouse.gph>
init{
mousemapping();
keymapping();
}
int mode;
main {
mouse_passthru();
key_passthru();
if (mode == 0) {
set_light('G');
}
if (mode == 1) {
set_light('R');
}
if ((key_status(KEY_E)) && (mode == 0)){
mode = 1;
}
else if (key_status(KEY_E) && (mode == 1)) {
mode = 0;
}
}
-
davebruno - Staff Sergeant
- Posts: 13
- Joined: Sat Feb 16, 2019 1:34 pm
Re: script running inconsistently
key_status will return true as long as you hold down the key, not only in the moment you press the key.
So it will do =1, =0, =1, ... to your variable as long as you press the key.
Take a look at my answer in your other post.
So it will do =1, =0, =1, ... to your variable as long as you press the key.
Take a look at my answer in your other post.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: script running inconsistently
Scachi wrote:key_status will return true as long as you hold down the key, not only in the moment you press the key.
So it will do =1, =0, =1, ... to your variable as long as you press the key.
Take a look at my answer in your other post.
Got it working, thanks a lot
-
davebruno - Staff Sergeant
- Posts: 13
- Joined: Sat Feb 16, 2019 1:34 pm
Re: script running inconsistently
Scachi wrote:key_status will return true as long as you hold down the key, not only in the moment you press the key.
So it will do =1, =0, =1, ... to your variable as long as you press the key.
Take a look at my answer in your other post.
Actually its still running inconsistent,
Now it switches fine until other keys are pushed, so for example when I run the below it works while tapping E but if I hold W and tap E it doesn't work, any idea why that would happen?
- Code: Select all
#include <keyboard.gph>
#include <display.gph>
#include "light_k.gph"
#include <mouse.gph>
#define KEYS_TO_MONITOR_MAX 1 // set to the max number of keys you need
#include "xkeys.gph"
uint8 KEYE;
init{
mousemapping();
keymapping();
KEYE =xkeys_add(KEY_E);
}
int mode;
int NavState;
main {
mouse_passthru();
key_passthru();
if (mode > 1) {
mode = 0;}
if (mode == 0) {
set_light('G');
}
if (mode == 1) {
set_light('R');
}
if (xkeys_event_active(KEYE)) {
mode = mode + 1;
}
}
-
davebruno - Staff Sergeant
- Posts: 13
- Joined: Sat Feb 16, 2019 1:34 pm
Re: script running inconsistently
bug in my xkeys header, fixed it. please download it again.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: script running inconsistently
Scachi wrote:bug in my xkeys header, fixed it. please download it again.
Sweet, thank you!
-
davebruno - Staff Sergeant
- Posts: 13
- Joined: Sat Feb 16, 2019 1:34 pm
Re: script running inconsistently
Scachi wrote:bug in my xkeys header, fixed it. please download it again.
Yo man, I just changed to a different mouse and I now cannot map its buttons to letters, have you made a mouse equivalent to xkeys at all?
I'm running into the same issues as before..
Thanks,
Dave
-
davebruno - Staff Sergeant
- Posts: 13
- Joined: Sat Feb 16, 2019 1:34 pm
Re: script running inconsistently
No, I have none for mouse.davebruno wrote:Scachi wrote:bug in my xkeys header, fixed it. please download it again.
Yo man, I just changed to a different mouse and I now cannot map its buttons to letters, have you made a mouse equivalent to xkeys at all?
I am not playing with mouse or keyboard..I use some self made device in addition to a default ps4 controller that i can assign keypresses to its buttons. This is what I have created the xkeys header for. That the header is useful for real keyboard too is just a glitch.
what are "the same issues" ?I'm running into the same issues as before..
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
8 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 98 guests