Tuesday, 02 December 2008
 
  Home arrow Forum  
Main Menu
Home
News
Forum
Documentation
Download
Links
Administrator
Login Form
Welcome, Guest. Please login or register.
December 02, 2008, 07:50:39 AM
Username: Password:
Login with username, password and session length

Forgot your password?
Reset the Stylus
DSLua Community
Welcome, Guest. Please login or register.
December 02, 2008, 07:50:39 AM
1723 Posts in 315 Topics by 6333 Members
Latest Member: kneemiage
DSLua Community  |  General DS Programming Chats  |  Code Hashing  |  Reset the Stylus « previous next »
Pages: [1]
Author Topic: Reset the Stylus  (Read 749 times)
nonchip
New Moon
*
Posts: 9


Advanced DSLua programmer


« on: October 21, 2007, 08:54:17 AM »

I wrote a menu for a paint project.
Code:
require("functions.inc.lua")
SCREEN_TOP    = 1
SCREEN_BOTTOM = 0
BGTopText = Screen.LoadTextBG()
BGBotText = Screen.LoadTextBG()
Screen.Initialize( SCREEN_TOP,    BGTopText )
Screen.Initialize( SCREEN_BOTTOM, BGBotText )

BGTopText:PrintXY( 1, 5, "Hi "..DSLua.UserName().."!" )
BGTopText:PrintXY( 3, 5, "Welcome to SKETCH" )
while Pads.Start() == false do
    BGBotText:PrintXY(1,2,"Click for Keyboard-Mode")
    BGBotText:PrintXY(1,5,"Click for Stylus-Mode")
    BGBotText:PrintXY(1,8,"Click for Stylus-Line-Mode")
    while true do
        DSLua.LidCloseAction()
        if stylusInTextBox(1, 1, 5, 3) then
            DSLua.WaitForNoKey()
            BGBotText:Clear()
            dofile("sketch_keyboard.lua")
            break
        end
        if stylusInTextBox(1, 4, 5, 6) then
            DSLua.WaitForNoStylus()
            BGBotText:Clear()
            dofile("sketch_stylus_free.lua")
            break
        end
        if stylusInTextBox(1, 7, 5, 9) then
            DSLua.WaitForNoStylus()
            BGBotText:Clear()
            dofile("sketch_stylus_lines.lua")
            break
        end
    end
end

stylusInTextBox(x1, y1, x2, y2) runs stylusInBox(x1*8, y1*8, x2*8, y2*Cool to get text-screen coords.

But if i use this, and don't tap the screen after selecting the mode, it restarts the same mode automatically, because the coords are the same.
how can i reset the stylus coords?Huh



PS: I think i add a button to drag the "Click here to ..."-button to
« Last Edit: October 21, 2007, 11:28:43 AM by nonchip » Logged

Sorry for my bad english.I'm german.
daltonlaffs
Waxing Gibbous
****
Posts: 340


Freaking Insane


WWW
« Reply #1 on: October 22, 2007, 03:18:46 PM »

Resetting coordinates is next to impossible, but there is a solution to this problem: The Stylus.Down() function.

Here's a fixed version of your code:

Code:
require("functions.inc.lua")
SCREEN_TOP    = 1
SCREEN_BOTTOM = 0
BGTopText = Screen.LoadTextBG()
BGBotText = Screen.LoadTextBG()
Screen.Initialize( SCREEN_TOP,    BGTopText )
Screen.Initialize( SCREEN_BOTTOM, BGBotText )

BGTopText:PrintXY( 1, 5, "Hi "..DSLua.UserName().."!" )
BGTopText:PrintXY( 3, 5, "Welcome to SKETCH" )
while Pads.Start() == false do
    BGBotText:PrintXY(1,2,"Click for Keyboard-Mode")
    BGBotText:PrintXY(1,5,"Click for Stylus-Mode")
    BGBotText:PrintXY(1,8,"Click for Stylus-Line-Mode")
    while true do
        DSLua.LidCloseAction()
if Stylus.Down() then
        if stylusInTextBox(1, 1, 5, 3) then
            DSLua.WaitForNoKey()
            BGBotText:Clear()
            dofile("sketch_keyboard.lua")
            break
        end
        if stylusInTextBox(1, 4, 5, 6) then
            DSLua.WaitForNoStylus()
            BGBotText:Clear()
            dofile("sketch_stylus_free.lua")
            break
        end
        if stylusInTextBox(1, 7, 5, 9) then
            DSLua.WaitForNoStylus()
            BGBotText:Clear()
            dofile("sketch_stylus_lines.lua")
            break
        end
    end
end
end

The simple addition was to check whether the Stylus is on the screen or not. If not, the stylusInBox commands aren't even run, so the old coordinates are not processed.
Logged

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



^^ That works, I SWEAR! ^^
nonchip
New Moon
*
Posts: 9


Advanced DSLua programmer


« Reply #2 on: October 25, 2007, 01:34:11 PM »

thanks, but i think the DnD-method I use is a cool demonstration of the DSLua functions.
Logged

Sorry for my bad english.I'm german.
Pages: [1]
« previous next »
    Jump to:  



    (C) 2008 DSLua

    DSLua - Best scripting language for Nintendo DS home-brew!