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; dofile("index.lua") should do fine but if you want the whole LUAplayer load up again then use break. Something like this: ...
-
10-17-2006, 02:25 AM #3721
dofile("index.lua") should do fine but if you want the whole LUAplayer load up again then use break. Something like this:
if blahblahblah then
break
end
-
10-20-2006, 04:53 AM #3722.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Hey guys, I need help making a file browser that opens up .PNGs onto the canvas for my yPaint? Can anyone help? Thanks :)
-
10-20-2006, 01:45 PM #3723QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- London, United Kingdom
- Beiträge
- 131
- Points
- 4.812
- Level
- 44
- Downloads
- 0
- Uploads
- 0
n2 = (lshift(string.byte(str,1 +k),4) & 0x30) + 1
LUA 5.1 really doesnt like that line, more specificly "&" ...Lexical error?
What changes would I need to do to make it run properly?
-
10-20-2006, 06:25 PM #3724Asleep...

- Registriert seit
- Oct 2005
- Beiträge
- 1.383
- Points
- 11.516
- Level
- 70
- Downloads
- 0
- Uploads
- 0
k im making a breakout clone but the problem is that the box doesnt seem to do anything once its hit.--balls by Hedzx--
-- define colors
white = Color.new(255,255,255)
red = Color.new(225,0,0)
green = Color.new(0,225,0)
blue = Color.new(0,0,225)
blocks = 0
--paddle
player = {}
player.x = 0
player.y = 260
player.width = 32
player1 = Image.createEmpty(33,2)
player1:clear(red)
--end paddle
-- ball
ball = {}
ball.x = 10
ball.y = 100
ball.state = "falling"
ball1 = Image.createEmpty(2,2)
ball1:clear(green)
--end paddle
-- block(s)
block = {}
for i = 1,1 do
block[i] = { x = i + 0, y = i + 32, pos = true}
end
blocky = Image.createEmpty(32,32)
blocky:clear(blue)
while true do
screen:clear()
pad = Controls.read()
-- control paddle left or right
if pad:right() then
player.x = player.x + 2
end
if pad:left() then
player.x = player.x - 2
end
-- define the direction ball will fly
if ball.state == "falling" then
ball.y = ball.y + 1
end
if ball.state == "rising up" then
ball.y = ball.y - 1
end
if ball.state == "rising left" then
ball.y = ball.y - 1
ball.x = ball.x - 1
end
if ball.state == "rising right" then
ball.y = ball.y - 1
ball.x = ball.x + 1
end
if ball.state == "falling right" then
ball.y = ball.y + 1
ball.x = ball.x + 1
end
if ball.state == "falling left" then
ball.y = ball.y + 1
ball.x = ball.x - 1
end
-- define "collision" (lol) for paddle..
-- if on right it bounces right etc., etc.,
if ball.y >= player.y and ball.x > player.x and ball.x < player.x + 11 then
ball.state = "rising left"
end
if ball.y >= player.y and ball.x > player.x + 11 and ball.x < player.x + 22 then
ball.state = "rising up"
end
if ball.y >= player.y and ball.x > player.x + 22 and ball.x < player.x + 33 then
ball.state = "rising right"
end
-- wall code
if ball.x < 0 and ball.state == "rising left" then
ball.state = "rising right"
end
if ball.x > 480 and ball.state == "rising right" then
ball.state = "rising left"
end
if ball.y < 0 and ball.state == "rising up" then
ball.state = "falling"
end
if ball.y < 0 and ball.state == "rising left" then
ball.state = "falling left"
end
if ball.y < 0 and ball.state == "rising right" then
ball.state = "falling right"
end
if ball.x < 0 and ball.state == "falling left" then
ball.state = "falling right"
end
if ball.x > 480 and ball.state == "falling right" then
ball.state = "falling left"
end
-- block
if ball.y < block[1].y +32 and ball.x < block[1].x + 32 and ball.pos == "rising up" and block[1].pos ~= false then
blocks = 1
block[1].pos = false
ball.state = "falling"
elseif ball.y < block[1].y and ball.x < block[1].x + 32 and ball.pos == "rising right" and block[1].pos ~= false then
blocks = 1
block[1].pos = false
ball.state = "falling right"
elseif ball.y < block[1].y and ball.x < block[1].x + 32 and ball.pos == "rising left" and block[1].pos ~= false then
blocks = 1
block[1].pos = false
ball.state = "falling left"
end
-- end block
-- blit paddle and player
screen
rint(190,100,"Balls By Hedzx", white)
screen:blit(player.x, player.y, player1)
screen:blit(ball.x, ball.y, ball1)
screen
rint(0, 0,"balls broken"..blocks, green)
for a = 1,1 do
if block[a].pos ~= false then
screen:blit(block[1].x,block[1].y,blocky)
end
end
-- flip screen and wait forever.
screen.flip()
screen.waitVblankStart()
end
also, how would i be able to make the boxes be side by side in the
because it just blits boxes on top of each other. any suggestionss on what to add the x by so that its next to the last block?? thanks.block[i] = { x = i + 0, y = i + 32, pos = true}
-
10-20-2006, 11:53 PM #3725lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Whenever i added OGG music format to my game is wouldnt load unlss it was loaded though IRShell, But when i removed it and converted it to .wav it worked, Does anyone know why?
-
10-21-2006, 12:10 AM #3726
Are you using lua player 0.2? You need 0.2 to load .lrx libraries. This is interesting, i'm helping AN IDIOT WHO PIRATED MY GAME. If you have copied it fully, you would have a great example of playing OGGs don't you think?
-
10-21-2006, 12:13 AM #3727lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
OMG, I am using .20, Look dude i dont like this, If you want i guess i can say i give you some credit, will that make you happy?
Also, I am asking this question because i didnt priated your game i made it by myslef with the help of three othersGeändert von Anti-QJ (10-21-2006 um 12:14 AM Uhr) Grund: Automerged Doublepost
-
10-21-2006, 12:14 AM #3728
SOME CREDIT?!?!?? Don't you dare insult me like that. You owe me an APOLOGY.
-
10-21-2006, 05:31 AM #3729Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
dude, chill out. you gonna get yourself banned. do you have PROOF (REAL PROOF) that he "pirated" your code? (the real term is "stolen", but meh.)
--------------------------------------------------------------------------------------
-
10-21-2006, 05:33 AM #3730QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
http://forums.qj.net/f-psp-developme...ml#post1121032
I did a diff between the two dance.lua files.
-
10-21-2006, 05:34 AM #3731
Here's my proof: http://boardsus.playstation.com/play...=27479#M348145
Zitat von Grimfate126
Notice the date. Sorry for not 'chilling' but I am willing to take a ban for what i think is right. The real term is plagiarize actually but who cares.
-
10-21-2006, 05:36 AM #3732
Hi can som one tell me what are the degree's in the analog like up is 0 and just a bit from the left is like 360 ? can som one help i ant get the correct number for the analog to work.
Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
10-21-2006, 05:46 AM #3733Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von ZereoX
Code:if AX() >= 100 then --move right end if AX() <= -99 then --move left end if AY() >= 100 then --move up end if AY() <= -99 then --move down end
--------------------------------------------------------------------------------------
-
10-21-2006, 05:54 AM #3734
Tkz grimfate i really apreciate.
Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
10-21-2006, 06:18 AM #3735Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von ZereoX
no prob. BTW, you have to define AX and AY as:
or, you can just reaplce the AX, and the AY in the script i gave you with:Code:AX = pad:analogX AY = pad:analogY
Code:pad:analogX pad:analogY
--------------------------------------------------------------------------------------
-
10-21-2006, 06:21 AM #3736QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- London, United Kingdom
- Beiträge
- 131
- Points
- 4.812
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Anyone? Im still fairly new to lua n any help will be apprieciated
Zitat von trex6662k5
-
10-21-2006, 06:24 AM #3737QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
What are you trying to do with it?
-
10-21-2006, 06:24 AM #3738Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von trex6662k5
what are you programming?? youre even using byte operations! but i dont think '&' is leagal in lua. try luaplayer .20--------------------------------------------------------------------------------------
-
10-21-2006, 06:47 AM #3739QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- London, United Kingdom
- Beiträge
- 131
- Points
- 4.812
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Thats the thing it doesnt work in luaplayer 0.20 works in others though
The line originates from here
As you can most likely tell from the function name, it converts a string to base64
The code is johnny2002's and is from Xbox media center: Remote music interface which I have been adding features to. I want to be able to use the latest luaplayer 0.20 mod but due to a "Lexical error" (Writing conventions?) I cant use it.
function encodeB64(str)
local B64 = "ABCDEFGHIJKLMNOPQRSTUVWX YZabcdefghijklmnopqrstuvw xyz0123456789+/=";
local out = ""
local sl = string.len(str)
for i = 0, math.ceil(sl/3)-1 do
k = i*3
n1 = rshift(string.byte(str,1+ k),2)+1
n2 = (lshift(string.byte(str,1 +k),4) & 0x30) + 1
n3 = 65
n4 = 65
if sl >= 2+k then
n2 = n2 + (rshift(string.byte(str,2 +k),4) & 0x0F)
n3 = (lshift(string.byte(str,2 +k),2) & 0x3C) + 1
if sl >= 3+k then
n3 = n3 + (rshift(string.byte(str,3 +k),6) & 0x03)
n4 = string.byte(str,3+k) & 0x3F + 1
end
end
out = out .. string.sub(B64,n1,n1) .. string.sub(B64,n2,n2) .. string.sub(B64,n3,n3) .. string.sub(B64,n4,n4)
end
return out
end
-
10-21-2006, 06:58 AM #3740QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Assuming that & means bitwise and, try lookinbg around for band() function.
http://www.wowwiki.com/Lua_functions
-
10-21-2006, 07:01 AM #3741QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- London, United Kingdom
- Beiträge
- 131
- Points
- 4.812
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Thanks I'll see wether it helps
-
10-21-2006, 12:35 PM #3742QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- 6ft. Down Underground........Oh and guess what my avatar is
- Beiträge
- 387
- Points
- 4.918
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Ok Ive got this code and whenever I try to run it I get
here is my code can you tell me whats wrong wit itCode:lua:19 <eof> expected near 'end'
P.S. Thats the whole codeCode:screen:clear() white = Color.new(255, 255, 255) background = Image.load("psp/IMAGE/psp.png") screen:blit(0, 0, background, 0, 0, background:width(), background:height(), false) file = io.open("psp/score.txt", "r") score = file:read() file:close() screen:print(10,10,score,white) screen.waitVblankStart() screen.flip() end
-
10-21-2006, 12:56 PM #3743I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
You either have to add a 'while true do' or take out the 'end'
Zitat von the undead
-= Double Post =-
Wait, are you trying to load an image from the PSP folder in the root? If so, you have to do:
ms0:/PSP/IMAGE/psp.pngGeändert von Propel (10-21-2006 um 12:56 PM Uhr) Grund: Automerged Doublepost

-
10-21-2006, 09:20 PM #3744QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- 6ft. Down Underground........Oh and guess what my avatar is
- Beiträge
- 387
- Points
- 4.918
- Level
- 44
- Downloads
- 0
- Uploads
- 0
Ill try that, but no i have subfolder named psp
Zitat von Propel
-= Double Post =-
ok thanks the 'while true do' worked....I cant beleive i didnt catch thatGeändert von the undead (10-21-2006 um 09:20 PM Uhr) Grund: Automerged Doublepost
-
10-22-2006, 02:01 AM #3745QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey , can you let a player use the analaog stick in lua and if you can please tell me how
-
10-22-2006, 02:12 AM #3746i r leet lol

- Registriert seit
- Sep 2006
- Ort
- England
- Beiträge
- 2.615
- Points
- 17.776
- Level
- 84
- Downloads
- 0
- Uploads
- 0
Yeh you can, i think it's like:
At least i think...Code:pad = Controls.read() if analog.x() and analog.y() then blah end
whyHELLOder.
-
10-22-2006, 02:22 AM #3747QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
Grimfate126:
Zitat von mark.sparky
Code:if AX() >= 100 then --move right end if AX() <= -99 then --move left end if AY() >= 100 then --move up end if AY() <= -99 then --move down end
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
10-22-2006, 04:46 AM #3748QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey sorry to bother you guys again but can take a look at this code because i have been trying for hours but i just cant get the collision detection to work. Im trying to stop the player from walking into the fences.
-EDIT- Just change the file extension to .lua
-
10-22-2006, 04:49 AM #3749QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
playerx should be player.x in the collision code. playery should be player.y. Also oldx and oldy need to be globals (declared at the top) for the script.
-
10-22-2006, 04:54 AM #3750QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
well at the top ive put in oldx = player.x and oldy = player.y
and at the collision code ive put player.x and player.y but it is stilll not working


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum