Source language: Translate to:

Quiz

General questions about NeoBook

Moderator: Neosoft Support

Quiz

Postby martinp » Wed Jun 01, 2016 1:58 pm

Hi guys, ive been trying to produce a program that allows a fastest finger first quiz.
Basically, I have two buzzers.
Each buzzer (when pressed) activates a button on the keyboard and when pressed it shows their name and blocks the other one out.
I have been using the disable and enable object script BUT its not working as it should.
One of the buzzers always seems to be the first each time.

Can anyone shed any light on the issue, or suggest a solve?

Thanks
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: Quiz

Postby Gaev » Wed Jun 01, 2016 2:30 pm

martinp:

When communicating on this forum, it helps to speak the lingo that other NeoBook users understand ... what is a "buzzer" ? ... what is "a button on the keyboard" ?

I have been using the disable and enable object script BUT its not working as it should.
One of the buzzers always seems to be the first each time.

Can anyone shed any light on the issue, or suggest a solve?

For each event, post your code here ... and explain what each referenced NeoBook object is.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Quiz

Postby martinp » Thu Jun 02, 2016 6:37 am

Oops sorry.

I have 2 large physical red buttons that activate keys on the keyboard when they are pressed.
Button 1 and button 2
I have attached a code to each key so that when a buzzer is pressed, it disables the other buzzer.

Loop "1" "2" "[Count]"
If "Button[Count]" "<>" "[Self]"
DisableObject "Button[Count]"
EndIf
EndLoop

The above works BUT it does not disable the 'other' button quick enough.
The project is for a Quiz Night where two teams go head to head.
A question is asked and the first person to buzz in gets to answer the question.
Hence the 'fastest finger first' theme.

Thanks
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: Quiz

Postby Cipolla » Thu Jun 02, 2016 7:34 am

As far as i understand your "buzzer" simply simulates a key press on your keyboard?

So i mean you don´t need the loop inside your button script. Simply fire an

If Button 1 is pressed..
Code: Select all
DisableObject "Button2"
...do something more...


and

If Button 2 is pressed..
Code: Select all
DisableObject "Button1"
...do something more...


Or am i missing something?
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Re: Quiz

Postby martinp » Thu Jun 02, 2016 8:53 am

tried that already but it's not quick enough.........contestants do tend to slam their buttons within a millisecond of each other and that script seemd to allow one of the buttons to be first more than the other
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: Quiz

Postby Gaev » Thu Jun 02, 2016 10:39 am

martinp:

1) Before you ask the question ...
Code: Select all
SetVar "[FirstResponder]" ""


2) for the Click event for Button1 ...
Code: Select all
If "[FirstResponder]" "=" ""
   SetVar "[FirstResponder]" "Button1"
Endif


3) for the Click event for Button2 ...
Code: Select all
If "[FirstResponder]" "=" ""
   SetVar "[FirstResponder]" "Button2"
Endif


Have a Text object that will show the value of [FirstResponder].

If you still get unexpected results, tell us ...

a) What are the shortcut keys assigned to Button1 and Button2 ?

b) Which one does NeoBook favour all the time ?
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Quiz

Postby martinp » Thu Jun 02, 2016 1:56 pm

shortcut keys:
Button 1 is NUM1 (keypad)
Button 2 is NUM2 (keypad)

It does tend to favour button 1......BUT.....could this due to the way that I press the two buttons at the same time?
If anyone presses two buttons at the same time, chances are they will have one finger that maybe more dominant than the other, in other words.....if you are left handed, or right handed??
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: Quiz

Postby Gaev » Thu Jun 02, 2016 3:13 pm

martinp:

shortcut keys:
Button 1 is NUM1 (keypad)
Button 2 is NUM2 (keypad)

How did you manage to set these shortcuts ? ... NeoBook's dropdown values for the shortcut key selection do not show these options ... in my NeoBook, it offers ...

Ctrl+A to Ctrl+Z
Ctrl+Alt+A to Ctrl+Alt+Z
F1 to F12
Ctrl+F1 to Ctrl+F12
Shift+F1 to Shift+F12
Shift+Ctrl+F1 to Shift+Ctrl+F12
Ins, Delete, Backspace and various combinations

... but no number keys ... however, if you choose Ins option, it refers to the key on the numeric pad with the characters 0 and Ins ... and similarly, if you choose the Del option it refers to the key on the numeric pad with the characters decimal point and Del.

On my keyboard, the unshifted key on the numeric pad is End (for 1) and down-arrow (for 2).

Please post here how you managed to define 1 and 2 on the Numeric keypad.

It does tend to favour button 1......BUT.....could this due to the way that I press the two buttons at the same time?

If anyone presses two buttons at the same time, chances are they will have one finger that maybe more dominant than the other, in other words.....if you are left handed, or right handed?


I tried doing this with the Ins and Del keys ... using the commands suggested in my last post ... when I examined the Debugger for the sequence of commands serviced, I did notice that NeoBook halts whatever it is doing (in this case, servicing commands for one Button) and hops on to servicing of commands for the second button ... then coming back to complete the commands for the first button.

Each time, I (not the fastest finger in the west) could interrupt processing after just one command was serviced ... so code this ...

1) Before you ask the question ...
Code: Select all
SetVar "[FirstResponder]" ""


2) for the Click event for Button1 ...
Code: Select all
SetVar "[FirstResponder]" "[FirstResponder]Button1, "


3) for the Click event for Button2 ...
Code: Select all
SetVar "[FirstResponder]" "[FirstResponder]Button2, "


... and give it your fastest finger ... if NeoBook can service at least one command before the second event code kicks in, then you can examine the contents of [FirstResponder] to see who got in first.

Even if this works on your computer, note that results may be different with older/slower computers and/or faster fingers.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Quiz

Postby Cipolla » Fri Jun 03, 2016 4:54 am

I did a quick test on my maschine using my code postet above.

This is the result. A friend and i hacked like hell on keys "a" and "l" :lol:

(The list is mouch more longer...) seems to me works like a charme

My maschine is a I5 windows 7

a
a
a
l
l
l
a
l
l
l
a
a
l
l
a
l
l
a
a
l
a
l
l
a
l
a
a
a
l
l
a
a
l
l
l
a
a
a
a
l
a
l
l
a
l
a
a
l
l
l
a
l
l
l
l
l
a
a
l
a
l
l
a
l
l
l
a
a
l
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Re: Quiz

Postby Gaev » Fri Jun 03, 2016 5:25 am

Klaus:

On my Windows 10 machine (with AMD A10-7300 processor), I could replicate your experience (I used Ins and Del keys) ... which ...

1) confirms that with both our machines (and human finger-swiftness), you can sneak in one NeoBook command ... faster machines may enable more commands ... slower machines (with fast-fingered humans) may pose a problem.

2) assuming that you can sneak in at least one command, your suggestion to make the first command DisableObject is the best solution (as it prevents the instructions for the other Button from being activated).

@martinp:

Make the first command in each Button's click section "Disable the other Button" ... you will need to have instructions to Enable both Buttons before every test ... if it still does not work, post details of your machine.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Quiz

Postby martinp » Fri Jun 03, 2016 6:22 am

HI guys, regarding the keys press
In each PushButton Properties I clicked in the ShortCutKey box and simply pressed the number 1 button the keypad.

Will try the below and see what happens
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: Quiz

Postby martinp » Mon Jun 06, 2016 2:45 am

DisableButton code works brilliant (when placed first in each button script).....BUT if you add more than two buttons, the results differ.
The laptop that I use is not that fast and it struggles with code when more than two buttons are pressed at a 'relatively' same time.

As you can probs gather, I'm not brilliant with coding (but I do get by) and learning all the time...

Disabling the other three buttons when one is pressed is causing a few headaches.....can anyone suggest a work round?

Thanks guys
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: Quiz

Postby martinp » Mon Jun 06, 2016 2:50 am

Here's the code that I've been using on each button

DisableObject "button2"
DisableObject "button3"
DisableObject "button4"
MoveObject "Answer1" "251" "555"
DisableObject "button1"

"Answer1" is a JPG image that shows above a team name so that it indicates who pressed first.
The DisableOject button 1 (at the end of the code) is to stop teams pressing their button again
(in this instance, it was Team 1......or button 1)
martinp
 
Posts: 50
Joined: Fri May 20, 2005 6:18 am

Re: Quiz

Postby Gaev » Mon Jun 06, 2016 5:57 am

martinp:
The laptop that I use is not that fast and it struggles with code when more than two buttons are pressed at a 'relatively' same time.

Too bad you don't have (can't find) a computer fast enough to handle at least two commands between key presses.

Try this (for capturing the fast finger) first ... if it works (on the slow machine), we can explore means of showing the results ...

1) Before you ask the question ...
Code: Select all
SetVar "[FirstResponder]" ""


2) for the Click event for Button1 ...
Code: Select all
SetVar "[FirstResponder]" "[FirstResponder]Button1, "

... for each of the other buttons, setup a similar SetVar command.

Temporarily, have a Text object visible ... and set its value to [FirstResponder] ... depending on order of key presses, you will see its content as something like ...

Button3, Button1, Button2, Button4,

If you are able to verify that this text displays the values in the order of key presses, the logic for extracting the first Button is ...
Code: Select all
StrParse "[FirstResponder]" ", " "[WinnerButton]" "[Count]"
AlertBox "WinnerButton" "[WinnerButton1]"
If "[WinnerButton1]" "=" "Button1"
   MoveObject "Answer1" "251" "555"
EndIf
If "[WinnerButton1]" "=" "Button2"
   MoveObject "Answer2" "251" "555"
EndIf
If "[WinnerButton1]" "=" "Button3"
   MoveObject "Answer3" "251" "555"
EndIf
If "[WinnerButton1]" "=" "Button4"
   MoveObject "Answer4" "251" "555"
EndIf


Initially assign the above code to yet another button (say Show Winner) ... if it is not acceptable to have a user action (click, key press) in order to show the winner, an automated process (using a Timer object) can be explored.
User avatar
Gaev
 
Posts: 3728
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 0 guests