DSLua Community
Welcome, Guest. Please login or register.
May 18, 2012, 09:19:48 PM
1371 Posts in 262 Topics by 33109 Members
Latest Member: Limewire Download
DSLua Community  |  DSLua - Best scripting language for Nintendo DS  |  Need Help?  |  How do I... « previous next »
Pages: [1]
Author Topic: How do I...  (Read 1266 times)
LeightonW87
Waxing Crescent
**
Posts: 17


« on: July 18, 2006, 08:52:08 PM »

How do I add a delay to my menu system and clear the screen to remove old text???

Code:
-- SCREEN ARRAYS --
SCREEN_BOTTOM = 0
LOOPON = 1
MENU = 0
MENU_OPTION = 1

-- THIS SETS THE BOTTOM SCREEN UP --
BGBotText = Screen.LoadTextBG()
Screen.Initialize( SCREEN_BOTTOM, BGBotText )

-- INFO TEXT --

while true do
BGBotText:SetColor( 200, 0, 200, 0 )
BGBotText:PrintXY( 0, 19, "Touch the screen to continue... ")
if LOOPON == 1 and Stylus.Down() then
LOOPON = 0
MENU = 1
BGBotText:SetColor( 200, 0, 200, 0 )
BGBotText:PrintXY( 0, 16, "Menu System made by ")
BGBotText:PrintXY( 0, 17, "    Leighton :D")
end
if Stylus.Down() then
MENU = 1
end
-- Open the Menu  (TEXT PART)  --
if MENU == 1 then
BGBotText:SetColor( 150, 0, 150, 0 )
BGBotText:PrintXY( 4, 1, "A Menu by" )
BGBotText:PrintXY( 0, 2, "Leighton Williams" )
end
if Pads.Up() then
MENU_OPTION = MENU_OPTION - 1
end
if Pads.Down() then
MENU_OPTION = MENU_OPTION + 1
end
if MENU_OPTION == 1 then
BGBotText:SetColor ( 5 )
BGBotText:PrintXY( 0, 10, "START MUSIC" )

BGBotText:SetColor ( 4 )
BGBotText:PrintXY( 0, 11, "PAUSE MUSIC" )

BGBotText:SetColor ( 4 )
BGBotText:PrintXY( 0, 12, "STOP MUSIC" )
end
if MENU_OPTION == 2 then
BGBotText:SetColor ( 4 )
BGBotText:PrintXY( 0, 10, "START MUSIC" )

BGBotText:SetColor ( 5 )
BGBotText:PrintXY( 0, 11, "PAUSE MUSIC" )

BGBotText:SetColor ( 4 )
BGBotText:PrintXY( 0, 12, "STOP MUSIC" )
end
if MENU_OPTION == 3 then
BGBotText:SetColor ( 4 )
BGBotText:PrintXY( 0, 10, "START MUSIC" )

BGBotText:SetColor ( 4 )
BGBotText:PrintXY( 0, 11, "PAUSE MUSIC" )

BGBotText:SetColor ( 5 )
BGBotText:PrintXY( 0, 12, "STOP MUSIC" )
end
if MENU_OPTION == 0 then
MENU_OPTION = 1
end
if MENU_OPTION == 4 then
MENU_OPTION = 3
end
if LOOPON == 2 then
break
end
Screen.WaitForVBL()
end

Anyway, this was my first proper attempt at DSLua and I can be sure that "while true do" is much better than "loop", Thanks for that Daltonlaffs. Cheesy

Oh, I also think that a could have tried to make the code a bit smaller.
Logged
Zhen
Waxing Crescent
**
Posts: 45


WWW
« Reply #1 on: July 19, 2006, 04:34:15 AM »

How do I add a delay to my menu system and clear the screen to remove old text???

You can try this.

Code:
-- clear the text screen
BGBotText:Clear()

-- delay n seconds
function delay( seconds )
    local initialTime = DSLua.VBlankCount()
    local actualTime = initialTime
    local ticks = seconds / 0.0167224 -- a tick is a 1 / 59.8 of a second

    while ( actualTime - initialTime ) < ticks do
        Screen.WaitForVBL()
        actualTime = DSLua.VBlankCount()
    end
end

Zhen
Logged
daltonlaffs
First Quarter
***
Posts: 189


Freaking Insane


WWW
« Reply #2 on: July 19, 2006, 07:28:49 AM »

That works ok, zhen, but there is one more way to do it. In my opinion, a little easier. You need my dummy files, which create an INVISIBLE image, which has 5 frames. Why? Because then you can make a nDelay, nFrame thingy to gradually change the frame. And if nFrame is the current frame on the dummy image, then if nFrame = 4, you can make that the trigger that it's delayed enough. The best part is you just gotta change the nDelay value. But i guess Zhen's way works too, and saves a little RAM, so w/e.  Grin

P.S.
Anyway, this was my first proper attempt at DSLua and I can be sure that "while true do" is much better than "loop", Thanks for that Daltonlaffs. Cheesy

Yer welcome. I remember when I was new. Check out the questions I asked. A lot there. Anyway, some people (like us) overlook some things and misinterperet others. Don't worry. I was just like you, and I am working on a huge project!
Logged

Code:
-- Bored? Read code line below.
-- Bored? Read code line above.



^^ That works, I SWEAR! ^^
Pages: [1]
« previous next »
    Jump to: