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; Why are you having the vertical value increase when you press right? You should be increasing the x value...
-
04-12-2006, 02:21 AM #1471Rock Star

- Registriert seit
- Aug 2005
- Ort
- CT| FW: 4.01 M33-2
- Beiträge
- 11.844
- Points
- 70.899
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Why are you having the vertical value increase when you press right? You should be increasing the x value

-
04-12-2006, 02:29 AM #1472is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
yea - but you can still use the letter y althugh it gets confusign, you just have to say (y, 100, ....)
but i would use X
TO - I really think people should use the devs one more, then we will be asking harder q's eh?What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
04-12-2006, 02:31 AM #1473Rock Star

- Registriert seit
- Aug 2005
- Ort
- CT| FW: 4.01 M33-2
- Beiträge
- 11.844
- Points
- 70.899
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Ya, but Im just saying its just easier to put (x, 25, ...) and then have x = x +5 when you press right

-
04-12-2006, 02:37 AM #1474is not posting very often

- Registriert seit
- Feb 2006
- Ort
- omnipresent
- Beiträge
- 5.162
- Points
- 33.152
- Level
- 100
- Downloads
- 0
- Uploads
- 0
ya I know, hey TO, what are you currently working on?
What did we think the world would look like in 2015?
http://forums.qj.net/501501-post26.html
Zitat von Abe
-
04-12-2006, 02:42 AM #1475Rock Star

- Registriert seit
- Aug 2005
- Ort
- CT| FW: 4.01 M33-2
- Beiträge
- 11.844
- Points
- 70.899
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Check the sig....im about to get back to work on Tux Rampage, as I have a backup of that project, so I can continue where I left off

