PSP Hacks - Forums
Go Back   PSP Hacks - Forums > Tech Talk > LUA Scripting

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 09-10-2008, 03:43 PM
dlevans dlevans is offline
PSP Smarty
 
Join Date: Apr 2008
Location: kansas
Posts: 135
dlevans User Has a Beginner Reputation
Default

i just downloaded the phoneix game engine and i was messing around with the lua scripts and i was wondering on the on screen keyboard script what would be the syntax so it would display text then have the user type something and keep going like this
hello welcome to pge lua!
enter your name:
--osk would pop up
your name is :txt:
enter your birthday:
--osk again
--calculate age
you are: X years old

also on the save data script could you save a lua script so you could keep adding to it like names or phone numbers or anything?

thanks
Reply With Quote
  #2  
Old 09-10-2008, 04:53 PM
hotrocker hotrocker is offline
Programmer
PSP Hacker
 
Join Date: Jun 2007
Location: yesterday
Posts: 855
hotrocker User Has a Beginner Reputation
Default

this would prolly get more attn in the lua programming section :)
__________________

(Compliments of Chode)
Reply With Quote
  #3  
Old 09-10-2008, 06:34 PM
dlevans dlevans is offline
PSP Smarty
 
Join Date: Apr 2008
Location: kansas
Posts: 135
dlevans User Has a Beginner Reputation
Default

can you move it... i dont want to double post
Reply With Quote
  #4  
Old 09-11-2008, 03:04 AM
Blade_punk's Avatar
Blade_punk Blade_punk is offline
Moderator
PSP Monk
 
Join Date: Nov 2006
Location: Candy Mountain
Posts: 2,686
Blade_punk will become famous soon enoughBlade_punk will become famous soon enough
Default

Moved
__________________
The PSP Programming and Development Mega Thread
-Rock Station-
PSN: Xsjado7
Quote:
Why don't you try walking on your hands! Then you could use your feet for hi-5's and eating sandwiches. You know, all the important stuff!
Reply With Quote
  #5  
Old 09-11-2008, 12:10 PM
InsertWittyName InsertWittyName is offline
Programmer
PSP Newbie
 
Join Date: Jun 2008
Posts: 41
InsertWittyName User Has a Beginner Reputation
Default

You would basically just repeat the OSK sample several times, once for each event.

Make an attempt at it yourself, then come back and post code if you require further help.

You can save whatever you want as savedata.
__________________
Reply With Quote
  #6  
Old 09-11-2008, 02:59 PM
dlevans dlevans is offline
PSP Smarty
 
Join Date: Apr 2008
Location: kansas
Posts: 135
dlevans User Has a Beginner Reputation
Default

okay ill try it once i get it working ill try loading some txt off the memory stick kinda like a scheduler where the saves are your tasks for the day
Reply With Quote
  #7  
Old 09-11-2008, 03:46 PM
dlevans dlevans is offline
PSP Smarty
 
Join Date: Apr 2008
Location: kansas
Posts: 135
dlevans User Has a Beginner Reputation
Default

okay im a little confused
Code:
-- Load the font, 16 pixels in height, to RAM
verdana16 = pge.font.load("verdana.ttf", 16, PGE_RAM)

-- Check the font loaded correctly
if not verdana16 then
	error("Failed to load font.")
end

-- Init OSK with description, initial text and check success
if not pge.utils.oskinit("Test Description", "Initial Text") then
	error("Error on osk init.")
end

-- Create two colors
white = pge.gfx.createcolor(255, 255, 255)
red = pge.gfx.createcolor(255, 0, 0)

enabled = true
done = false
text = ""
text2 = ""
x = 0
y = 0
counter = 0

