QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

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; ill try this soon! Originally Posted by Faint Can lua load .mp3 files? No. Sorry but you should be able ...

Reply
 
LinkBack Thread Tools
Old 10-06-2005, 05:09 PM   #121

Developer
 
cools's Avatar
 
Join Date: Aug 2005
Posts: 472
Trader Feedback: 0
Default

ill try this soon!

Quote:
Originally Posted by Faint
Can lua load .mp3 files?
No. Sorry but you should be able to load .wav
__________________

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..
cools is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 05:36 PM   #122
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by Twenty 2
You might actually want to try
Code:
blue = Color.new(0, 0, 225)
while true do
pad  = Controls.read()
dice2 = math.random(6)
if pad:cross() then
screen:clear()
screen:print(90, 50,string.format("%d", dice2), blue)
screen.flip()
screen.waitVblankStart()
end
end
I changed the color so you could actualy see the number and I added a screen clear so that it doesnt print over it self so you cant read it.
There's no space between the comma after 50 and string.format.
__________________
"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]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 05:45 PM   #123

Developer
 
Join Date: Jun 2005
Location: At my house...
Posts: 885
Trader Feedback: 0
Default

I tested the program with the exact code i posted so i dont think it matters.
__________________
F.A.L.O?
Twenty 2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 05:49 PM   #124
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Lightbulb

Quote:
Originally Posted by MagicianFB
Wow that took me a while...
Ok put keyboard.lua (rename it to that) in the same file as your main code.
Then put this in your main code:
Code:
dofile("keyboard.lua")
When you want define a variable or print something you can define the variable or what it's printing as keyboard()
Code:
-- Examples
print(keyboard())
thetext = keyboard()
This will allow you to input what it is going to register the value as.

=================
Start - Enter Value
D-pad - select key
R - Space
L - Delete
Select - Like holding down shift
Control pad - Press the button corresponding with the character on the selected key
================

I've tested it and it seems to work on luaplayer v9 but not v11
Just upgraded it, so instead use this keyboard.lua file
Attached Files
File Type: txt keyboard.lua.txt‎ (15.8 KB, 48 views)
__________________
"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]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-06-2005, 08:12 PM   #125
 
Snaku's Avatar
 
Join Date: Jun 2005
Posts: 330
Trader Feedback: 0
Default

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.
Snaku is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 12:24 PM   #126
 
XteticX's Avatar
 
Join Date: Jun 2005
Location: script.lua
Posts: 426
Trader Feedback: 0
Default

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: .
XteticX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 12:27 PM   #127

Rock Star
 

 
Join Date: Aug 2005
Location: CT| FW: 4.01 M33-2
Posts: 11,844
Trader Feedback: 0
Default

Quote:
Originally Posted by MagicianFB
Just upgraded it, so instead use this keyboard.lua file
i wanna test the keyboard, and try and incoporate it into my lua program, but first i have to exchange my bricked psp :icon_sad: :icon_sad:
__________________

TeamOverload is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 12:48 PM   #128
 
Snaku's Avatar
 
Join Date: Jun 2005
Posts: 330
Trader Feedback: 0
Default

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.
Snaku is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 02:23 PM   #129
 
XteticX's Avatar
 
Join Date: Jun 2005
Location: script.lua
Posts: 426
Trader Feedback: 0
Default

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}
This is still only a 16 piece field as you can see, but it can be whatever you desire it too be. How it works now, is instead of bliting the whole field at once, witch I found was kinda laggy and jerky, I only blit 2 images at once. The "CurentPiece" and the "Next Piece". Like zelda, if the Hero's position get near either end of the screen, then the next piece is generated. Depending on the position of the Hero once again, the next block's X, Y coords will be set, then the piece will be calculated from the table. Really simple accually. :razz: Here's what a next piece funciton looks like:

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
I know its kinda ugly with all the "elseif Piece==16" but its only because I'm testing soem stuff. I need to make limits for each piece type. Then all that's left is to add anims here and there, water, birds, trees, etc. Then one can make diferent piece pictures for different world, and stack em in a different order so on.

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
XteticX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 03:26 PM   #130

Developer
 
cools's Avatar
 
Join Date: Aug 2005
Posts: 472
Trader Feedback: 0
Default

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
cools is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 04:26 PM   #131
 