-
04-12-2006, 02:57 AM #1476QJ Gamer Silver
- Registriert seit
- Feb 2006
- Ort
- England
- Beiträge
- 1.038
- Points
- 8.993
- Level
- 63
- Downloads
- 0
- Uploads
- 0
help
could someone help me every time I load my lua thingy it gets to loading 90% but then my psp takes me back to eloader screen someone help me heres my code:
Code:pink = Color.new(255, 0 , 153) blue = Color.new(0 , 153, 255) orange = Color.new(255, 102, 0) gray = Color.new(153, 153, 153) black = Color.new(0 , 0 , 0) screen:print(194, 136, "Loading: 0%", pink) screen.flip() background = Image.load("images/background.jpg") screen:clear() screen:print(194, 136, "Loading: 20%", pink) screen.flip() circle = Image.load("images/buttons/circle_button.png") down = Image.load("images/buttons/down_arrow.png") screen:clear() screen:print(194, 136, "Loading: 40%", pink) screen.flip() l = Image.load("images/buttons/left_trigger.png") left = Image.load("images/buttons/left_arrow.png") screen:clear() screen:print(194, 136, "Loading: 60%", pink) screen.flip() r = Image.load("images/buttons/right_trigger.png") right = Image.load("images/buttons/right_arrow.png") boltsnd = Sound.load("music/comp.wav") screen:clear() screen:print(194, 136, "Loading: 80%", pink) screen.flip() square = Image.load("images/buttons/square_button.png") triangle = Image.load("images/buttons/triangle_button.png") screen:clear() screen:print(194, 136, "Loading: 90%", pink) screen.flip() up = Image.load("images/buttons/up_arrow.png") x = Image.load("images/buttons/cross_button.png") splash = Image.load("images/lua.gif") screen:clear() screen:print(194, 136, "Loading: 100%", pink) screen.flip() screen.waitVblankStart(60) screen:blit(0, 0, splash, false) screen.waitVblankStart() screen.flip() boltsnd:play() screen.waitVblankStart(240) Music.volume(128) while true do screen:blit(0, 0, background, false) pad = Controls.read() screen:print(135, 251, "Press 'Start' to restart", blue) screen:print(110, 261, "Press 'Select' for a screenshot", blue) screen:print(383, 35, "Support:", black) screen:print(365, 45, "PS3Lounge.net", orange) screen:print(365, 55, "scriptscribbler.com/psp", gray) screen.flip() if pad:cross() then screen:blit(50, 228, x) screen.flip() end if pad:circle() then screen:blit(90, 195, circle) screen.flip() end if pad:triangle() then screen:blit(45, 165, triangle) screen.flip() end if pad:square() then screen:blit(15, 195, square) screen.flip() end if pad:up() then screen:blit(60, 40, up) screen.flip() end if pad:right() then screen:blit(90, 65, right) screen.flip() end if pad:down() then screen:blit(60, 80, down) screen.flip() end if pad:left() then screen:blit(30, 65, left) screen.flip() end if pad:l() then screen:blit(4, 6, l) screen.flip() end if pad:r() then screen:blit(403, 4, r) screen.flip() end if pad:select() then screen:save("screenshot.tga") end if pad:start() then break end endI own a Playstation 3,PSP and a Wii add me on psn: azazin,
Zitat von TheMasterChef
-
04-12-2006, 03:06 AM #1477Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Try this:
Code:pink = Color.new(255, 0 , 153) blue = Color.new(0 , 153, 255) orange = Color.new(255, 102, 0) gray = Color.new(153, 153, 153) black = Color.new(0 , 0 , 0) background = Image.load("images/background.jpg") circle = Image.load("images/buttons/circle_button.png") down = Image.load("images/buttons/down_arrow.png") l = Image.load("images/buttons/left_trigger.png") left = Image.load("images/buttons/left_arrow.png") r = Image.load("images/buttons/right_trigger.png") right = Image.load("images/buttons/right_arrow.png") square = Image.load("images/buttons/square_button.png") triangle = Image.load("images/buttons/triangle_button.png") up = Image.load("images/buttons/up_arrow.png") x = Image.load("images/buttons/cross_button.png") splash = Image.load("images/lua.gif") boltsnd = Sound.load("music/comp.wav") screen:print(194, 136, "Loading: 0%", pink) screen.flip() screen:clear() screen:print(194, 136, "Loading: 20%", pink) screen.flip() screen:clear() screen:print(194, 136, "Loading: 40%", pink) screen.flip() screen:clear() screen:print(194, 136, "Loading: 60%", pink) screen.flip() screen:clear() screen:print(194, 136, "Loading: 80%", pink) screen.flip() screen:clear() screen:print(194, 136, "Loading: 90%", pink) screen.flip() screen:clear() screen:print(194, 136, "Loading: 100%", pink) screen.flip() screen.waitVblankStart(60 ) screen:blit(0, 0, splash, false) screen.waitVblankStart() screen.flip() boltsnd:play() screen.waitVblankStart(24 0) Music.volume(128) while true do screen:blit(0, 0, background, false) pad = Controls.read() screen:print(135, 251, "Press 'Start' to restart", blue) screen:print(110, 261, "Press 'Select' for a screenshot", blue) screen:print(383, 35, "Support:", black) screen:print(365, 45, "PS3Lounge.net", orange) screen:print(365, 55, "scriptscribbler.com/psp", gray) screen.flip() if pad:cross() then screen:blit(50, 228, x) screen.flip() end if pad:circle() then screen:blit(90, 195, circle) screen.flip() end if pad:triangle() then screen:blit(45, 165, triangle) screen.flip() end if pad:square() then screen:blit(15, 195, square) screen.flip() end if pad:up() then screen:blit(60, 40, up) screen.flip() end if pad:right() then screen:blit(90, 65, right) screen.flip() end if pad:down() then screen:blit(60, 80, down) screen.flip() end if pad:left() then screen:blit(30, 65, left) screen.flip() end if pad:l() then screen:blit(4, 6, l) screen.flip() end if pad:r() then screen:blit(403, 4, r) screen.flip() end if pad:select() then screen:save("screenshot.tga") end if pad:start() then break end end
-
04-12-2006, 05:34 AM #1478QJ Gamer Bronze
- Registriert seit
- Jan 2006
- Ort
- Western Australia
- Beiträge
- 1.046
- Points
- 8.803
- Level
- 63
- Downloads
- 0
- Uploads
- 0
How big can your .wav files be? Because I'm trying to use some for music but just by going song
lay() (song is my song variable).
-
04-12-2006, 06:39 AM #1479Mindless Fanboy
- Registriert seit
- Mar 2006
- Beiträge
- 1.907
- Points
- 17.218
- Level
- 83
- Downloads
- 0
- Uploads
- 0
i think they can be as big as you want them to be. try it. i am not too sure. if not, edit it down a bit
-
04-12-2006, 06:40 AM #1480Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
I am so stuck on these tile backgrounds. Its really annoying me also.
Error:Code:--Load images tiles = Image.load("images/specialtiles.png") -- the map map1 = { "dkkkkkkkkfaaaaaaaaaaaaaaa", "ibgbgbbgbjaaaaaaaaaaaaaaa", "ibgbgbbgbjaaaaaaaaaaaaaaa", "ibgbgbbgbjaaaaaaaaaaaaaaa", "ibgbgbbgbjaaaaaaaaaaaaaaa", "ibgbgbbgbjaaaaaaaaaaaaaaa", "hlllllllleaaaaaaaacpaaaaa", "aaaaaaaaaaaaaaaaaanoaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa" } function drawTile(tile, x, y) local tileX = math.mod(tile, 4) local tileY = math.floor(tile / 4) screen:blit(16 * x, 16 * y, tiles, 17 * tileX + 1, 17 * tileY + 1, 16, 16, false) end while true do for y = 1, 17 do line = map1[y] for x = 1, 30 do tile = string.byte(line, x) - string.byte("a") drawTile(tile, x - 1, y - 1) end end screen.flip() end
error: game.lua:40: attempt to perform arithmetic on a nil value
Please help!
-
04-12-2006, 07:11 AM #1481Think, Do, Gloat.
- Registriert seit
- Nov 2005
- Ort
- England, Norwich
- Beiträge
- 1.422
- Points
- 12.687
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Music files like wav's can't be that big. It is better to use MOD format or IT, or anything which uses modules, rather than a waveform. Also, loading times are affected if you try and load like 5 5mb song wavs.
I would have thought though if you have to do it, maybe 2mb each. no longer than 30 seconds.
-
04-12-2006, 07:34 AM #1482QJ Gamer Bronze
- Registriert seit
- Jul 2005
- Ort
- Washington
- Beiträge
- 211
- Points
- 5.459
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Zitat von TeamOverload
Allright, changed it, but that didn't really change anything, the char image still does not move.
white = Color.new(255, 255, 255)
char = Image.load("char.png")
x = 150
screen
rint(100, 100, "loading finished", white)
screen.flip()
screen.waitVblankStart(24 0)
screen:clear()
screen:blit(x, 50, char)
screen.flip()
pad = Controls.read()
if pad:right() then
x = x + 5
end
while true do
screen.waitVblankStart()
screen.flip()
endPsp firmware: 1.5 - Thank you 0okm and Fanjita! ^^
-
04-12-2006, 07:39 AM #1483Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Try that m8!Code:white = Color.new(255, 255, 255) char = Image.load("char.png") x = 150 screenrint(100, 100, "loading finished", white) screen.flip() screen.waitVblankStart(24 0) screen:clear() screen:blit(x, 50, char) screen.flip() pad = Controls.read() if pad:right() then x = x + 5 end while true do pad = Controls.read() screen:blit(x, 50, char) screen.flip() pad = Controls.read() if pad:right() then x = x + 5 end screen.waitVblankStart() screen.flip() end
-
04-12-2006, 08:28 AM #1484QJ Gamer Bronze
- Registriert seit
- Jul 2005
- Ort
- Washington
- Beiträge
- 211
- Points
- 5.459
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Ha, it works, thanks a ton!
Psp firmware: 1.5 - Thank you 0okm and Fanjita! ^^
-
04-12-2006, 08:53 AM #1485
@ct-boy
If it stops at 90% it means there is something wrong between 90% and 100%. Just so you know for the future. I think people forget that, maybe im wrong. So anyway, Lua cant handle GIF's (yet), so change that in your code.LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-12-2006, 08:55 AM #1486
Cant help you if you dont tell me/us what line line 40 is :P . But anyway, the error means that something gets compared to something that hasnt got any value, so just check all the previous statements where that variable is involved in. Hope that its clear, otherwise you need to tell which line it is.
Zitat von kozine
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-12-2006, 11:17 AM #1487Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
NVM it fixed. I had less tiles.
-
04-12-2006, 12:30 PM #1488QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- Puerto Rico
- Beiträge
- 310
- Points
- 7.109
- Level
- 55
- Downloads
- 0
- Uploads
- 0
It didn't work the way I wanted it too. I'm tring to make a pinball game and I want the flappers to move
Zitat von kozine