-- Loop until exit requested
while pge.running() do

	-- Update controls
	pge.controls.update()

	-- Start drawing
	pge.gfx.startdrawing()
	
	-- Clear screen (to black)
	pge.gfx.clearscreen()
	
	-- Draw a rectangle
	pge.gfx.drawrect(x, y, 100, 60, red)
	
	-- If OSK not being drawn, draw some text
	if not enabled then
		verdana16:activate()
		verdana16:printcenter(130, white, text)
		verdana16:active()
		verdana16:printcenter(125, white, text2)
	end
	
	-- End drawing
	pge.gfx.enddrawing()
	
	if enabled then
		-- pge.utils.oskupdate() must be called after pge.gfx.enddrawing(), but before pge.gfx.swapbuffers()
		done, text = pge.utils.oskupdate()
		
		if done then
			if text == "" then
				text = "User cancelled."
				
			else
				text = "User entered: " .. text
				pge.utils.oskinit("Test Description", "enter second text")
				text2 = pge.utils.oskupdate()
				text = "user entered: " .. text2
			end
		end
	end
	
	-- Swap buffers
	pge.gfx.swapbuffers()
	
	-- Increment counter
	counter = counter + 1
	
	-- Set the rectangle to a random screen position
	if counter >= 60 then
		counter = 0
		x = pge.math.randfloat(0, 380)
		y = pge.math.randfloat(0, 212)
	end
	
	-- If RIGHTTRIGGER pressed, end
	if pge.controls.pressed(PGE_CTRL_RTRIGGER)and pge.controls.pressed(PGE_CTRL_LTRIGGER) then
		break
	end
	
end

verdana16 = nil

white = nil
red = nil
state = nil
enabled = nil
done = nil
text = nil
text2 = nil
x = nil
y = nil
counter = nil
hangs on an error but
Code:
-- Load the font, 16 pixels in height, to RAM
verdana16 = pge.font.load("verdana.ttf", 16, PGE_RAM)

-- Check the font loaded correctly
if not verdana16 then
	error("Failed to load font.")
end

-- Init OSK with description, initial text and check success
if not pge.utils.oskinit("Test Description", "Initial Text") then
	error("Error on osk init.")
end

-- Create two colors
white = pge.gfx.createcolor(255, 255, 255)
red = pge.gfx.createcolor(255, 0, 0)

enabled = true
done = false
text = ""
text2 = ""
x = 0
y = 0
counter = 0

-- Loop until exit requested
while pge.running() do

	-- Update controls
	pge.controls.update()

	-- Start drawing
	pge.gfx.startdrawing()
	
	-- Clear screen (to black)
	pge.gfx.clearscreen()
	
	-- Draw a rectangle
	pge.gfx.drawrect(x, y, 100, 60, red)
	
	-- If OSK not being drawn, draw some text
	if not enabled then
		verdana16:activate()
		verdana16:printcenter(130, white, text)
		verdana16:active()
		verdana16:printcenter(125, white, text2)
	end
	
	-- End drawing
	pge.gfx.enddrawing()
	
	if enabled then
		-- pge.utils.oskupdate() must be called after pge.gfx.enddrawing(), but before pge.gfx.swapbuffers()
		done, text = pge.utils.oskupdate()
		
		if done then
			if text == "" then
				text = "User cancelled."
				
			else
				pge.utils.oskinit("Test Description", "enter second text")
				text = "User entered: " .. text
				text2 = "user entered: " .. text2
			end
		end
	end
	
	-- Swap buffers
	pge.gfx.swapbuffers()
	
	-- Increment counter
	counter = counter + 1
	
	-- Set the rectangle to a random screen position
	if counter >= 60 then
		counter = 0
		x = pge.math.randfloat(0, 380)
		y = pge.math.randfloat(0, 212)
	end
	
	-- If RIGHTTRIGGER pressed, end
	if pge.controls.pressed(PGE_CTRL_RTRIGGER)and pge.controls.pressed(PGE_CTRL_LTRIGGER) then
		break
	end
	
end

verdana16 = nil

white = nil
red = nil
state = nil
enabled = nil
done = nil
text = nil
text2 = nil
x = nil
y = nil
counter = nil
doesnt display text or text2 just keeps looping the osk with the intial text "enter second text" but no text is ever entered and the first osk never comes up i changed exit to Ltrigger and Rtrigger cuz i like pressing start on the osk and it kept exiting that works fine but it doesnt display any text at all
Reply With Quote
Reply

 



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:16 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©