Join Date: Jun 2005
Posts: 32
Trader Feedback: 0
Default

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
Dack Chaar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 04:31 PM   #132
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

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..
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 04:50 PM   #133
 
Join Date: Jun 2005
Posts: 32
Trader Feedback: 0
Default

k, thanks but it says '=' expected near 'e'
Dack Chaar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 05:13 PM   #134
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by Dack Chaar
k, thanks but it says '=' expected near 'e'
That's because, due to a forum glitch, spaces are put in paces they shouldn't be.
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]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 05:27 PM   #135

Developer
 
Join Date: Jun 2005
Location: At my house...
Posts: 885
Trader Feedback: 0
Default

Quote:
Originally Posted by MagicianFB
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
Im not to sure but i dont think you have a while loop and you have a "end"
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?
Twenty 2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 06:13 PM   #136
 
Join Date: Jun 2005
Posts: 32
Trader Feedback: 0
Default

K, thanks for your help guys, and sorry to be such a noob, but it says <eof> expected near end.
Dack Chaar is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 06:22 PM   #137
 
sofa king dumb's Avatar
 
Join Date: Aug 2005
Location: USA
Posts: 214
Trader Feedback: 0
Default

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
sofa king dumb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 06:23 PM   #138
 
Bilo's Avatar
 
Join Date: Sep 2005
Location: In your garage
Posts: 73
Trader Feedback: 0
Default

Quote:
Originally Posted by sofa king dumb
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

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..
Bilo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 06:31 PM   #139
 
sofa king dumb's Avatar
 
Join Date: Aug 2005
Location: USA
Posts: 214
Trader Feedback: 0
Default

if pad:right() then
x = x + 0.25
screen.flip()
end

would this work then? thanks in advance
sofa king dumb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 06:32 PM   #140
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

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]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 06:33 PM   #141
 
Bilo's Avatar
 
Join Date: Sep 2005
Location: In your garage
Posts: 73
Trader Feedback: 0
Default

I think so.

I'm not sure how lua handles values.. Not too sure if it would see the value 0.00
but in theory, yes.

Try it and see.
Bilo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 06:34 PM   #142
 
Bilo's Avatar
 
Join Date: Sep 2005
Location: In your garage
Posts: 73
Trader Feedback: 0
Default

Quote:
Originally Posted by MagicianFB
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)

Isn't it the rotation point?
Bilo is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 07:29 PM   #143
 
sofa king dumb's Avatar
 
Join Date: Aug 2005
Location: USA
Posts: 214
Trader Feedback: 0
Default

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
Attached Images
 
sofa king dumb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 08:39 PM   #144
 
Snaku's Avatar
 
Join Date: Jun 2005
Posts: 330
Trader Feedback: 0
Default

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.
Snaku is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-07-2005, 08:46 PM   #145
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

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]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2005, 08:43 AM   #146
 
Snaku's Avatar
 
Join Date: Jun 2005
Posts: 330
Trader Feedback: 0
Default

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..
Snaku is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2005, 01:00 PM   #147
 
XteticX's Avatar
 
Join Date: Jun 2005
Location: script.lua
Posts: 426
Trader Feedback: 0
Default

Quote:
Originally Posted by Snaku
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?

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:
I had thought to have one image maybe 2 to 3 times the size of the screen that could be scrolled around
This would indeed make our lifes easier, but I think the current luaplayer still cant blit big enought images. Something like 512pix max I'm not sure. Anyway I hope you get your game into gear soon. I wanna see some RPGs come out before ours. Good luck.
XteticX is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2005, 03:22 PM   #148

Developer
 
Join Date: Jun 2005
Location: At my house...
Posts: 885
Trader Feedback: 0
Default

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?
Twenty 2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2005, 03:27 PM   #149
NDS Mod
 
MagicianFB's Avatar
 
Join Date: Jul 2005
Location: w00+land
Posts: 645
Trader Feedback: 0
Default

Quote:
Originally Posted by Twenty 2
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
ypu have to use == when asking if something is true.
__________________
"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]
MagicianFB is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 10-08-2005, 03:59 PM   #150

Developer
 
Join Date: Jun 2005
Location: At my house...
Posts: 885
Trader Feedback: 0
Default

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?
Twenty 2 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
code , lib , lua , luaplayer , noobs , programming , psp programming , scripting , thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 12:39 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us