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

Detect sleep mode or home menu

Root / Submissions / [.]

12Me21Created:
MILLISEC is a millisecond (1/1000) timer. It uses the 3DS's internal clock, which runs constantly. MAINCNT is a counter, which increments during screen refresh (59.834 times per second). Since this is controlled by SB, it doesn't happen during sleep mode or when you're on the home menu. When you go to the menu or close your 3DS, they become desynchronized, which is easy to detect.
VAR _OLDMS%=MILLISEC
VAR _OLDMC%=MAINCNT
DEF PAUSED()
 VAR MS%=MILLISEC
 VAR MC%=MAINCNT
 VAR DIFF#=(MS%-_OLDMS%)-(MC%-_OLDMC%)/59.834*1000 '3DS runs at 59.834 FPS, not exactly 60
 _OLDMS%=MS%
 _OLDMC%=MC%
 IF DIFF#<2 THEN DIFF#=0 'ignore differences of less than 2 milliseconds
 RETURN DIFF#
END
This function does not need to run constantly. It will return the number of milliseconds spent in sleep mode or the home menu since the last call.

oh awesome, so you could make it so after closing your 3ds the game auto pauses so when you come back it dosent automatically go.. right..? or a game about closing your 3ds lol.

Replying to:SwanBot
oh awesome, so you could make it so after closing your 3ds the game auto pauses so when you come back it dosent automatically go.. right..? or a game about closing your 3ds lol.
"HOW DARE YOU SHUT ME OUT WHILE I'M SPEAKING TO YOU?!"

Replying to:SwanBot
oh awesome, so you could make it so after closing your 3ds the game auto pauses so when you come back it dosent automatically go.. right..? or a game about closing your 3ds lol.
^IM USING THAT!!!^ Edit; i never used it so now i will

how do you actually use this? i don't know how to use DEF lol

Replying to:IAmRalsei
how do you actually use this? i don't know how to use DEF lol
DEF lets you make your own commands and functions.
DEF TEST
  PRINT "Hello"
END
would print "Hello" when you run it with TEST. More examples:
DEF TALKPRINT T$
  FOR I=0 TO LEN(T$)-1
    PRINT T$[I]
    BEEP
    VSYNC 5
  NEXT
END

TALKPRINT "blah blah blah"

DEF ADD(NUM1,NUM2)
  RETURN NUM1+NUM2
END

PRINT ADD(2,2)
To run DEFined functions, just write their name like you would write PRINT.

Replying to:IAmRalsei
how do you actually use this? i don't know how to use DEF lol
YOU DIDN'T EXPLAIN IT WELL ENOUGH! GIVE AN EXAMPLE OF WHAT TO DO TO GOTO A LABEL WITH THIS CODE PLS

Replying to:IAmRalsei
how do you actually use this? i don't know how to use DEF lol
Understanding is on you. A lot of your posts are low-quality or thoughtless, DaSonicMario. Please try to be more considerate; this is not miiverse and the expectations are different.

Replying to:IAmRalsei
how do you actually use this? i don't know how to use DEF lol
i know it's not Miiverse but i thought it'd be similar to Miiverse.

Replying to:IAmRalsei
how do you actually use this? i don't know how to use DEF lol
SBS is less of a get-help whereever whenever environment than Miiverse. You can learn a lot more here as well if you look and ask in the right places. Also, your question was in caps and badly phrased. Sometimes that will work, sometimes it wonโ€™t. But itโ€™s usually the latter. Donโ€™t use label loops, kids. Stay in WHILE and eat your DEFs.

Replying to:IAmRalsei
how do you actually use this? i don't know how to use DEF lol
What. The. Heck?

Replying to:SwanBot
oh awesome, so you could make it so after closing your 3ds the game auto pauses so when you come back it dosent automatically go.. right..? or a game about closing your 3ds lol.
but i'm creating a game about closing your 3DS EDIT i finished it