http://luaplayer.org/forums/index.php?topic=20.0 is best for psp lua coding ;)
Printable View
http://luaplayer.org/forums/index.php?topic=20.0 is best for psp lua coding ;)
Hey everyone, i just released my egyptian ratscrew game over on the forums... check it out!
When blitting with the Gu, prints and fillRects always appear above the image blitted, aswell as transparency on the image appearing black.
Has anyone found a fix for any of these issues? It would help allot.
fillRect before gu blit.
hey i was wondering if anyone knows a way to read a line from a different lua file to get the value of its variable almost like dofile("...") but i just need it for 1 line in order...for example read the name a player enters thanks in advance
variables are stored in memory until released by code, so any variables created during the execution of 1 script will still be available when jumping to another script using dofile. Although, I have to say that this is a very sloppy way of coding and i would definately rethink how you are structuring your functions.Zitat:
Zitat von pspsalv2
I've already tried that. Do you mind providing an example?Zitat:
Zitat von Da_MerV
im having trouble. i added a collision script into my code for a small box in the bottom right of the screen but now whenever i jump and try and land on the box, the player just goes straight through it.
heres my code:
shouldnt something like:Code:green=Color.new(0,255,0)
white = Color.new(255,255,255)
rightbarrier=477
leftbarrier=1
upbarrier=1
downbarrier=270
oldpad = Controls.read()
player = Image.createEmpty(32,32)
j = false
gy = 240
gx = 0
player:clear(white)
block = Image.createEmpty(240,32)
block:clear(green)
Player = { x = 2, y = 238 }
playerHeight = 32
playerWidth = 32
Block = {}
Block[4] = { x = 240, y = 240, height = block:height(), width = block:width() }
function collision()
if (Player.y < upbarrier) then
Player.y = 3
end
if (Player.x < leftbarrier) then
Player.x = 3
end
if (Player.x + playerWidth > rightbarrier) then
Player.x = 464
end
if (Player.y + playerHeight > downbarrier) then
Player.y = 238
end
end
function movePlayer()
pad = Controls.read()
if pad:start() then
exitgame = 1
end
if pad:left() then
Player.x = Player.x - 2
end
if pad:right() then
Player.x = Player.x + 2
end
end
function collisionCheck(object)
if (Player.x + playerWidth > object.x) and (Player.x < object.x + object.width) and (Player.y + playerHeight > object.y) and (Player.y < object.y + object.height) then
Player.x = oldx
Player.y = oldy
end
end
while true do
if exitgame ==1 then
break
end
pad = Controls.read()
screen:clear()
if j then
if gx < 50 then gx = gx + 2 end
if gx == 50 then j = false end
end
Player.y = gy - gx
if pad:cross() and not oldpad:cross() and not j then
j = true
end
if gx > 0 and not j then
gx = gx - 1
end
oldx = Player.x
oldy = Player.y
screen:clear()
collision()
movePlayer()
collisionCheck(Block[4])
screen:blit(Player.x,Player.y,player)
for a = 1,4 do
screen:blit(Block[4].x,Block[4].y,block)
end
screen.waitVblankStart()
screen.flip()
end
work?Code:if (Player.y > 206) and (Player.x > 240) then
Player.y = 206
end
You used the wrong operator in the second oneCode:if (Player.y > 206) and (Player.x < 240) then
Player.y = 206
end
no, thats rght. the box is in the bottom right of the screen. the further to the right of the screen the bigger the x coordinate
Ohh sorry i read it as them both being Player.y lol :pZitat:
Zitat von Xsjado7
all good. so does anyone know what i can do?
that code means that if the plaer jumped on the box then he would be reset so try it if it doesnt post here again and ill do it for youCode:if (Player.y > 206) and (Player.x > 240) then
Player.y = 206
end
It's pretty simple really. Take a few minutes to think logically about the order in which you do your player movements and collision checks.Zitat:
Zitat von Xsjado7
do you mean the actual order that i write it? sorry, im looking for a quick fix. my brain isnt working to well at the moment :down:
Here's a function i wrote for one of my projects:
So just try that like:Code:function collision(x1, y1, w1, h1, x2, y2, w2, h2)
if x1 + w1 > x2 and x1 < x2 + w2 and y1 + h1 > y2 and y1 < y2 + h2 then
return true
else
return false
end
end
Hope that helps you :)Code:if collision(player.x, player.y, player.width, player.height, box.x, box.y, box.width, box.height) then
screen:print(0,0,"Collision",Color.new(255,255,255))
end
thanks, il try it :tup:
i know its a bit off subject but yongo why wont you carry on with your app it sounded like it was going to be good you just have to ignore the stupid people sometimes and carry on !!!!!!!!!!!
i agree, it sounded mad
hi all, ive decided to dive back into lua for a while and have forgotten most of what i learnt before ...
When it is executed and i press up i see both spritesheets. I have tried to fix it in different ways but it still happens ...Code:white = Color.new(255,255,255)
dofile("animLib.lua")
skull = Image.createEmpty(32,32)
Skull = { width=skull:width(), height=skull:height(), (front1)}
Skull.x = 200
Skull.y = 200
f = SS.new("forward", "png", 20, 60)
d = SS.new("down", "png", 20, 60)
while true do
screen:clear()
pad = Controls.read()
if pad:up() then
screen:clear()
f:blit(Skull.x, Skull.y, 50)
Skull.y = Skull.y - 1
end
if pad:down() then
screen:clear()
d:blit(Skull.x, Skull.y, 50)
Skull.y = Skull.y + 1
end
screen.waitVblankStart()
screen.flip()
end
PS: when pressing down, its fine ...
try this
Code:white = Color.new(255,255,255)
dofile("animLib.lua")
skull = Image.createEmpty(32,32)
Skull = { width=skull:width(), height=skull:height(), (front1)}
Skull.x = 200
Skull.y = 200
f = SS.new("forward", "png", 20, 60)
d = SS.new("down", "png", 20, 60)
ssno = 0
while true do
pad = Controls.read()
screen:clear()
if
pad:up()
then
ssno = 1
end
if
ssno == 1
then
screen:clear()
f:blit(Skull.x, Skull.y, 50)
Skull.y = Skull.y - 1
end
if
pad:down()
then
ssno = 2
end
if
ssno == 2
then
screen:clear()
d:blit(Skull.x, Skull.y, 50)
Skull.y = Skull.y + 1
end
screen.waitVblankStart()
screen.flip()
end
nope :(
-= Double Post =-
nvm i messed up on the sprites height :p
i know i found the error and sent you the new code lol
no hard feelings lol
:Jump:
Tsk tsk. Well all right, a better hint then! But you're getting off easy.Zitat:
Zitat von Xsjado7
Your main loop:
Get it?Code:while true do
if exitgame ==1 then break end
pad = Controls.read()
screen:clear()
if j then
if gx < 50 then gx = gx + 2 end
if gx == 50 then j = false end -- you should use else here
end
Player.y = gy - gx --***************Exhibit A*******************
if pad:cross() and not oldpad:cross() and not j then
j = true
end
if gx > 0 and not j then
gx = gx - 1
end
oldx = Player.x
oldy = Player.y --***************Exhibit B*******************
screen:clear()
collision()
movePlayer()
collisionCheck(Block[4]) --***************Exhibit C*******************
screen:blit(Player.x,Player.y,player)
for a = 1,4 do
screen:blit(Block[4].x,Block[4].y,block)
end
screen.waitVblankStart()
screen.flip()
end
hey everyone,
@LMelior: it didnt work but thanks for trying.
anyways iv moved onto something else: flashing. iv got my code set up quite nicely so far but i have run into a few snags.
1. my app doesnt wait for me to press X before flashing
2. my 01-12.bmp that is going to be flashed dissapears when i run the program for some unkown reason.
has anyone got any ideas on what could be causing these problems? thanks in advance
...thank god for Pandora...Zitat:
Zitat von Xsjado7
:ROFL:Zitat:
Zitat von KelptoOne
lua is the easiest thing to learn when coding for psp
how come i see alot of questions for lua games, but none of the games released?
get used to it.Zitat:
Zitat von Urameshi
you know, i havent noticed that...Zitat:
Zitat von Urameshi
meh, WIPs..
im almost finished my little app and i fixed my problems no thanks to you guys :Argh: haha no hard feelings, i know i do seem like a noob but i do have a pretty good understanding of lua. just one question. when i overwrite a file in the flash it cuts the file from the memory stick instead of copying it. anyway to make it copy instead? thanks
Code:System.writeFile("path:/to/file","path:/to/destination", delete source file? "yes" or "no")
haha it was write underneath my nose, i thought that meant overwrite if a file of the asme name is present. thanks myshoo
Depends. Some people can understand C/C++ better then Lua.Zitat:
Zitat von EminentJonFrost
Compiling my lua script will help improve speed, correct? If so, what should I use to compile it? I've tried the XtreamLua Compiler with no luck.
EDIT: Nevermind, I got the XtreamLua Compiler to work.
I did not "try" to fix it for you, because that's not a good way to help people. I was pointing out what was wrong. You moved your character (Exhibit A), then you set the "old" x and y positions to the current x and y positions (Exhibit B), and then checked for collision (Exhibit C). When the objects collide, you move the current x and y back to the old x and y, which - guess what - is exactly the same, thanks to your second step. So, like I said the first time, think about the order in which you do things.Zitat:
Zitat von Xsjado7
No, it doesn't improve execution speed. I think if you compile a file that you want to include with dofile or loadfile, then it speeds up the loading process, but if I recall correctly, that's the only speed benefit. Your best bet right now is to optimize your code. Once Luaplayer 0.21 is released though, the execution speed will be considerably better.Zitat:
Zitat von andyauff
I see. Thanks.Zitat:
Zitat von LMelior
Hi guys, did anyone have any joy trying to use WLAN on Lua Player 0.20?
I've been trying to access a file on my server to get some specific data for a HB I'm developing at the moment, but it just hangs. I've found lots of workaround, but none of them seem to work.
I even thought I was doing something wrong, so I tried to run the WLAN code from the sample, which looks pretty much like what I developed, but it just hangs too.
Did anyone get this sample to work?
Cheers,
Marcos Placona
Are you overclocking your psp? you have to keep the processor at default settings if you want to use wlan.Zitat:
Zitat von placo23
I've changed everything, but it still doesn't work. I've changed my clock to default, changed Wlan.useConnectionConfig( 1) to Wlan.useConnectionConfig( 2), changed the hard reset to enabled and nothing.
Does WLAN hava any problem with WPA?
cheers