With the code you gave me it overlaps on one another. Give it a try. I need that when one pic appears another disappears and viceversa. I would like the help. Thanks.
-
04-12-2006, 12:31 PM #1489Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
I dont think u replaces the 0's with the place u wanted it?
-
04-12-2006, 12:37 PM #1490QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- Puerto Rico
- Beiträge
- 310
- Points
- 7.109
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Yes I've changed the 0's but that does not change the overlapping.
-
04-12-2006, 12:39 PM #1491Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
--Load images
pica = Image.load("Path to image")
picb = Image.load("Path to image")
--Begin the main loop
while true do
pad = Controls.read()
screen:blit(0, 0, pica)
if pad:cross() then
screen:clear()
screen:blit(0, 0, picb)
end
screen.flip()
end
-
04-12-2006, 01:09 PM #149211th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
This works:
Try itCode:--Load images bg = Image.load("bg.png") pic = {} pic[1] = Image.load("flapperleft1.png") pic[2] = Image.load("flapperleft2.png") imgpic=pic[1] --Begin the main loop while true do screen:blit(0, 0, bg) pad = Controls.read() if pad:cross() then imgpic=pic[2] else imgpic=pic[1] end screen:blit(0, 0, imgpic) screen.flip() end
!
Also BG is the background, as i thought it would look neat...FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
-
04-12-2006, 01:20 PM #1493Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Is there ANYBODY on this site that can help me make a two picture animation? at all?
-
04-12-2006, 01:21 PM #1494
Explain EXACTLY what you would like to do Greenskull.
D:
-
04-12-2006, 01:22 PM #1495Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
when you press X, I want a dude to talk using two pictures, I want him to keep talking untill I press X again.
-
04-12-2006, 01:40 PM #1496
Something like(untested, just typed it up here):
I dunno if this works, as i say i just typed it up, but it should be along the lines of what you need.Code:frame1 = Image.load("bla.png") frame2 = Image.load("bla2.png") Animation = 0 while true do pad = Controls.read() if Animation = 0 then screen:blit(x,y,frame1) screen.flip() screen.waitVblankStart() end if Animation = 1 then screen:blit(x,y,frame1) screen.flip() screen.waitVblankStart(change depending on the delay needed) screen:clear() screen:blit(x,y,frame2) screen.flip() screen.waitVblankStart(again change for delay) screen:clear() end if pad:cross() and Animation == 0 then Animation = 1 end if pad:cross() and Animation == 1 then Animation = 0 end endD:
-
04-12-2006, 01:41 PM #1497
As others have explained to you how animation works im not explaining that. To make the animation go untill you press X again just use a variable:
easy as that...Code:if pressed==true play animantion end if pad:cross() and pressed==true then pressed=false end
LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
04-12-2006, 06:17 PM #1498
I don't get why this doesn't work. I keep getting the "attempt to index field '?' ( a nil value)" error.
please don't just tell me what's wrong, also tell me how to fix it. ThanksCode:for i = 1,21 do something[i] = {x = 25 + 10 * i, y = 480 - picture1:height(), pic = picture1} end while true do screen:blit(something[i].x, something[i].y, something[i].pic) end
-
04-12-2006, 07:58 PM #1499
- Registriert seit
- Mar 2006
- Beiträge
- 7
- Points
- 4.063
- Level
- 40
- Downloads
- 0
- Uploads
- 0
You have to initiate something:
Code:something = {} for i = 1,21 do something[i] = {x = 25 + 10 * i, y = 480 - picture1:height(), pic = picture1} end while true do screen:blit(something[i].x, something[i].y, something[i].pic) end
-
04-12-2006, 10:23 PM #1500
How do I make a function run only once? (while in the "While true do" loop)
Also, when I want make a function to print a random number between say, 1 and 30, it prints all of them! How do I make it print just one? ( or maybe, assign just one number between 1 and 30 to a variable...I have the problem that if a = math.random(1,30), a = 1 through 30)Geändert von ro0kie42 (04-12-2006 um 10:43 PM Uhr)


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