forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

quick & dirty code for easily getting text input

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
Dark Killer



Joined: 25 Jan 2005
Posts: 32

PostPosted: Wed Sep 21, 2005 9:18 am    Post subject: quick & dirty code for easily getting text input Reply with quote

Just some simple code to get user inputted text. Someone may find it usefull:

Code:
--Quick and dirty LUA text input example
--by: Dark Killer

--You are free to modify and/or implement this in your own projects, all I ask in return is that you credit me.

--Controls:
--  Up/Down: select character
--  X: add character
--  R: space
--  L: backspace
--  Start: submit   

function Controls.waitpadup() --pauses execution untill all buttons are released
   pad=Controls.read()
   while pad:select() or pad:start() or pad:up() or pad:right() or pad:down() or pad:left() or pad:l() or pad:r() or pad:triangle() or pad:circle() or pad:cross() or pad:square() do
      screen.waitVblankStart()
      pad=Controls.read()
   end
end

   a=65
   c=""
   while true do
      screen:clear(Color.new(0,0,0))
      screen:print(100, 100, "what is your name?", Color.new(0,255,0))
      if a<65 then
         a=90
      end
      if a>90 then
         a=65
      end
      b=string.char(a)
      screen:print(118, 110, c..b, Color.new(0,255,0))
      pad = Controls.read()
      if pad:up() then
         a=a+1
         Controls.waitpadup()
      end   
      if pad:down() then
         a=a-1
         Controls.waitpadup()
      end
      if pad:cross() then
         c=c..b
         Controls.waitpadup()
      end
      if pad:r() then
         c=c.." "
         Controls.waitpadup()
      end
      if pad:l() then
         c=string.sub(c, 1, (string.len(c)-1))
         Controls.waitpadup()
      end
      if pad:start() then
         screen:print(100, 140, "hello," .. c..b .. "!", Color.new(255,0,0))
         Controls.waitpadup()
         screen.waitVblankStart()
         screen.flip()
         while true do
            screen.waitVblankStart()
         end
      end
   screen.waitVblankStart()
   screen.flip()
   end
Back to top
View user's profile Send private message AIM Address
Mmy



Joined: 08 Aug 2005
Posts: 9

PostPosted: Sat Sep 24, 2005 10:21 pm    Post subject: Reply with quote

This is very intriguing, what i'd like to know is if there is a way to save the name to a file, .lua, .txt whatever. If there is, how does one go about doing it? (i have been unsuccesful in my searching of it.
Back to top
View user's profile Send private message
officiallypoor



Joined: 10 Sep 2005
Posts: 8

PostPosted: Sun Sep 25, 2005 12:32 am    Post subject: Reply with quote

Yes how do we go about having a high score script with this text imput
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group