Seite 111 von 342 ErsteErste ... 11 61 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 161 211 ... LetzteLetzte
Zeige Ergebnis 3.301 bis 3.330 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; Okay, heres my code: Code: -- Alien Crosshair Game Screen -- Completally Coded by Mailas Gonrai -- Most errors fixed ...

  
  1. #3301
    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

    Okay, heres my code:
    Code:
    -- Alien Crosshair Game Screen
    -- Completally Coded by Mailas Gonrai
    -- Most errors fixed by pjspeedy and yaustar
    -- Colors
    black = Color.new(0,0,0)
    blue = Color.new(191, 255, 195)
    yellow = Color.new(255, 255, 0, 200)
    green=Color.new(0,255,0, 195)
    white = Color.new(255,255,255)
    red = Color.new(255,69,0, 195)
    
    -- ETC Variables
    displayTime = math.random(2,5)
    counter = 0
    speed = 1
    offscreen = false
    pad = Controls.read()
    -- Functions
    function RandomPoint()
    end
    math.randomseed(os.time())
    
    -- Images
    back = Image.load("./Images/back_game.png")
    crosshair = Image.load("./Images/crosshair.png")
    border = Image.load("./Images/game_border.png")
    alienimage = Image.load("./Images/alien.png")
    
    -- Music
    Music.playFile("./Music/grmus.it")
    
    -- Objects
    Player = {}
    Player.x = 208
    Player.y = 112
    
    alien = {}
    alien.x = math.random(1,3)
    alien.y = math.random (1,3)
    alien = {x = 0, y = 200}
    x_point = 23
    y_point = 83
    
    -- Health Equivelent Options
    Player.health = 100
    healthbar = {}
    healthbar.y = 10
    
    
    function movePlayer()
    	if pad:left() then
    		Player.x = Player.x - 4
    	end
    
    	if pad:right() then
    		Player.x = Player.x + 4
    	end
    	
    	if pad:down() then
    		Player.y = Player.y + 4
    	end
    
    	if pad:up() then
    		Player.y = Player.y - 4
    	end
    end
    
    function perimeterSize()
    	if Player.x > 480 - 64 then
    		Player.x = 480 - 64
    	end
    	
    	if Player.x < 0 then
    		Player.x = 0
    	end
    
    	if Player.y > 272 - 64 then
    		Player.y = 272 - 64
    	end
    	
    	if Player.y < 0 then
    		Player.y = 0
    	end
    end
    
    
    
    -- THE LOOP!----------------------------------------------------------
    
    while true do
    
    	screen:clear()
    	x_point = math.random(1,480)
    y_point = math.random(1,272)
    AlienMove()
    
            if alien.x < x_point then
    alien.x = alien.x + 2
    end
    if alien.x > x_point then
    alien.x = alien.x - 2
    end
    if alien.y < y_point then
    alien.y = alien.y + 2
    end
    if alien.y < y_point then
    alien.y = alien.y - 2
    end
    if alien.x == x_point and alien.y == y_point then
    RandomPoint()
    end
    					
    		
    		counter = counter + 1
    	
    		if counter >= displayTime then
    			alien.x = math.random(1,3)
    			alien.y = math.random (1,3)
    				end
    	
    		if alien.x == 1 then
    			alien.x = 224
    			alien.y = 182
    		end
    	
    		if alien.x == 2 then
    			alien.x = 60
    			alien.y = 132
    		end
    	
    		if alien.x == 3 then
    			alien.x = 404
    			alien.y = 154
    		end
    	
    			
    		displayTime = math.random(500,2000)
    		counter = 0
    	end
    	
    	screen:blit(0,0,back)
                        screen:blit(alien.x,alien.y,alienimage)	
                        screen:blit(Player.x,Player.y,crosshair)
    	screen:blit(0,0,border)
    	
    	screen:fillRect(320,240,Player.health,healthbar.y,green)
    	screen:print(320,230,Player.health,blue)
    	
    	movePlayer()
    	perimeterSize()
    	alienscreenSize()
    	
    	if pad:l() then
    		dofile("menu.lua")
    	end
    
    	screen.waitVblankStart()
    	screen.flip()
    end
    And my error:
    error: ./game.lua:159: /<eof>/ expected near /end/



  2. #3302
    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

    displayTime = math.random(500,2000)
    counter = 0
    end
    The 'end' there is messing your script up. Remove it.

  3. #3303
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Technically, its the end at the very end. Putting that mis-placed end where he does have it, closes the main loop, and until something breaks it, everything beyond it is useless... Removing hte ending end would also solve it ;) Just not how you would want it.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  4. #3304
    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 SG57
    Technically, its the end at the very end. Putting that mis-placed end where he does have it, closes the main loop, and until something breaks it, everything beyond it is useless... Removing hte ending end would also solve it ;) Just not how you would want it.
    Yes, I assumed he wanted a solution that would help him.

  5. #3305
    QJ Gamer Green
    Points: 8.746, Level: 62
    Level completed: 99%, Points required for next Level: 4
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    www.ultimatetalkforums.com Games, RPG, quickchat and more!
    Beiträge
    532
    Points
    8.746
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Could anyone tell me how to make it so...in the end of your code when if it sais like..press x how do i make it read another text document...


    so how do i make it read another text thing after i press abuton...code please =-)
    [CENTER][COLOR=black][COLOR=black][URL="http://forums.qj.net/f-psp-firmware-discussion-253/t-psp-firmware-30-get-it-58053.html"][COLOR=cyan]would you upgrade?[/COLOR][/URL] [/COLOR][FONT=Times New Roman][COLOR=navy][URL="http://www.mindistortion.net/iwantyoursoul/?i_am=altunozara"]OMG ITS REAL![/URL][/COLOR][/FONT][COLOR=black] [URL="http://forums.qj.net/showthread.php?t=61756&page=1&pp=10"][COLOR=lime]Sony vs Nintendo[/COLOR][/URL][/COLOR][/COLOR][/CENTER]
    [CENTER] [/CENTER]
    [CENTER][URL="http://www.ultimatetalkforums.com"][IMG]http://i94.photobucket.com/albums/l82/Altunozara/userbar2.jpg[/IMG][/URL][/CENTER]
    [CENTER][SIZE=3]i [/SIZE][URL="http://forums.qj.net/www.gamingwell.com"][SIZE=3]wonder what could be under this hyperlink..hmm[/SIZE][/URL][/CENTER]
    [CENTER][SIZE=3][COLOR=green][B][I]Maniakc is awsome!!![/I][/B][/COLOR][/SIZE][/CENTER]
    [CENTER][FONT=Arial Black][SIZE=3][COLOR=#660099][I][U][URL="http://forums.qj.net/member.php?u=58299"]The Brain Pwns!!![/URL][/U][/I][/COLOR][/SIZE][/FONT][/CENTER]

    [COLOR=sienna]Creator of:[/COLOR][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-go-go-go-beta-66652.html"][COLOR=sienna]GO GO GO![/COLOR][/URL]

  6. #3306
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    dofile("path.lua")

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  7. #3307
    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

    @ Gonrai
    If you wanted you could improve your code's efficiency by combining the functions movePlayer() and perimeterSize() like this:
    Code:
    function movePlayer()
    	if pad:left() and Player.x > 0 then
    		Player.x = Player.x - 4
    	end
    
    	if pad:right() and Player.x < 480 - 64 then
    		Player.x = Player.x + 4
    	end
    	
    	if pad:down() and Player.y < 272 - 64 then
    		Player.y = Player.y + 4
    	end
    
    	if pad:up() and Player.y > 0 then
    		Player.y = Player.y - 4
    	end
    end
    It's a small improvement, sure, but if your project becomes large, it's the little things like this that you have to watch for and improve.


    @ altunozara

    Code:
    file=io.open("yourfile.txt","r")
    documenttext=file:read("*a")
    file:close()
    The variable "documenttext" will be one long string containing all of the characters in your text file, including possibly the character representations of escape sequences. Be aware that unless your file is essentially one line (e.g. you didn't press Enter while you were making the text file), you may have some funky characters like that.

  8. #3308
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    is it possible to clear some part of the screen and not everything

  9. #3309
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    I think it is, but i forgot how.
    What did we think the world would look like in 2015?

    Zitat Zitat von Abe
    Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
    http://forums.qj.net/501501-post26.html

  10. #3310
    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

    Heres what I did:
    I looked at what emulator guy said and was kinda confused because
    1. the math.random on displayTime is 2,5, not 200,5000
    2. There is no end under the counter variable.

    THen, I looked at SG57's post and I removed the end so it looks like this:
    Code:
    if pad:l() then
    		dofile("menu.lua")
    	end
    
    	screen.waitVblankStart()
    	screen.flip()
    At the end of my script. But heres what happened:
    When I loaded my game on my menu script, it just froze.

  11. #3311
    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

    @hallo007

    Zitat Zitat von hallo007
    is it possible to clear some part of the screen and not everything
    I'm not sure what you mean...just stop blitting whatever it is to screen? But you could always cheat and make a rectangle to cover up part of the screen.
    Code:
    coverup=Image.createEmpty(240,272)
    screen:blit(0,0,coverup)
    To cover up the left half. Many coders use a separate image variable that they "build up" and then they only have to blit that to screen. I call mine "prescreen" but you may have seen "offscreen" in some codes:
    Code:
    prescreen=Image.createEmpty(480,272)
    -- (blit everything to prescreen)
    coverup=Image.createEmpty(240,272)
    prescreen:blit(0,0,coverup)
    screen:blit(0,0,prescreen)
    I've been told this is faster than blitting everything directly to the screen buffer, though I've never actually tested this. It just seems cleaner so I always do it.



    @ Gonrai

    Zitat Zitat von Gonrai
    2. There is no end under the counter variable.
    Direct from your post above (with indentations left in):
    Code:
    		displayTime = math.random(500,2000)
    		counter = 0
    	end
    Sure looks like it to me, and besides SG57 even told you that it wouldn't work (he teases Lua coders for kicks ).

  12. #3312
    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

    index.lua:2: error loading sound? help?!
    edit. heres the code
    iyk = Sound.load("iyk.wav")
    iyklay()
    Music.volume(128)

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

  13. #3313
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    actually, that presreen thing will use more RAM and be slower, because it has to create the image
    What did we think the world would look like in 2015?

    Zitat Zitat von Abe
    Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
    http://forums.qj.net/501501-post26.html

  14. #3314
    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

    Zitat Zitat von xsorifc28
    index.lua:2: error loading sound? help?!
    edit. heres the code
    iyk = Sound.load("iyk.wav")
    iyklay()
    Music.volume(128)
    i dont get it. why am i getting an error?

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

  15. #3315
    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

    My code:
    Code:
    -- Alien Crosshair Game Screen
    -- Completally Coded by Mailas Gonrai
    -- Most errors fixed by pjspeedy and yaustar
    -- Colors
    black = Color.new(0,0,0)
    blue = Color.new(191, 255, 195)
    yellow = Color.new(255, 255, 0, 200)
    green=Color.new(0,255,0, 195)
    white = Color.new(255,255,255)
    red = Color.new(255,69,0, 195)
    
    -- ETC Variables
    displayTime = math.random(2,5)
    counter = 0
    speed = 1
    offscreen = false
    pad = Controls.read()
    -- Functions
    function RandomPoint()
    end
    math.randomseed(os.time())
    
    -- Images
    back = Image.load("./Images/back_game.png")
    crosshair = Image.load("./Images/crosshair.png")
    border = Image.load("./Images/game_border.png")
    alienimage = Image.load("./Images/alien.png")
    
    -- Music
    Music.playFile("./Music/grmus.it")
    
    -- Objects
    Player = {}
    Player.x = 208
    Player.y = 112
    
    alien = {}
    alien.x = math.random(1,3)
    alien.y = math.random (1,3)
    alien = {x = 0, y = 200}
    x_point = 23
    y_point = 83
    
    -- Health Equivelent Options
    Player.health = 100
    healthbar = {}
    healthbar.y = 10
    
    
    function movePlayer()
    	if pad:left() then
    		Player.x = Player.x - 4
    	end
    
    	if pad:right() then
    		Player.x = Player.x + 4
    	end
    	
    	if pad:down() then
    		Player.y = Player.y + 4
    	end
    
    	if pad:up() then
    		Player.y = Player.y - 4
    	end
    end
    
    function perimeterSize()
    	if Player.x > 480 - 64 then
    		Player.x = 480 - 64
    	end
    	
    	if Player.x < 0 then
    		Player.x = 0
    	end
    
    	if Player.y > 272 - 64 then
    		Player.y = 272 - 64
    	end
    	
    	if Player.y < 0 then
    		Player.y = 0
    	end
    end
    
    
    
    -- THE LOOP!----------------------------------------------------------
    
    while true do
    
    	screen:clear()
    	x_point = math.random(1,480)
    y_point = math.random(1,272)
    AlienMove()
    
            if alien.x < x_point then
    alien.x = alien.x + 2
    end
    if alien.x > x_point then
    alien.x = alien.x - 2
    end
    if alien.y < y_point then
    alien.y = alien.y + 2
    end
    if alien.y < y_point then
    alien.y = alien.y - 2
    end
    if alien.x == x_point and alien.y == y_point then
    RandomPoint()
    end
    					
    		
    		counter = counter + 1
    	
    		if counter >= displayTime then
    			alien.x = math.random(1,3)
    			alien.y = math.random (1,3)
    				end
    	
    		if alien.x == 1 then
    			alien.x = 224
    			alien.y = 182
    		end
    	
    		if alien.x == 2 then
    			alien.x = 60
    			alien.y = 132
    		end
    	
    		if alien.x == 3 then
    			alien.x = 404
    			alien.y = 154
    		end
    	
    			
    		
    	screen:blit(0,0,back)
                        screen:blit(alien.x,alien.y,alienimage)	
                        screen:blit(Player.x,Player.y,crosshair)
    	screen:blit(0,0,border)
    	
    	screen:fillRect(320,240,Player.health,healthbar.y,green)
    	screen:print(320,230,Player.health,blue)
    	
    	movePlayer()
    	perimeterSize()
    	alienscreenSize()
    	
    	if pad:l() then
    		dofile("menu.lua")
    	end
    
    	screen.waitVblankStart()
    	screen.flip()
    end
    It now gives me this error:
    Code:
    error: ./game.lua:95: attempt to call a global /ALienMove/ ( a nil value)
    Error: No script file found.
    Press start to Restart.

  16. #3316
    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

    Alienmove isnt classed as a function
    -= Double Post =-
    You never did function Alienmove()
    You just did Alienmove()
    -= Double Post =-
    Zitat Zitat von xsorifc28
    i dont get it. why am i getting an error?
    Have you checked that the sound file is not too big or too long for Lua Player
    Geändert von JoeDaStudd (08-23-2006 um 11:13 AM Uhr) Grund: Automerged Doublepost
    <<Put A message Here>>
    <<Just made another rubbish website visit it here.>>

  17. #3317
    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 heres the deal..

    i need some code to make my character shoot a bullet at wherever my crosshair image is. ive tried ALOT and cant get anything working

    my character scrolls left to right at the bottom of my screen. The crosshair can go anywhere by using the directional buttons.

    so could someone tell me how to do this?

  18. #3318
    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

  19. #3319
    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

    trust me ive studied that, it just shoots them left right up or down


    i need mine to shhot to wherever the crosshair is (that could be any x,y position)

  20. #3320
    is not posting very often
    Points: 33.152, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 99,6%

    Registriert seit
    Feb 2006
    Ort
    omnipresent
    Beiträge
    5.162
    Points
    33.152
    Level
    100
    Downloads
    0
    Uploads
    0

    Standard

    make the cross hairs position x and y.

    Then just have the bullets final location as X and Y
    What did we think the world would look like in 2015?

    Zitat Zitat von Abe
    Either way, if you don't know, don't guess. Stick to answering questions about stuff you're qualified to answer, like Pokemon questions or something along those lines.
    http://forums.qj.net/501501-post26.html

  21. #3321
    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

    if you look at the evil mana tut its not as easy as just changing some xy positions

    he has it set up diferent

  22. #3322
    Developer
    Points: 8.360, Level: 61
    Level completed: 70%, Points required for next Level: 90
    Overall activity: 16,0%

    Registriert seit
    Jun 2005
    Ort
    At my house...
    Beiträge
    886
    Points
    8.360
    Level
    61
    Downloads
    0
    Uploads
    0

    Standard

    Sorry i dont have time to read all of your code but do you have a Controls.read(); at all to intialize the buttons?

    Edit: nvm found it
    F.A.L.O?

  23. #3323
    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

    Zitat Zitat von JoeDaStudd
    Have you checked that the sound file is not too big or too long for Lua Player
    size is 450kb...its like 15-20 secs long.

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

  24. #3324
    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

    can someone pleas post a snippet to find ur current FPS???
    --------------------------------------------------------------------------------------

  25. #3325
    QJ Gamer Blue
    Points: 4.519, Level: 42
    Level completed: 85%, Points required for next Level: 31
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    120
    Points
    4.519
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I wanted to add a typewriter effect but I get an error.

    Code:
     -- EVILMANA.COM PSP LUA CODEBASE
    -- www.evilmana.com/tutorials/codebase
    -- Typewriter Effect for Text
    -- SUBMITTED BY: dennis van den broek
    
    -- Code : DS (dialogue system)
    -- Autor: Dennis van den broek
    
    white = Color.new(255, 255, 255)
    
    -- initialise if the DS (dialogue system) should be called
    DS_set = 0
    
    -- strings used for the effect
    DS_str = { }
    DS_str[1] = "This is a typewriter machine test..."
    DS_str[2] = "This code is a test which can be used freely,"
    DS_str[3] = "in any type of game, credits are allways welcome"
    
    -- temp string that stores the current to write string
    write_str = ""
    str_length = 0
    -- counter for holding where on the string we are
    i = 1
    num = 1
    
    -- sets the DS on or off
    function init_DS(type)
            if type == 1 then
                    DS_set = 1
            else
                    DS_set = 0
                    num = 1
            end
    end
    
    -- checks what string to write, function should be upgraded with detection of which
    string to print
    -- currently it's a simple placeholding code
    function set_DS()
            if num > 3 then
                    init_DS(0)
            end
            
            Typewriter(DS_str[num], 2, 10, 100)
    end
    
    -- the actual code, input the string you wanna print, and how many characters per
    frame you wanna show up...
    function Typewriter(str, speed, DSx, DSy)
            read_str = str
            str_length = string.len(read_str)
            
            if i <= str_length then
                    i = i+speed
                    write_str = string.sub(read_str, 1, i)
    
                    screen:print(DSx, DSy, write_str, white)
            else
                    screen:print(DSx, DSy, write_str, white)
                    if pad:cross() and oldpad:cross() ~= pad:cross() then
                            i = 0
                            num = num + 1
                    end
            end
    end
    
    -- main while loop
    while true do
            pad = Controls.read()
    
            if pad:cross() and oldpad:cross() ~= pad:cross() then
                    init_DS(1)
            end
            
            if DS_set == 1 then
                    set_DS()
            end
    
            screen.waitVblankStart()
            screen.flip()
    
            screen:clear()
            oldpad = pad
    end

  26. #3326
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    how about you post the error... Why wouldnt you saying you need help?

    And I dont have time to read through the code and see whats wrong, even with an the error, but I can say having any 'screen' calls after you flip the display buffer is pointless. remove the screen:clear, it has no effect.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  27. #3327
    QJ Gamer Blue
    Points: 4.519, Level: 42
    Level completed: 85%, Points required for next Level: 31
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    120
    Points
    4.519
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    I get this error.
    Code:
     Error: index.lua:38 /=/ expected near /to/

  28. #3328
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    Well, go to line 38, see if there is something there that shouldnt be... Looks to me that the comment got brought out of the -- segment, making an error... Simply add '--' before 'string' on line 38.

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  29. #3329
    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

    And on all of the other lines where comments are.

  30. #3330
    QJ Gamer Blue
    Points: 4.519, Level: 42
    Level completed: 85%, Points required for next Level: 31
    Overall activity: 0%

    Registriert seit
    Apr 2006
    Beiträge
    120
    Points
    4.519
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Ok I got it to work. Now If I want to exit my program, do I just input
    Code:
     if pad:start() then 
    exit


 

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 09:01 PM Uhr.

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