LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

How do you use the buttons

Root / Programming Questions / [.]

ElzoBroCreated:
I looked at the in-game manual for help but the explanation it gave me was not detailed enough. Plz Help

What do you want to use the buttons for? As input in a program?

Make a variable or just use BUTTON(). As in: IF BUTTON()=={blah blah} THEN {blah} The first blah is what you want the button to be. It's quite hard to remember them all: 1- up 2- down 4- left 8- right 16- a button 32- b button 64- x button 128- y button 256- l trigger 512- r trigger For example, if I want the program to wait until the A button is pressed, then I would put something like: @LOOP IF BUTTON()==16 THEN GOTO @BLAH GOTO @LOOP If you need any more scenarios or examples you can always ask. People here are glad to help!

This worked thanks

No problem! Glad to help!

Wait so what if i wanted a certain beep to come from pressing the button

Wait so what if i wanted a certain beep to come from pressing the button
You would put a beep command in @BLAH
@LOOP
IF BUTTON()==16 THEN GOTO @BLAH 'this part
GOTO @LOOP 

You could use BEEP as a result of a button press. Like: IF BUTTON()==16 THEN BEEP GOTO @LOL ENDIF

You don't need to remember the button codes in SmileBASIC, there are pre-defined constants for that: IF BUTTON() AND #A THEN BEEP I would recommend using AND instead of == because it allows for pressing other buttons with it. So for example, if you are holding L and press A, it wouldn't detect A being pressed if you used ==, but it would if you used AND.

It detects two buttons for me if I do something like IF BUTTON()==65 THEN BLAH I put sixty five since its 64 (x button) and 1 (up on dpad) and it works.

I'm not sure if you understood me; in my example, you wouldn't care about the other button (L). All you want to know is if the user pressed A, but pressing another button while pressing A will prevent the following from working: IF BUTTON() == #A THEN BEEP With this you can ONLY be pressing A and nothing else or else it won't BEEP; Holding L while pressing A won't trigger this. By doing this: IF BUTTON() AND #A THEN BEEP You can be pressing all the buttons you want and it would ignore them, only caring about if you pressed A; you could be holding UP, DOWN, L, R, etc. and press A and it will still BEEP.

Oh okay. That's actually going to be very helpful

Thanks for all the help guys!

So how do i have more than one button work,when try to the others dont work but the first one in the program does

Maybe something like: IF BUTTON() AND #A+#B THEN blah blah If it doesn't work for whatever you're asking, sorry. I didn't really get what you posted and I dont have my 3DS so I can't test what I'm posting.

Ummm to have two or more buttons do the same thing then maybe like: IF (BUTTON() AND #A) OR (BUTTON() AND #B) THEN BEEP And just add more "OR (BUTTON() AND blah)" for more buttons. If you want every button to do the same thing the use: IF BUTTON()>0 THEN BEEP

sorry, i meant that if i type: @LOOP1 IF BUTTON()==16 THEN GOTO @BLAH GOTO @LOOP1 Then I type @LOOP2 IF BUTTON()==32 THEN GOTO @BLAH2 GOTO @LOOP2 Only @LOOP1 wants works, @LOOP2 seems to just be ignored

Then put them on the same loop, like @LOOP IF BUTTON()==16 THEN GOTO @BLAH IF BUTTON()==32 THEN GOTO @BLAH2 GOTO @LOOP

Oh, Ok thanks! i think i can try to make Simon Says esque game now

I might make a Simon Says game myself. It'll be a fun project!