ok thnx ill try that
Printable View
ok thnx ill try that
how do you display text on a coordinate and keep it their while on another coordinate, display text and keep changing it? get what im saying?
ok nutterbuter i did what u said but now when i press "r" the value of player is permannently changed to zero. is there a way to temporarily change the value so it is zero only when r is pressed
EDIT: nvm i fixed it
Yay, i actually used my skills for good!Zitat:
Zitat von jamz1825
When you screen:print text is there a way to automatically skip a certain amount of pixels down once the text has filled the screen. If you need any more details please post... Any help would be really appreciated. Im looking for a way to make a paragraph without alot of hassle.
There is no way to automatically go to the next line. The best way to do it is as follows.
1. Open up Photoshop or the Gimp
2. Open up you picture
3. Write the text on the picture
4. Save it as a .PNG file
Unless string.gfind is implemented in the latest LuaPlayer, this is the best I can do (Note the chopping of text at the end of the line). Probably really slow as well. Press left and right to narrow widen the text width.
http://i7.tinypic.com/24o3o5e.pngCode:WHITE = Color.new(255, 255, 255);
BLACK = Color.new(0, 0, 0);
-- Just wrapping text round a screen. Problem. Chops words
Str_BigStringOfTextFromFile = "I can't tell you all how great it is to finally talk about what we've really been building in the XNA team. At GDC this year we showed off managed code running on an Xbox 360. We positioned it as a tool to help the professional industry, which it is. I expect it to be an excellent environment for casual games of all types and it will make inroads into FPS and other big games over time."
Int_TextWidth = 40;
Int_StartLineY = 1;
Int_LineHeight = 9;
while true do
PspPadState = Controls.read();
if PspPadState:start() then
break;
end
if PspPadState:left() and Int_TextWidth > 1 then
Int_TextWidth = Int_TextWidth - 1;
end
if PspPadState:right() and Int_TextWidth < 60 then
Int_TextWidth = Int_TextWidth + 1;
end
screen:clear(WHITE);
-- Get the current length of the screen
local Int_LengthOfString = string.len(Str_BigStringOfTextFromFile);
-- Get the number of lines in the string
local Int_NumberOfLines = math.abs(Int_LengthOfString / Int_TextWidth);
Int_CurrentLine = 0;
for i=0,Int_NumberOfLines do
local Str_Line = string.sub(Str_BigStringOfTextFromFile, (i*Int_TextWidth)+1, ( (i+1)*Int_TextWidth) );
screen:print(1, (Int_StartLineY+(Int_LineHeight*Int_CurrentLine)), Str_Line);
Int_CurrentLine = Int_CurrentLine + 1;
end
screen.waitVblankStart();
screen.flip();
end
I wrote a function to do this a while ago, it might help you. There are tons of comments, so read the ones at the top (just below the function definition) and see if it fits your application. It looks pretty cluttered with all of the in-code comments, but they explain what the code is doing so it should be easy to modify.Zitat:
Zitat von Dr.Gringo
Code:function printMLtext(x, y, str, color, maxlen, vspacing, maxlines)
-- DESCRIPTION
-- Divides strings to allow for easy multiline printing. Designed to be similar in syntax
-- to the screen:print command, and actually can be used as a replacement for the
-- command entirely. Note that this has been tested for the default font and default
-- text size only, although it should work with any mono-spaced font and text size.
-- LMelior 7/18/2006
--
-- INPUTS
-- "x" and "y" - the horizontal and vertical pixel location of the first character.
-- "str" - the input string
-- "color" - the color of the text
-- "maxlen" (optional, but you probably want to set this) - maximum number of
-- -- characters you want to allow on one line.
-- -- -- The default value is 60 (it is the maximum number of characters that will fit on the
-- -- -- -- PSP screen when using the PSP's default font).
-- "vspacing" (optional) - vertical spacing, in pixels, between consecutive lines of text
-- -- The default value is 15 pixels.
-- "maxlines" (optional) - allows you to define the maximum number of lines of text that
-- -- you want to display, and it will wait for player input to continue to the next line. If
-- -- -- the input string exceeds these parameters, it will only print the first screen, but it
-- -- -- -- will return the remainder of the string, so you can easily run it through again
-- -- -- -- -- (see Example 2).
-- -- -- -- -- -- The default value is 18 lines, because along with the other defaults, this
-- -- -- -- -- -- -- will fill up the entire PSP screen with text.
-- Note: if you want to define "vspacing" or "maxlines," you must define the
-- -- parameter(s) before it!
--
-- EXAMPLES
-- Example 1:
-- -- stra="This string is too long to fit on one line if the "
-- -- strb="maximum length of the line is 30 characters."
-- -- printMLtext(230, 10, stra .. strb, Color.new(255,255,255), 30)
--
-- Example 2:
-- str=(very long string)
-- while true do
-- screen:clear()
-- pad=Controls.read()
-- nextpage=printMLtext(230, 10, str, Color.new(255,255,255), 30, 15, 10)
-- if pad:cross() and nextpage~=nil then
-- screen.waitVblankStart(8)
-- str=nextpage
-- end
-- screen.waitVblankStart()
-- screen.flip()
-- end
-- Check for optional input
if maxlen==nil then
maxlen=60
end
if vspacing==nil then
vspacing=15
end
if maxlines==nil then
maxlines=18
end
-- Initialize remainder (will be overwritten if remainder exists)
local remainder=nil
if string.len(str)<=maxlen then -- you didn't need to use this!
screen:print(x,y,str,color)
else
local laststr=str -- initialize variable to hold reduced string
local strk=0 -- loop counter
local substr={} -- initialize substring table
while string.len(laststr)>maxlen do
strk=strk+1
-- Chop off string at the max length plus one and reverse it (if there's a space at maxlen+1 it's OK!)
-- -- This doesn't work on Luaplayer 0.14 for Windows, but it probably works in Luaplayer 0.20:
-- local revstr=string.reverse(string.sub(laststr,1,maxlen))
-- -- This works on Luaplayer 0.14 for windows:
local tmp=string.sub(laststr,1,maxlen+1) -- chops off string at maxlen+1
local revstr="" -- initialize revstr and then build it
for k=1,string.len(tmp) do
revstr=revstr .. string.sub(tmp,-k,-k)
end
tmp=maxlen+1-string.find(revstr," ") -- find the index of last space
-- use index to define the substring
substr[strk]=string.sub(laststr,1,tmp)
-- chop off the first substring to get ready for next loop
laststr=string.sub(laststr,tmp+2)
end
-- add the last part of the string to the table (loop terminates before this step)
strk=strk+1
substr[strk]=laststr
-- check of number of lines will fit on the screen in one printing (remainder = nil)
if strk<=maxlines then
for k=1,strk do
screen:print(x,y+(k-1)*vspacing,substr[k],color)
end
else -- print first screen and then build up remainder string from the unused substrings
for k=1,maxlines do
screen:print(x,y+(k-1)*vspacing,substr[k],color)
end
remainder=substr[maxlines+1]
for k=2,strk-maxlines do
remainder=remainder .. " " .. substr[maxlines+k]
end
end
return remainder
end
end
Thanks guys your help is really appreciated! Sorry to ask such a common question but how do i make the text bigger like 12pts to 16pts...
--Thanks
You can't do that with the in-built font, but if you use your own font you must specify the size.Zitat:
Zitat von Dr.Gringo