![]() |
|
#11
|
||||
|
||||
|
__________________
|
|
#12
|
|||
|
|||
|
im stuck on the 8th level of laserix...
__________________
![]() PSP 5.00 m33 |
|
#13
|
||||
|
||||
|
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.
__________________
|
|
#14
|
|||
|
|||
|
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
|
|
#15
|
||||
|
||||
|
hmmm. I like that. But does it prevent playign th game, or does it just show an error andthen continue?
__________________
|
|
#16
|
|||
|
|||
|
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. |
|
#17
|
|||
|
|||
|
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
__________________
Member number: 3 Meat lover? Watch: http://www.chooseveg.com/animal-cruelty.asp |
|
#18
|
|||
|
|||
|
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. |
|
#19
|
|||
|
|||
|
NOOB question, sorry :oops: but, how do i make these into lua scripts?
__________________
![]() PSP 5.00 m33 |
|
#20
|
||||
|
||||
|
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"
__________________
|
![]() |
|
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|