Page 2 of 5 FirstFirst 1 2 3 4 ... LastLast
Results 11 to 20 of 48

Thread: Nifty scripts

  
  1. #11
    RaiderX's Avatar
    RaiderX is offline Senior Member -Hacks Titan
    Join Date
    Jun 2005
    Posts
    4,192
    Rep Power
    20

    Default

    ok, I'm gonna have to discect the original LUAfireworks to get the gravity code. The reaosn I wnat gravity is to add "tabletip" to my Wooly Willey game so u can drop all the dots to one side. i'll figure it out!


  2. #12
    qwerty is offline Senior Member -Hacks Veteran
    Join Date
    Jun 2005
    Location
    Texas
    Posts
    1,281
    Rep Power
    15

    Default

    im stuck on the 8th level of laserix...

    PSP 5.00 m33

  3. #13
    RaiderX's Avatar
    RaiderX is offline Senior Member -Hacks Titan
    Join Date
    Jun 2005
    Posts
    4,192
    Rep Power
    20

    Default

    ooo. I forgot about that game, I ahd it but havent playede it yet. been too busy with other stuff. o well, i play it later.

  4. #14
    modsyn is offline -Hacks Guru
    Join Date
    Aug 2005
    Location
    Shinigami Kurosaki Ichigo!
    Posts
    2,475
    Rep Power
    16

    Default

    This is an all-inclusive learning script. I didn't document the code at all,
    but I have a bit at the top explaining what all I'm accomplishing with it
    and how to test its funcionality.

    Code:
    --[[ Example Script for demonstrating swapping backgrounds and how to handle 
    	files not being found in LUA. Also demonstrates the values of the analog
    	stick, the os.time(), and the os.difftime() functions for getting time values.
    
    	provided by modsyn.
    
    	Test this script this way: put files 0.PNG, 1.PNG, 2.PNG, 3.PNG, 4.PNG and 5.PNG
    	in the same directory as the script. Run the script, hitting X to reset the timer
    	and swap the images. Then, delete one of the .PNG files and run it again. Instead
    	of crashing (like I'm sure has happened with your scripts before) when the image is
    	not found, it creates a blank canvas and writes a filenotfound error message to the
    	screen.
    
    	I hope everyone enjoys this. 
    ]]
    
    System.usbDiskModeActivate()
    red = Color.new(255, 0, 0);
    white = Color.new(255, 255, 255);
    black = Color.new(0,0,0)
    canvas = Image.load("0.png")
    
    mode = 0
    oldTime = os.time()
    time = 0
    
    oldPad = Controls.read()
    while true do
    
    	pad = Controls.read()
    	dx = pad:analogX()
    	dy = pad:analogY()
    
    	if pad:cross() then
    		if pad ~= oldPad then
    			time = os.difftime(os.time(),oldTime)
                      oldTime = os.time()
    			mode = mode + 1
    			if math.mod(mode, 6) == 0 then
    				mode = 0
    			end
                      file = io.open(tostring(mode)..".PNG","r")
                      if file then
    				canvas = Image.load(tostring(mode)..".PNG")
    			else
    				canvas = Image.createEmpty(480, 272)
    				canvas:clear(black)
                            canvas:print(120,120,"Image " .. tostring(mode+1) .. ".PNG not found!!!",white)
    			end
    		end
    	end
    
    	screen:blit(0, 0, canvas, 0, 0, canvas:width(), canvas:height(), false)
    	screen:print(11, 11, "dx: " .. tostring(dx), white)
    	screen:print(11, 21, "dy: " .. tostring(dy), white)
    	screen:print(11, 31, "mode = " .. tostring(mode), white)
    	screen:print(11, 41, "time difference = " .. tostring(time), white)
    	screen.waitVblankStart()
    	screen.flip()
    	if pad:start() then break end
    	if pad:select() then screen:save("screenshot.tga") end
    	oldPad = pad
    end
    jMEnc Guide, jMEnc2 page - by the way, you smell nice

  5. #15
    RaiderX's Avatar
    RaiderX is offline Senior Member -Hacks Titan
    Join Date
    Jun 2005
    Posts
    4,192
    Rep Power
    20

    Default

    hmmm. I like that. But does it prevent playign th game, or does it just show an error andthen continue?

  6. #16
    modsyn is offline -Hacks Guru
    Join Date
    Aug 2005
    Location
    Shinigami Kurosaki Ichigo!
    Posts
    2,475
    Rep Power
    16

    Default

    it normally displays an image. if the image isn't found it shows a black
    screen and a message but doesn't quit. normally, it will crash if you try
    to load a picture that isn't found.
    jMEnc Guide, jMEnc2 page - by the way, you smell nice

  7. #17
    LordCthulu is offline Senior Member -Hacks Enthusiast
    Join Date
    Mar 2005
    Posts
    578
    Rep Power
    14

    Default

    Hey modsyn I made a drawing script that includes your script to show the position of the analog stick.
    I gave you credit in the readme. Lemme know if your cool with it.
    Heres the script (also uploaded the .rar in my first post in this topic)

    Code:
    System.usbDiskModeActivate()
    red = Color.new(255, 0, 0);
    white = Color.new(255, 255, 255);
    blue = Color.new(0, 0, 255);
    black = Color.new(0, 0, 0);
    green = Color.new(0, 255, 0);
    
    canvas = Image.createEmpty(480, 272)
    canvas:clear(white)
    
    brush = {}
    eraser = {}
    
    x0 = 0
    y0 = 0
    x1 = 0
    y1 = 0
    
    drawColor = 0;
    
    while true do
    
       pad = Controls.read()
       dx = pad:analogX()
       dy = pad:analogY()
    	if math.abs(dx) > 32 then
    		x0 = x0 + dx / 64
    	end
    	dy = pad:analogY()
    	if math.abs(dy) > 32 then
    		y0 = y0 + dy / 64
    	end
    
    	if pad:cross() then
          if drawColor == 0 then
             canvas:drawLine(x0, y0, x1, y1, black)
          elseif drawColor == 1 then
             canvas:drawLine(x0, y0, x1, y1, red)
          elseif drawColor == 2 then
             canvas:drawLine(x0, y0, x1, y1, blue)
          elseif drawColor == 3 then
             canvas:drawLine(x0, y0, x1, y1, green)
          end
       end
    
       if pad:up() then
          drawColor = 0
       elseif pad:down() then
          drawColor = 1
       elseif pad:left() then
          drawColor = 2
       elseif pad:right() then
          drawColor = 3
       end
    
       if pad:triangle() then
          canvas:clear(white)
       end
    	x1 = x0
    	y1 = y0
    	screen:blit(0, 0, canvas, 0, 0, canvas:width(), canvas:height(), false)
    	screen:drawLine(x1 - 5, y1, x1 + 5, y1, red)
    	screen:drawLine(x1, y1 - 5, x1, y1 + 5, red)
       screen:print(11, 11, "X: " .. tostring(dx), red)
       screen:print(11, 21, "Y: " .. tostring(dy), red)
    
       screen.waitVblankStart()
       screen.flip()
       if pad:start() then break end
       if pad:select() then screen:save("screenshot.tga") end
    end
    Oldest psp-hacks member ever.

  8. #18
    modsyn is offline -Hacks Guru
    Join Date
    Aug 2005
    Location
    Shinigami Kurosaki Ichigo!
    Posts
    2,475
    Rep Power
    16

    Default

    i'm most definitely cool with it. anything i post here can be used by
    anyone. most of that stuff i got from the tutorials, anyway.
    jMEnc Guide, jMEnc2 page - by the way, you smell nice

  9. #19
    qwerty is offline Senior Member -Hacks Veteran
    Join Date
    Jun 2005
    Location
    Texas
    Posts
    1,281
    Rep Power
    15

    Default

    NOOB question, sorry :oops: but, how do i make these into lua scripts?

    PSP 5.00 m33

  10. #20
    RaiderX's Avatar
    RaiderX is offline Senior Member -Hacks Titan
    Join Date
    Jun 2005
    Posts
    4,192
    Rep Power
    20

    Default

    open up notepad ans type in the script. Then save as "all files" and save it as "script.lua" or if u are gonna use it in the Lwoser application, "index.lua"

Page 2 of 5 FirstFirst 1 2 3 4 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •