Seite 110 von 342 ErsteErste ... 10 60 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 160 210 ... LetzteLetzte
Zeige Ergebnis 3.271 bis 3.300 von 10238

Lua Programming Help Thread

This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; well have you put a number in the highscore text...

  
  1. #3271
    QJ Gamer Green
    Points: 7.057, Level: 55
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Ort
    Scotland, UK
    Beiträge
    571
    Points
    7.057
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    well have you put a number in the highscore text



  2. #3272
    QJ Gamer Green
    Points: 6.256, Level: 51
    Level completed: 53%, Points required for next Level: 94
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    London
    Beiträge
    645
    Points
    6.256
    Level
    51
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von JaSo PsP
    these are the variables at the start. theres nothing wrong cos it can display them in the game:
    Code:
    highscore = io.open("hiscore.txt","r")
    theHighScore = highscore:read() --this is where it reads the file, it doesnt read it as a number
    score = 0
    Im not great with lua but you opened the file with an "r" tag? Wont that mean you can only read?
    [b][center]
    [URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL]

    [url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center]

  3. #3273
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von JaSo PsP
    these are the variables at the start. theres nothing wrong cos it can display them in the game:
    Code:
    highscore = io.open("hiscore.txt","r")
    theHighScore = highscore:read() --this is where it reads the file, it doesnt read it as a number
    score = 0
    -= Double Post =-


    yer, it cant read the info in the document as a number, help!
    NVM, read mark.sarpkys post.
    --------------------------------------------------------------------------------------

  4. #3274
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    here:
    Code:
    levelTimer = Timer.new(100000)
    levelTimer:start()
    red = Color.new(255,0,0)
    background = Image.load("cloud.png")
    smiley = Image.load("smile.png")
    sad = Image.load("sad.png")
    math.randomseed(os.time())
    rx = math.random(0,442)
    ry = math.random(0,234)
    highscore = io.open("hiscore.txt","r")
    whighscore = io.open("hiscore.txt","w")
    theHighScore = highscore:read()
    boost = 2000
    score = 0
    x = 0
    y = 5
    TotalTimeLimit = 130
    -= Double Post =-
    Zitat Zitat von mark.sparky
    well have you put a number in the highscore text
    yes i have, it was 0 but i changed it to 10 and thats all thats there.

    cmon help me!!!
    Geändert von JaSo PsP (08-17-2006 um 09:18 AM Uhr) Grund: Automerged Doublepost
    ...Just Returned To The Scene...

  5. #3275
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    The problem here is that when you read from a file, its reading it in as a string, not a number. Therefore you cannot compare a number with the string.

  6. #3276
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    The problem here is that when you read from a file, its reading it in as a string, not a number. Therefore you cannot compare a number with the string.
    so how can i save a high score?
    ...Just Returned To The Scene...

  7. #3277
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    At the moment I am looking for a string to number/integer function in Lua (I really don't fancy writing one myself) but can't find any.

  8. #3278
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    At the moment I am looking for a string to number/integer function in Lua (I really don't fancy writing one myself) but can't find any.
    k, im gonna fishish off the game and post it without the hiscore thing.
    -= Double Post =-
    what do i write to make the whole thing restart? well?
    Geändert von JaSo PsP (08-17-2006 um 09:48 AM Uhr) Grund: Automerged Doublepost
    ...Just Returned To The Scene...

  9. #3279
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Note that this code is for a standalone project only. You MUST press start to exit otherwise the file doesn't not get saved:
    Code:
    WHITE = Color.new(255, 255, 255)
    
    highscore = io.open("hiscore.txt","r")
    theHighScore = highscore:read("*number")
    highscore:close()
    
    currentScore = 0
    
    while true do
    
        PspPadState = Controls.read();
    
        if PspPadState:start() then
    	    break;
    	end
    	
    	if PspPadState:circle() then
    	    currentScore = currentScore + 1
    	end
    
    	screen:clear(WHITE)
    	screen:print(1,1, "High Score    " .. theHighScore)
    	screen:print(1,9, "Current Score " .. currentScore)
    	
    	screen.waitVblankStart();
    	screen.flip();
    end
    
    if currentScore > theHighScore then
        highscore = io.open("hiscore.txt","w")
        highscore:write(currentScore)
        highscore:close()
    end

  10. #3280
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von head_54us
    Note that this code is for a standalone project only. You MUST press start to exit otherwise the file doesn't not get saved:
    Code:
    WHITE = Color.new(255, 255, 255)
    
    highscore = io.open("hiscore.txt","r")
    theHighScore = highscore:read("*number")
    highscore:close()
    
    currentScore = 0
    
    while true do
    
        PspPadState = Controls.read();
    
        if PspPadState:start() then
    	    break;
    	end
    	
    	if PspPadState:circle() then
    	    currentScore = currentScore + 1
    	end
    
    	screen:clear(WHITE)
    	screen:print(1,1, "High Score    " .. theHighScore)
    	screen:print(1,9, "Current Score " .. currentScore)
    	
    	screen.waitVblankStart();
    	screen.flip();
    end
    
    if currentScore > theHighScore then
        highscore = io.open("hiscore.txt","w")
        highscore:write(currentScore)
        highscore:close()
    end
    it works but the mem stik light keeps flashing, when i exit the app after bout 10 seconds of flashing it has saved the score?
    -= Double Post =-
    sorted it out with the flashing..
    Geändert von JaSo PsP (08-17-2006 um 10:02 AM Uhr) Grund: Automerged Doublepost
    ...Just Returned To The Scene...

  11. #3281
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Nothing I can do about that. Looks like LuaPlayer syncs to the memory card when the file is closed whcih ensures that the data is written to card and flushes the buffer. I wouldn't have thought it be 10 secs though.

  12. #3282
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    i now just need to know, when the game ends, and it says game over, how to i make triangle make the game restart? what tells the game to restart?
    -= Double Post =-
    Zitat Zitat von head_54us
    Nothing I can do about that. Looks like LuaPlayer syncs to the memory card when the file is closed whcih ensures that the data is written to card and flushes the buffer. I wouldn't have thought it be 10 secs though.
    nah thats sorted.
    -= Double Post =-
    finished game...
    Geändert von JaSo PsP (08-17-2006 um 10:29 AM Uhr) Grund: Automerged Doublepost
    ...Just Returned To The Scene...

  13. #3283
    QJ Gamer Bronze
    Points: 5.924, Level: 49
    Level completed: 87%, Points required for next Level: 26
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Earth, UK
    Beiträge
    457
    Points
    5.924
    Level
    49
    Downloads
    0
    Uploads
    0

    Standard

    restart button
    put this in/near your game over function/loop
    Code:
    if pad:triangle() then
    dofile(".index.lua")
    end
    <<Put A message Here>>
    <<Just made another rubbish website visit it here.>>

  14. #3284
    QJ Gamer Blue
    Points: 4.580, Level: 43
    Level completed: 15%, Points required for next Level: 170
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    145
    Points
    4.580
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    I keep getting this weird error:
    Heres my code:
    -- Alien Cross Hair Menu Screen

    -- Create Colors
    white = Color.new(255,255,255)
    red = Color.new(255,69,0, 195)


    -- Load Background
    Background_Menu = Image.load("./Images/back_menu.png")

    -- Load Arrow Image
    arrow = Image.load("./Images/arrow_down.png")


    -- The Loop
    while true do
    screen:blit(0,0,Backgroun d_Menu)
    screen:blit(208,193,arrow )
    oldpad = Controls.read()
    pad = Controls.read()

    -- Prints our 4 menu options
    screenrint(208,96,"Start Game",white)
    screenrint(128,144,"Credits",wh ite)
    screenrint(208,192,"How To Play",white)
    screenrint(288,144,"Exit To XMB",white)
    -- These make it so when the variable "current" changes
    -- so does the current menu selection
    if current == 1 then
    screenrint(208,96,"Start Game",red)
    screen:blit(208,97,arrow)
    end
    if current == 2 then
    screenrint(128,144,"Credits",re d)
    screen:blit(128,145,arrow )
    end
    if current == 3 then
    screenrint(208,192,"How To Play",red)
    end
    if current == 4 then
    screenrint(288,144,"Exit To XMB",red)
    screen:blit(288,145,arrow )
    end

    if pad:up then
    current = 1
    end

    if pad:left then
    current = 2
    end

    if pad:down then
    current = 3
    end

    if pad:right then
    current = 4
    end

    screen.waitVblankStart()
    screen.flip()
    oldpad = pad
    end
    Heres my error:
    Error: menu.lua:45: function arguments expected near /then/
    ??????

  15. #3285
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    if pad:down() then
    if pad:left() then
    if pad:right() then
    if pad:left() then

    You have to have function arguments after buttons.
    -= Double Post =-
    http://evilmana.com/tutorials/codebase/simple_menu.php

    I would use that to make a menu. It's much better.
    Geändert von ARza (08-18-2006 um 08:53 PM Uhr) Grund: Automerged Doublepost

  16. #3286
    QJ Gamer Blue
    Points: 4.580, Level: 43
    Level completed: 15%, Points required for next Level: 170
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    145
    Points
    4.580
    Level
    43
    Downloads
    0
    Uploads
    0

    Standard

    Hey guys, sorry for that long code, I figured out the problem, I just forgot to put the () infront of my pads
    LOL, aha.
    EDIT:
    aww, someone beat me to it.

    Hold on, I have another question.
    Whats the correct coding for getting back to the XMB?

  17. #3287
    Developer
    Points: 5.650, Level: 48
    Level completed: 50%, Points required for next Level: 100
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    USA, Virginia
    Beiträge
    580
    Points
    5.650
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    there is no code to get back to XMB from luaplayer. but you can the eboot from the modded luaplayer and use the System.Quit() command as LMelior stated before.. PM me if you need help with that.

  18. #3288
    QJ Gamer Green
    Points: 9.165, Level: 64
    Level completed: 39%, Points required for next Level: 185
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Ort
    England ~¦¦¦|+|¦¦¦~
    Beiträge
    1.112
    Points
    9.165
    Level
    64
    My Mood
    Bored
    Downloads
    0
    Uploads
    0

    Standard

    where does it actually define the variable 'current'?
    ...Just Returned To The Scene...

  19. #3289
    Points: 3.957, Level: 40
    Level completed: 4%, Points required for next Level: 193
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    36
    Points
    3.957
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    ok...
    you know how when u screen:blit it makes the image show up?
    well is there a way you can do the opposite?

    like i want it so when i press r my first image dissapeers and a new one comes up.

    i have thing sort of working but when i press r the new image shows up just on top of the old one. and they both continue to like they are spossed too.
    please tell me what i have to do to make the original dissapear when r is pressed. here is my code..


    Player = { }
    Player[1] = { x = 200, y = 197 }

    while true do
    pad = Controls.read()
    screen:clear()
    screen:blit(Player[1].x,Player[1].y,player)

    if pad:l() and Player[1].x > 0 then
    Player[1].x = Player[1].x - 2
    end

    if pad:r() and Player[1].x < screenwidth then
    Player[1].x = Player[1].x + 2
    screen:blit(Player[1].x,Player[1].y,player2)
    end

  20. #3290
    QJ Gamer Green
    Points: 6.256, Level: 51
    Level completed: 53%, Points required for next Level: 94
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    London
    Beiträge
    645
    Points
    6.256
    Level
    51
    Downloads
    0
    Uploads
    0

    Standard

    @ Jamz, when you blit an image it isnt actually written to the screen. Its written to the buffer. When flip.Screen is executed the buffer is drawn to the screen. So you put what you want blitted in an if loop. I dont know lua, but ill try.

    Code:
    if playerblit = 1 then
    
     //* Blit code for player.
    
    end
    
    //* Then set up a pad input so that if R is pressed playerblit equals 0
    [b][center]
    [URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL]

    [url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center]

  21. #3291
    Points: 3.957, Level: 40
    Level completed: 4%, Points required for next Level: 193
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    36
    Points
    3.957
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    ok thnx ill try that

  22. #3292
    QJ Gamer Silver
    Points: 13.092, Level: 74
    Level completed: 61%, Points required for next Level: 158
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    Removable Disk (G:)
    Beiträge
    1.698
    Points
    13.092
    Level
    74
    Downloads
    0
    Uploads
    0

    Standard

    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?

    [_ıииeя_тυяκ*_]
    Turkish Power >_<

  23. #3293
    Points: 3.957, Level: 40
    Level completed: 4%, Points required for next Level: 193
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    36
    Points
    3.957
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    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

  24. #3294
    QJ Gamer Green
    Points: 6.256, Level: 51
    Level completed: 53%, Points required for next Level: 94
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    London
    Beiträge
    645
    Points
    6.256
    Level
    51
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von jamz1825
    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!
    [b][center]
    [URL="http://forums.qj.net/showthread.php?t=65032"][SIZE="3"][COLOR="Blue"]Omicron[/COLOR] - [COLOR="DeepSkyBlue"]A hacking simulation game for the PSP[/COLOR][/SIZE][/URL]

    [url=http://profile.mygamercard.net/dr+nutterbutter][img]http://card.mygamercard.net/gbar/live/dr+nutterbutter.gif[/img][/url][/b][/center]

  25. #3295
    QJ Gamer Blue
    Points: 4.119, Level: 40
    Level completed: 85%, Points required for next Level: 31
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    106
    Points
    4.119
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    When you screenrint 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.

  26. #3296
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    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

  27. #3297
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    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.
    Code:
    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

  28. #3298
    Developer
    Points: 4.318, Level: 41
    Level completed: 84%, Points required for next Level: 32
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    205
    Points
    4.318
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Dr.Gringo
    When you screenrint 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.
    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.

    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

  29. #3299
    QJ Gamer Blue
    Points: 4.119, Level: 40
    Level completed: 85%, Points required for next Level: 31
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Beiträge
    106
    Points
    4.119
    Level
    40
    Downloads
    0
    Uploads
    0

    Standard

    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

  30. #3300
    Developer
    Points: 5.162, Level: 46
    Level completed: 6%, Points required for next Level: 188
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Tauranga, New Zealand
    Beiträge
    355
    Points
    5.162
    Level
    46
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Dr.Gringo
    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.


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 07:53 AM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .