![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; ill try this soon! Originally Posted by Faint Can lua load .mp3 files? No. Sorry but you should be able ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#121 | |
![]() ![]() Developer
|
ill try this soon!
Quote:
__________________
PSP Monopoly | PSP Tic Tac Toe | PSP eMail and SMS | Drag Mini | Block Dude http://www.cools.biaklan.com Currently Working on ????? Quote of the Week Last edited by cools; 10-06-2005 at 05:11 PM.. |
|
|
|
|
|
|
#122 | |
![]() NDS Mod
|
Quote:
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me [URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL] |
|
|
|
|
|
|
#124 | |
![]() NDS Mod
|
Quote:
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me [URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL] |
|
|
|
|
|
|
#125 |
![]() |
Hey, MagicianFB. You probably didn't see it, but back on page 11 I was asking if you could tell a little about your rpg project to kinda' help me and anybody else who wants to do an rpg type project. I also asked a few other questions, but it ended up being kind of a long post so I won't repeat it here. The main thing I guess I want to be able to do is scrolling backgrounds (static bg's would be fine if I wanted to try a king's quest type game, or Myst orqsomething, I guesss). The only mention I've found of a scrolling background was in the forums at www.luaplayer.org but it was a really quick no details thing.
|
|
|
|
|
|
#126 |
![]() |
More RPGs, I cant wait to see what others did. I got a scrolling background working, exacly like in zelda1 on NES.
I'de like to see how you guys got it working tho. Got random fights FF style, working on menus and sub menus wich I'm having problems with :icon_sad: .
|
|
|
|
|
|
#127 | |
![]() ![]() Rock Star
|
Quote:
:icon_sad:
__________________
![]() |
|
|
|
|
|
|
#128 |
![]() |
Perhaps there could be some cooperation on the rpg thing? Not neccesarilly on the games themselves, but on how to code them. Perhaps some sort of template code for certain sections that can be edited for use in ones program. ie: the code for a basic battle setup that can be copied and pasted in place with some modifications for the specific game. I'm still doing research on programming in lua, but I had thought of making templates I could use (like one for each area in a game--paste in the template, assign a background png, make the map and assign other variables, but everything that is the same from area to area need not be redone) and posting them for others to use. If we all did that, we could get on with making the games more quickly.
At any rate, I would be interested to hear about your scrolling background. You said Zelda style? Could it be used with a .png for final fantasy style? Also, what kind of trouble are you having with the menu? I'm not a coder just yet, but maybe someone else would have some insight and it could help others who might run into the same problem. |
|
|
|
|
|
#129 |
![]() |
Snaku, I am using png format files. Kinda wierd, but I'm not using small blocks to draw the field. Instead, I'm using 480x272 pictures, I stack em in an table to create my field (piece positions) so I can have multiple worlds easily. All I have to do is change the table. Example:
Code:
Field={BD,AB,AB,BB,
AD,AD,BA,BC,
AD,AD,BD,BB,
BA,AA,AA,BC}
Code:
function NextPieceDown()
if Piece==1 then NextPiece=(Field[5]) CurrentPiece=5
elseif Piece==2 then NextPiece=(Field[6]) CurrentPiece=6
elseif Piece==3 then NextPiece=(Field[7]) CurrentPiece=7
elseif Piece==4 then NextPiece=(Field[8]) CurrentPiece=8
elseif Piece==5 then NextPiece=(Field[9]) CurrentPiece=9
elseif Piece==6 then NextPiece=(Field[10]) CurrentPiece=10
elseif Piece==7 then NextPiece=(Field[11]) CurrentPiece=11
elseif Piece==8 then NextPiece=(Field[12]) CurrentPiece=12
elseif Piece==9 then NextPiece=(Field[13]) CurrentPiece=13
elseif Piece==10 then NextPiece=(Field[14]) CurrentPiece=14
elseif Piece==11 then NextPiece=(Field[15]) CurrentPiece=15
elseif Piece==12 then NextPiece=(Field[16]) CurrentPiece=16
elseif Piece==13 then NextPiece=(Field[1]) CurrentPiece=1
elseif Piece==14 then NextPiece=(Field[2]) CurrentPiece=2
elseif Piece==15 then NextPiece=(Field[3]) CurrentPiece=3
elseif Piece==16 then NextPiece=(Field[4]) CurrentPiece=4
end
PieceY=0
repeat
screen:blit(PieceX,PieceY,Field[Piece])
NextPieceX=0
NextPieceY=PieceY+272
screen:blit(NextPieceX,NextPieceY,NextPiece)
screen:blit(HeroX,HeroY,Heroimg)
PieceX=0
PieceY=PieceY-4
HeroY=HeroY-3.5
screen.waitVblankStart()
screen.flip()
until NextPieceY==0
Piece=CurrentPiece
end
About my menus, I think I got it fixed for now. I was having trouble calling the submenus inside the main menu since I was creating a loop inside another loop. Found a wa around it. Hope this inspires some of you. :icon_smil |
|
|
|
|
|
#130 |
![]() ![]() Developer
|
Is there a Way to Clear only a part of the screen?
Could you do something like this: Code:
screen:clear(100, 100)
__________________
PSP Monopoly | PSP Tic Tac Toe | PSP eMail and SMS | Drag Mini | Block Dude http://www.cools.biaklan.com Currently Working on ????? Quote of the Week |
|
|
|
|
|
#131 |
|
System.usbDiskModeActivat e()
yellow = Color.new(255, 255, 0) blue = Color.new(0, 0, 255) orange = Color.new(223, 88, 6) grey = Color.new(94, 97, 111) black = Color.new(0, 0, 0) red = Color.new(255, 0, 0) white = Color.new (255, 255, 255) brun = Image.load ("Images/brun.png") crun = Image.load ("Images/crun.png") drun = Image.load ("Images/drun.png") erun = Image.load ("Images/erun.png") frun = Image.load ("Images/frun.png") grun = Image.load ("Images/grun.png") hrun = Image.load ("Images/hrun.png") ajump = Image.load ("Images/ajump.png") istand = Image.load ("Images/istand.png") Image:clear (white) screen:blit (100, 150, istand) screen.flip() Image:clear (white) screen.waitVblankStart(60 ) pad = Controls.read() if pad:right() then screen:blit (140, 150, drun) screen.flip() Image:clear (white) screen.waitVblankStart(10 ) screen:blit (180, 150, brun) screen.flip() Image:clear (white) screen.waitVblankStart(10 ) screen:blit (220, 150, crun) screen.flip() Image:clear (white) screen.waitVblankStart(10 ) screen:blit (260, 150, drun) screen.flip() Image:clear (white) screen.waitVblankStart(10 ) screen:blit (290, 150, erun) screen.flip() Image:clear (white) screen.waitVblankStart(10 ) screen:blit (340, 150, frun) screen.flip() Image:clear (white) screen.waitVblankStart(10 ) screen:blit (380, 150, grun) screen.flip() Image:clear (white) screen.waitVblankStart(10 ) screen:blit (420, 150, hrun) screen.flip() Image:clear (white) end if pad:cross() then screen:blit (100, 150, istand) screen.flip() screen.waitVblankStart(10 ) Image:clear (white) screen:blit (130, 150, ajump) screen.flip() screen.waitVblankStart(20 ) Image:clear (white) screen:blit (140, 150, istand) screen.flip() screen.waitVblankStart() end This is kind of ugly code but I am trying to learn anyway, it always will come up then it will stay on for about 2 seconds the it will say press start to restart, so if someone could help me I would appreciate it
|
|
|
|
|
|
|
#132 |
![]() NDS Mod
|
Does any one know what "loop in gettable" means, because it keeps on shoeing it as an error.
Edit: I added a loop around the controls part... Code:
System.usbDiskModeActivate()
yellow = Color.new(255, 255, 0)
blue = Color.new(0, 0, 255)
orange = Color.new(223, 88, 6)
grey = Color.new(94, 97, 111)
black = Color.new(0, 0, 0)
red = Color.new(255, 0, 0)
white = Color.new (255, 255, 255)
brun = Image.load ("Images/brun.png")
crun = Image.load ("Images/crun.png")
drun = Image.load ("Images/drun.png")
erun = Image.load ("Images/erun.png")
frun = Image.load ("Images/frun.png")
grun = Image.load ("Images/grun.png")
hrun = Image.load ("Images/hrun.png")
ajump = Image.load ("Images/ajump.png")
istand = Image.load ("Images/istand.png")
Image:clear (white)
screen:blit (100, 150, istand)
screen.flip()
Image:clear (white)
screen.waitVblankStart(60 )
end
pad = Controls.read()
if pad:right() then
screen:blit (140, 150, drun)
screen.flip()
Image:clear (white)
screen.waitVblankStart(10 )
screen:blit (180, 150, brun)
screen.flip()
Image:clear (white)
screen.waitVblankStart(10 )
screen:blit (220, 150, crun)
screen.flip()
Image:clear (white)
screen.waitVblankStart(10 )
screen:blit (260, 150, drun)
screen.flip()
Image:clear (white)
screen.waitVblankStart(10 )
screen:blit (290, 150, erun)
screen.flip()
Image:clear (white)
screen.waitVblankStart(10 )
screen:blit (340, 150, frun)
screen.flip()
Image:clear (white)
screen.waitVblankStart(10 )
screen:blit (380, 150, grun)
screen.flip()
Image:clear (white)
screen.waitVblankStart(10 )
screen:blit (420, 150, hrun)
screen.flip()
Image:clear (white)
end
if pad:cross() then
screen:blit (100, 150, istand)
screen.flip()
screen.waitVblankStart(10 )
Image:clear (white)
screen:blit (130, 150, ajump)
screen.flip()
screen.waitVblankStart(20 )
Image:clear (white)
screen:blit (140, 150, istand)
screen.flip()
screen.waitVblankStart()
end
end
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me [URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL] Last edited by MagicianFB; 10-07-2005 at 04:38 PM.. |
|
|
|
|
|
#134 | |
![]() NDS Mod
|
Quote:
So just look through the code and find spaces that look like the shouldn't be there. For example, the System.usbDiskModeActivat e() has a space in it that shouldn't be there, so just delete it.
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me [URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL] |
|
|
|
|
|
|
#135 | |
![]() ![]() Developer
|
Quote:
before your pad = Controls.read() that shouldn't be there. Im not the best coder though to im not quite sure.
__________________
![]() F.A.L.O?
|
|
|
|
|
|
|
#137 |
![]() |
im trying to make a slow moving cursor, but it moves too much by just tapping the dpad. any one know how to fix this
Code:
black = Color.new(0, 0, 0)
x = 139
y = 86
cursor = Image.load("cursor.png")
background = Image.load("background.png")
while true do
screen:blit(0, 0, background, false)
screen:blit(x, y, cursor)
screen.flip()
pad = Controls.read()
if pad:up() then
y = y - 1
screen.flip()
end
if pad:down() then
y = y + 1
screen.flip()
end
if pad:left() then
x = x - 1
screen.flip()
end
if pad:right() then
x = x + 1
screen.flip()
end
end
|
|
|
|
|
|
#138 | |
![]() |
Quote:
Change the values in your x and y's. Each time a buttons pressed the X and Y are told to move in some way. The value determins how far the cursor moves each time. Thus if it's a high value then the cursor moves faster.. lower value.. moves slower.
Last edited by Bilo; 10-07-2005 at 06:29 PM.. |
|
|
|
|
|
|
#140 |
![]() NDS Mod
|
What do all the second pair of numbers when yo blit an objects mean?
example: Code:
-------------these two: v v ---------------------- screen:blit(0, 0, image, 0, 0, width, height, false)
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me [URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL] |
|
|
|
|
|
#142 | |
![]() |
Quote:
Isn't it the rotation point? |
|
|
|
|
|
|
#143 |
![]() |
what am i doing wrong, im trying to make a paint in lua using the dpad, but it ends up like an ect-a-sketch and by that i mean the line that is being drawn cannot be turn on/off using x like its supposed to. (attached is the cursor pic its just a red dot, and that im using and that's the script) thanks in advance
Code:
black = Color.new(0, 0, 0)
white = Color.new(255, 255, 255)
x = 139
y = 86
cursor = Image.load("cursor.png")
canvas = Image.createEmpty(480, 272)
canvas:clear(white)
while true do
screen:blit(x, y, cursor)
screen.flip()
pad = Controls.read()
if pad:up() then
y = y - 1
screen.flip()
end
if pad:down() then
y = y + 1
screen.flip()
end
if pad:left() then
x = x - 1
screen.flip()
end
if pad:right() then
x = x + 1
screen.flip()
end
if pad:cross() then
canvas:drawLine(x, y, 1, 1, black)
screen.flip()
end
end
|
|
|
|
|
|
#144 |
![]() |
XteticX, that sounds interesting. I had thought to have one image maybe 2 to 3 times the size of the screen that could be scrolled around, but the tiles are probably better. Any reason they have to be the size of the screen, or could you have smaller tiles? Then if you had a small animation going on somewhere, a much smaller section of the screen would be getting refreshed over and over. Also, would it mess things up to have different size tiles? Meaning the whole map could be made of 420x278 tiles (or whatever size) and then one tile could actually be made of 4 smaller tiles... just as an example. Also, just a side thought, smaller tiles would mean less offscreen stuff is being loaded and causing lag.
I have to go to work now, but tomorrow I will begin studying the coding thing in ernest. Thanks for posting some of your stuff. I'm sure it'll help. |
|
|
|
|
|
#145 |
![]() NDS Mod
|
Hey guys! Here's a quick demo of how to load RPG Maker XP charsets in lua. Just use the replace charset.png, with the one you want.
Code:
function loadcharset(charset)
down = {}
left = {}
right = {}
up = {}
for i=1,4 do
down[i] = Image.createEmpty(charset:width()/4, charset:height()/4)
end
for i=1,4 do
left[i] = Image.createEmpty(charset:width()/4, charset:height()/4)
end
for i=1,4 do
right[i] = Image.createEmpty(charset:width()/4, charset:height()/4)
end
for i=1,4 do
up[i] = Image.createEmpty(charset:width()/4, charset:height()/4)
end
for i=0,3 do
down[i+1]:blit(0, 0, charset, (i*charset:width()/4), 0, charset:width()/4, charset:height()/4)
end
for i=0,3 do
left[i+1]:blit(0, 0, charset, (i*charset:width()/4), charset:height()/4, charset:width()/4, charset:height()/4)
end
for i=0,3 do
right[i+1]:blit(0, 0, charset, (i*charset:width()/4), 2*charset:height()/4, charset:width()/4, charset:height()/4)
end
for i=0,3 do
up[i+1]:blit(0, 0, charset, (i*charset:width()/4), 3*charset:height()/4, charset:width()/4, charset:height()/4)
end
end
charset = Image.load("charset.png")
loadcharset(charset)
screen:blit(0, 0, down[1])
screen:flip()
pos = 0
while true do
screen.waitVblankStart(8)
pad = Controls.read()
if pad:up() then
if pos==4 then
pos = 1
else
pos = pos+1
end
screen:clear()
screen:blit(100, 100, up[pos])
screen:flip()
elseif pad:down() then
if pos==4 then
pos = 1
else
pos = pos+1
end
screen:clear()
screen:blit(100, 100, down[pos])
screen:flip()
elseif pad:left() then
if pos==4 then
pos = 1
else
pos = pos+1
end
screen:clear()
screen:blit(100, 100, left[pos])
screen:flip()
elseif pad:right() then
if pos==4 then
pos = 1
else
pos = pos+1
end
screen:clear()
screen:blit(100, 100, right[pos])
screen:flip()
elseif pad:r() then
break
end
end
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me [URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL] |
|
|
|
|
|
#146 |
![]() |
Ok, stupid question: what are rpg maker char sets? I've never used an rpg maker, being unsatisfied with the level of graphics and all. I haven't been following them since rpg maker 2 came out for ps2. Is the XP one pretty good?
XteticX, I read through your post again (with slightly less tired eyes so it made more sense this time). Seems to be an effective method. So is the position of the Hero always in the center and the background scrolls, or does he move around the screen and the background starts scrolling when he nears the edge of the screen? The latter is the result I'd like to go for. I'm wanting to do environments very similarly to ff vii-ix. Either hand drawn, or snatched from another source, like an anime or something. As I've said, I don't expect to be able to make a final fantasy quality game, but I do want to go for that kind of feel. I've always hated the more traditional rpgs, with repeated tiles for a patch of grass or identical looking trees and huts. Also I noticed "Hero" was capitalized in your post. Is that his name, and if so, is that a clue as to what your project is? Last edited by Snaku; 10-08-2005 at 09:28 AM.. |
|
|
|
|
|
#147 | ||
![]() |
Quote:
A clue. lol. No, Its just the name of the variable. And yes, caracter moves around freely, once he reaches the edge of the screen, then the anim moves the next piece. I'm just saying, PROBABLY, you could do it like FF as you say if you had maybe 5 pieces of the background at once. Having the next piece for all four direction ready, but flikering issues could arise. Anyway I'm just saying it IS possible, just it ain't gonna be easy. I could prob do it but my free time is limited right now. :icon_sad: Quote:
|
||
|
|
|
|
|
#148 |
![]() ![]() Developer
|
What is wrong with this code? It says i have a error on line 19 with "then".
Code:
m = 1
ran = math.random(100)
blue = Color.new(0, 0, 225)
while true do
pad = Controls.read()
if pad:up() then
screen:clear()
screen:print(132, 230, string.format("d", m + 1), blue)
screen:flip() end
if pad:down() then
screen:clear()
screen:print(132, 230, string.format("d", m - 1), blue)
screen:flip() end
if pad:cross() and m = ran then
screen:clear()
screen:print(132, 230, string.format("d", m), blue)
screen:print(122, 230, "You guessed correctly!", blue)
screen:flip() end
if pad:start() then
break end
end
__________________
![]() F.A.L.O?
|
|
|
|
|
|
#149 | |
![]() NDS Mod
|
Quote:
__________________
"15% percent of programing is creating a program, 85% percent is getting it to work like it should." - Me [URL=http://www.mozilla.org/products/firefox/][IMG]http://img439.imageshack.us/img439/5667/getfirefox0sr.png[/IMG][/URL] |
|
|
|
|
|
|
#150 |
![]() ![]() Developer
|
Ok i fixed the == part and I forgot to put a % in front of d. No when I test the program and when i press up it goes straight to 2 and wont go higher. When i press down it goes straight to zero.
Code:
m = 1
ran = math.random(100)
blue = Color.new(0, 0, 225)
while true do
pad = Controls.read()
if pad:up() then
screen:clear()
screen:print(230, 136, string.format("%d", m + 1), blue)
screen:flip() end
if pad:down() then
screen:clear()
screen:print(230, 136, string.format("%d", m - 1), blue)
screen:flip() end
if pad:cross() and m == ran then
screen:clear()
screen:print(230, 136, string.format("%d", m), blue)
screen:print(230, 136, "You guessed correctly!", blue)
screen:flip() end
if pad:start() then
break end
end
__________________
![]() F.A.L.O?
|
|
|
|
![]() |
| Tags |
| code , lib , lua , luaplayer , noobs , programming , psp programming , scripting , thread |
| Thread Tools | |
|
|