Seite 310 von 342 ErsteErste ... 210 260 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 ... LetzteLetzte
Zeige Ergebnis 9.271 bis 9.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; how would i go about stopping the timer on a specific time? (5 Min. or 10Min.) Sorry for all the ...

  
  1. #9271
    QJ Gamer Green
    Points: 2.866, Level: 32
    Level completed: 78%, Points required for next Level: 34
    Overall activity: 0%

    Registriert seit
    Nov 2007
    Beiträge
    6
    Points
    2.866
    Level
    32
    Downloads
    0
    Uploads
    0

    Standard

    how would i go about stopping the timer on a specific time? (5 Min. or 10Min.)

    Sorry for all the questions ^^
    Code:
    TIMER:
    screen:clear()
    System.usbDiskModeActivate()
    
    red = Color.new(255, 0, 0)
    grey = Color.new(94, 97, 111)
    
    screen:print(13, 5, "Press L-Trigger to ARM BOMB and R-Trigger to DISARM BOMB.", grey)
    screen:flip()
    
    Timer = Timer.new(0)
    
    while true do
    	screen.waitVblankStart(5)
    	pad = Controls.read()
    	if pad:l() then
    		Timer:reset()
    		Timer:start()
    		while true do
    			pad = Controls.read()
    			screen:clear()
    			screen:print(13, 5, "Press L-Trigger to ARM BOMB and R-Trigger to DISARM BOMB.", grey)
    			screen:print(220, 133, tostring(math.floor(Timer:time()/1000/60) .. ":" .. math.floor((Timer:time()/1000/60-math.floor(Timer:time()/1000/60))*60) .. ":" .. string.sub(tostring(math.floor(Timer:time()/10)), -2)), red)
    			screen:flip()
    			if pad:r() then
    				Timer:stop()
    				break
    			end
    		end
    	elseif pad:start() then dofile("script.lua")
    	end
    end


    Geändert von psporpcp (08-17-2008 um 08:45 PM Uhr)

  2. #9272
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

  3. #9273
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Is there a way to draw a Square grid to the screen using lua(NO IMAGES)??

  4. #9274
    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

    dan - is there a drawLine function in Lua?
    Code:
    SQUARE_SIZE = 10 -- how many pixels per grid square
    GRID_WIDTH = 10  -- how many squares across
    GRID_HEIGHT = 10 -- how many squares down
    GRID_COLOR = Color.new(0,255,0) -- color of the grid lines
    GRID_OFFSET_X = 240 - SQUARE_SIZE * GRID_WIDTH / 2 -- offset the grid on the X axis by this many pixels
    GRID_OFFSET_Y = 136 - SQUARE_SIZE * GRID_HEIGHT / 2 -- "      "    "   "  "  Y  "    "   "   "     "
    
    function drawGrid(target)
      for y = 0, GRID_HEIGHT do
        for x = 0, GRID_WIDTH do
          -- draws lines from the top of the grid to the bottom going across
          target:drawLine(x * SQUARE_SIZE + GRID_OFFSET_X, GRID_OFFSET_Y,
                          x * SQUARE_SIZE + GRID_OFFSET_X, SQUARE_SIZE * GRID_HEIGHT + GRID_OFFSET_Y, GRID_COLOR)
          -- draws lines from the left of the grid to the right going down
          target:drawLine(GRID_OFFSET_X, y * SQUARE_SIZE + GRID_OFFSET_Y,
                          SQUARE_SIZE * GRID_WIDTH + GRID_OFFSET_X, y * SQUARE_SIZE + GRID_OFFSET_Y, GRID_COLOR)
        end
      end
    end
    
    drawGrid(screen)
    
    screen.flip()
    
    while not Controls.read():cross() do
    end
    With those parameters set that'll draw a green 10x10 grid in the center of the screen with each grid square being 10x10 as well. Modular programming ftw...

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


  5. #9275
    QJ Gamer Bronze
    Points: 5.381, Level: 47
    Level completed: 16%, Points required for next Level: 169
    Overall activity: 0%

    Registriert seit
    Jul 2006
    Beiträge
    550
    Points
    5.381
    Level
    47
    Downloads
    1
    Uploads
    0

    Standard

    Pff, beaten.

    Code:
    WIDTH = 10
    HEIGHT = 10
    SPACING = 10
    
    white = Color.new(255, 255, 255)
    
    for i = 0, WIDTH do
    	screen:drawLine(i * SPACING, 0, i * SPACING, HEIGHT * SPACING, white)
    end
    for i = 0, HEGIHT do
    	screen:drawLine(0, i * SPACING, WIDTH * SPACING, i * SPACING, white)
    end

  6. #9276
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Thanks, damn forgot about drawLine.

  7. #9277
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    i suggest drawing the lines to one singular Image.createEmpty() and then blitting that image to the screen it might speed it up slightly, rather than doing as show in the examples 20 loops and draw lines each time you go through the main while loop

    from what i understand you meant no image files.
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  8. #9278
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von FaT3oYCG Beitrag anzeigen
    i suggest drawing the lines to one singular Image.createEmpty() and then blitting that image to the screen it might speed it up slightly, rather than doing as show in the examples 20 loops and draw lines each time you go through the main while loop

    from what i understand you meant no image files.
    Drawline is slow but not nearly as slow as blitting images. As long as its not like the whole screen and can be incorporated into another image thats there anyways, drawLineing each loop is much faster

  9. #9279
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    I was wondering if this would work

    Code:
    if pad:up() then
        Adhoc:send(up)
    end
    Code:
    pad = Adhoc:recv()
    if pad == up then
        Player.img = Player.img + speed
    end
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  10. #9280
    QJ Gamer Blue
    Points: 5.672, Level: 48
    Level completed: 61%, Points required for next Level: 78
    Overall activity: 32,0%

    Registriert seit
    Dec 2007
    Ort
    Netherlands
    Beiträge
    148
    Points
    5.672
    Level
    48
    Downloads
    0
    Uploads
    0

    Standard

    i think u should send a string like "padButtonUp"
    and if the received is that string do code.
    [SIZE="1"][color=#D1D1FF]______________________________________________________________[/color]
    [i]Last edited by basfreak; 01-01-1990 at [color=#666686]12:00 PM[/color][/i].[/SIZE]

  11. #9281
    Lua guy
    Points: 11.690, Level: 71
    Level completed: 10%, Points required for next Level: 360
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Ort
    Wales, cardiff
    Beiträge
    1.442
    Points
    11.690
    Level
    71
    My Mood
    Blah
    Downloads
    0
    Uploads
    0

    Standard

    Yeah, i did mean no images.So bliting images is slow?I knew it took up memory but slow?Blitting an image always seemed pretty fast to me.

  12. #9282
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    You've OBVIOUSLY never made a CPU-intensive game.

  13. #9283
    Developer and Tutor.
    Points: 8.736, Level: 62
    Level completed: 96%, Points required for next Level: 14
    Overall activity: 0%

    Registriert seit
    Jul 2007
    Ort
    Widnes, England
    Beiträge
    1.649
    Points
    8.736
    Level
    62
    My Mood
    Happy
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von TurtlesPwn Beitrag anzeigen
    Drawline is slow but not nearly as slow as blitting images. As long as its not like the whole screen and can be incorporated into another image thats there anyways, drawLineing each loop is much faster
    my bad, i do that when i am displaying lots of images, i blit them to one image and then i dont have to blit every image every loop, i didnt realise that drawline is done differently or that it was faster.
    ------ FaT3oYCG -----
    AKA Craig, call me what you want to It's your preference.
    My Website: http://www.modern-gamer.co.uk/

    Currently working on:
    (0) MediaGrab
    (0) PGE Gears Of War - On hold (Very large project).
    (0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).

  14. #9284
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    For images, yes, one is faster than lots, but drawline is just....
    a line.....

    a line != an image

  15. #9285
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    My assumption is that whatever drawline function you are using modifies the the pixels manually, using a line algorithm. If you have access to the GU, which you do, you are better off writing your own function that uses GU_LINES.

  16. #9286
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Yes and that is certainly MUCH faster but you're forgetting that this person needed help making a grid and thus the GU would be a bit out of his current level.....

  17. #9287
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Regardless, he should know there is a faster way so when he gains the experience, he can do it the right way.

  18. #9288
    QJ Gamer Bronze
    Points: 8.665, Level: 62
    Level completed: 72%, Points required for next Level: 85
    Overall activity: 0%

    Registriert seit
    Mar 2007
    Beiträge
    758
    Points
    8.665
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Someone should just make a draw line function using the GU anyways so that drawing lines will be so much faster!

  19. #9289
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Except there are a lot of different ways you would want to do it for different uses and a generic function would have to account for all of that and thus be rather slow in comparison to other unique uses

  20. #9290
    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, I suppose you could take my drawGrid function and convert it to use fillRect since the 'lines' are at pi/2, pi, 2/3*pi, 2pi and can be represented by a rectangle easily, plus it'd be faster then a drawLine...

    fillScreenRect
    Code:
    void fillScreenRect(Color color, int x0, int y0, int width, int height)
    {
    	if (!initialized) return;
    	int skipX = PSP_LINE_SIZE - width;
    	int x, y;
    	Color* data = getVramDrawBuffer() + x0 + y0 * PSP_LINE_SIZE;
    	for (y = 0; y < height; y++, data += skipX) {
    		for (x = 0; x < width; x++, data++) *data = color;
    	}
    }
    drawLine:
    Code:
    static void drawLine(int x0, int y0, int x1, int y1, int color, Color* destination, int width)
    {
    	int dy = y1 - y0;
    	int dx = x1 - x0;
    	int stepx, stepy;
    	
    	if (dy < 0) { dy = -dy;  stepy = -width; } else { stepy = width; }
    	if (dx < 0) { dx = -dx;  stepx = -1; } else { stepx = 1; }
    	dy <<= 1;
    	dx <<= 1;
    	
    	y0 *= width;
    	y1 *= width;
    	destination[x0+y0] = color;
    	if (dx > dy) {
    		int fraction = dy - (dx >> 1);
    		while (x0 != x1) {
    			if (fraction >= 0) {
    				y0 += stepy;
    				fraction -= dx;
    			}
    			x0 += stepx;
    			fraction += dy;
    			destination[x0+y0] = color;
    		}
    	} else {
    		int fraction = dx - (dy >> 1);
    		while (y0 != y1) {
    			if (fraction >= 0) {
    				x0 += stepx;
    				fraction -= dy;
    			}
    			y0 += stepy;
    			fraction += dx;
    			destination[x0+y0] = color;
    		}
    	}
    }

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


  21. #9291
    QJ Gamer Bronze
    Points: 7.257, Level: 56
    Level completed: 54%, Points required for next Level: 93
    Overall activity: 0%

    Registriert seit
    Dec 2007
    Ort
    B.F.
    Beiträge
    328
    Points
    7.257
    Level
    56
    My Mood
    Psychedelic
    Downloads
    1
    Uploads
    0

    Standard Lua Bind Error Using Netlib

    Got a Little trouble when using Yourseam's Netlib Library.
    Its returns: error index lua (Line 52) : Bind Error

    here is the 52th Line:

    Code:
    serverSocket = Socket.createServerSocket(17852)

    and the whole code:

    Code:
    selec = 1
    
    noms = "serveur 1"
    
    blanc = Color.new(255,255,255)
    noir = Color.new(0,0,0)
    
    ip = Wlan.getIP()
    
    fleche = Image.load("images/epee.png") 
    fd = Image.load("images/co.png") 
    
    fi = io.open("nom.txt" , "r")   
    fdc = fi:read("*n") 
    fi:close() 
    
    oldpad = Controls.read() 
    
    while true do
    screen:clear()
    pad = Controls.read() 
    
    screen:blit(0,0,fd) 
    
    
    dofile("netlib.lua")
    netlib_server = "66.25.53.65"
    netconnect()
    
    if selec == 0 then
    selec = 1
    end
    
    if selec == 3 then
    selec = 2
    end
    
    if selec == 1 then
    screen:blit(40,60,fleche) 
    end
    if selec == 2 then
    screen:blit(162,181,fleche) 
    end
    
    if pad:down() and oldpad:down() ~= pad:down() then
    selec = selec + 1
    end
    if pad:up() and oldpad:up() ~= pad:up() then
    selec = selec - 1
    end
    
    serverSocket = Socket.createServerSocket(17852) --Here is the Line of error 
    
    if pad:cross() and oldpad:cross() ~= pad:cross() and selec == 1 then
    Socket.connect(netlib_server, 17852)
    if Socket:isConnected() == "true" then
    dofile("carte1-1.lua")
    end
    end
    
    if pad:cross() and oldpad:cross() ~= pad:cross() and selec == 2 then
    System.message("Voulez-vous quitter le jeu ?", 1)
    Bouton = System.buttonPressed(1)
    if Bouton == "Yes" then
       System.Quit()
    end
    end
    
    screen:print(400,0,ip,blanc)
    screen:print(85,77,noms,noir)
    screen.flip()
    screen.waitVblankStart()
    oldpad = pad
    end

  22. #9292
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    while true do
    screen:clear()
    pad = Controls.read() 
    
    screen:blit(0,0,fd) 
    
    
    dofile("netlib.lua")
    netlib_server = "66.25.53.65"
    netconnect()
    You're loading netlib and then starting the connection every single loop. Those last three lines belong BEFORE your main loop.
    And then why are you creating a server socket in the first place for using netlib? No need to......

    Also, you should indent your code and it would be a lot easier to read.

  23. #9293
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    How do you get luaplayer to check the music folder for an mp3 and play all of them one after another.
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  24. #9294
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Open the folder with listDirectory, loop through the list and play it if its a .mp3

  25. #9295
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Usually, raping LuaPlayer with a large metal pipe will get it to do whatever you want. Just make sure it knows who its daddy is.

  26. #9296
    QJ Gamer Green
    Points: 5.875, Level: 49
    Level completed: 63%, Points required for next Level: 75
    Overall activity: 0%

    Registriert seit
    Jul 2008
    Ort
    In your pocket.
    Beiträge
    192
    Points
    5.875
    Level
    49
    My Mood
    Angelic
    Downloads
    0
    Uploads
    0

    Standard

    Can you post a code example thanks.
    AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13

  27. #9297
    QJ Gamer Green
    Points: 3.721, Level: 38
    Level completed: 48%, Points required for next Level: 79
    Overall activity: 0%

    Registriert seit
    Jan 2008
    Beiträge
    612
    Points
    3.721
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Digikid13 Beitrag anzeigen
    Can you post a code example thanks.
    I made it as simple as it gets.
    Open the directory and get a listing with System.listDirectory
    Loop through the items with a for loop
    Play each one

    What more is there to it? Asking for code indicates incompetence and a copynpasting noob. Try to do it yourself and ask for help on EXACTLY what you can't figure out.

  28. #9298
    QJ Gamer Blue
    Points: 4.268, Level: 41
    Level completed: 59%, Points required for next Level: 82
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    497
    Points
    4.268
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    Usually, raping LuaPlayer with a large metal pipe will get it to do whatever you want. Just make sure it knows who its daddy is.
    hahahahahaha lol thats halarious

  29. #9299
    QJ Gamer Blue
    Points: 3.795, Level: 38
    Level completed: 97%, Points required for next Level: 5
    Overall activity: 27,0%

    Registriert seit
    Jul 2007
    Beiträge
    296
    Points
    3.795
    Level
    38
    Downloads
    0
    Uploads
    0

    Standard

    On a serious note, I was looking through the docs, and found this function:
    Code:
    System.PlayAllMp3sInASpecificDirectoryOneAfterTheOther(dirname)
    You should try that.

  30. #9300
    QJ Gamer Blue
    Points: 4.268, Level: 41
    Level completed: 59%, Points required for next Level: 82
    Overall activity: 0%

    Registriert seit
    Apr 2008
    Beiträge
    497
    Points
    4.268
    Level
    41
    Downloads
    0
    Uploads
    0

    Standard

    lol


 

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

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