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; System.usbDiskModeActivat e() -- You should make this activated by a button Code: usb = 0 if Controls.read():l() and usb == ...
-
11-15-2006, 08:35 PM #4141QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
System.usbDiskModeActivat e() -- You should make this activated by a button
Code:usb = 0 if Controls.read():l() and usb == 0 then System.USBDiskModeActivate() usb = 1 end if Controls.read():l() and usb == 1 then System.USBDiskModeDeactivate() usb = 0 end
white = Color.new(255, 255, 255) --You never even use this, so get rid of it
background = Image.load("images/menu.png")
November = Image.load("images/nov.png")
December = Image.load("images/dec.png")
January = Image.load("images/jan.png")
Febuary = Image.load("images/feb.png")
March = Image.load("images/mar.png")
April = Image.load("images/apr.png")
May = Image.load("images/may.png")
June = Image.load("images/june.png")
July = Image.load("images/july.png")
August = Image.load("images/aug.png")
September = Image.load("images/sept.png")-- I assume you'll use these later
--You need to make your code into a main loop
That code will make it blit the background and make l toggle USB. To disply the month images:Code:while true do screen:blit(0, 0, background)--You dont need to put false, only true if you want it true screen.waitVblankStart() screen.flip() end -- You need to end it
screen:blit(x,y,nameofamo nth) -- Place that in your main loop AFTER you blit the background
-
11-15-2006, 08:36 PM #4142Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
for one thing, there is a space at the end of the ACTIVAT_E take it out, second put the images in the same folder as the index.lua and take out the "images/" from code and
Zitat von cheese the psp
while true do
screen:blit(0, 0, background)
screen.waitVblankStart()
screen.flip()
end
you need to add that
-
11-15-2006, 08:50 PM #4143QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Images dont need to be in the same directory. Putting them in direcxtories organizes them.
-
11-15-2006, 08:59 PM #4144words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Says you ;)

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
11-15-2006, 09:04 PM #4145lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
It really doesent matter where you put the images, AAs long as they load.
-
11-16-2006, 06:40 AM #4146Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Where would i put oldpad = pad or whatever. would i put that next under
Zitat von Access_Denied
pad = Controls.read()
or after
if pad:r() and oldpad:r() ~= pad:r() then
computer = math.random(3,5)
???
OK getting really mad over here REALLY MAD.
ok first i still have the question above my really mad sentence and i have another problem.
in lua player my menu is named index.lua and the other things are the pics and multiplayer.lua and singleplayer.lua now it clearly says index.lua and lua player is supposed to run that but it goes straight to my multiplayer.lua file instead WTF. ive tried changing directories and everything but its being a little B*** is there a function or something im missing?
EDIT: still not working i delclared oldpad = Controls.read() outside of the main loop and it still didnt work.Geändert von GuitarGod1134 (11-16-2006 um 08:33 AM Uhr)
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-16-2006, 12:37 PM #4147Designs

- Registriert seit
- Jul 2006
- Ort
- Canada
- Beiträge
- 1.395
- Points
- 14.040
- Level
- 76
- Downloads
- 0
- Uploads
- 0
i made a bullet collision so when my plane shoots the enemy plane, the enemy plane turns into a fireball untill it goes off the screen and turns back to a plane again so i did this
but the problem is when it loads the image again, the game lags, but it loads every like second or so, so the game is becoming lag fiestaCode:if spot1.x>=470 then obst1 = Image.load("enemy1.png") end if spot2.x>=470 then obst2 = Image.load("enemy2.png") end if spot3.x>=470 then obst3 = Image.load("enemy3.png") end if spot4.x>=470 then obst4 = Image.load("enemy4.png") end
-= Double Post =-
nevermind problem solvedGeändert von yoyomacy (11-16-2006 um 12:37 PM Uhr) Grund: Automerged Doublepost

-
11-16-2006, 01:49 PM #4148QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
how do u make a program a loop
all those happy faces were supposed to be "p"sSystem.usbDiskModeActivat e()
white = Color.new(255, 255, 255)
black = Color.new(0, 0, 0)
screen
rint(194, 136, ".......LOADING, PLEASE WAIT.......", black)
screen.flip()
background = Image.load("menu.png")
November = Image.load("nov.png")
December = Image.load("dec.png")
January = Image.load("jan.png")
Febuary = Image.load("feb.png")
March = Image.load("mar.png")
April = Image.load("apr.png")
May = Image.load("may.png")
June = Image.load("june.png")
July = Image.load("july.png")
August = Image.load("aug.png")
September = Image.load("sept.png")
screen:clear()
while true do
screen:blit(0, 0, background)
screen.waitVblankStart()
screen.flip()
end
pad = Controls.read()
screen
rint(5, 261, "controls", white)
screen
rint(5, 251, "press left arrow for november", white)
screen
rint(5, 241, "press right arrow for december", white)
screen
rint(5, 231, "press up arrow for january", white)
screen
rint(5, 221, "press down arrow for febuary", white)
screen
rint(5, 211, "press x for march", white)
screen
rint(5, 201, "press 0 for april", white)
screen
rint(5, 191, "press [] for may", white)
screen
rint(5, 181, "press ^ for june", white)
screen
rint(5, 171, "press R for july", white)
screen
rint(5, 161, "press L for august", white)
screen
rint(5, 151, "press 'select' to take a screenshot", white)
screen
rint(5, 141, "press 'start' to restart", white)
screen.flip()
if pad:left() then
screen:blit(0, 0, November, false)
screen.flip()
end
if pad:right() then
screen:blit(0, 0, December, false)
screen.flip()
end
if pad:up() then
screen:blit(0, 0, January, false)
screen.flip()
end
if pad:down() then
screen:blit(0, 0, Febuary, false)
screen.flip()
end
if pad:cross() then
screen:blit(0, 0, March, false)
screen.flip()
end
if pad:circle() then
screen:blit(0, 0, April, false)
screen:flip()
end
if pad:square() then
scree:blit(0, 0, May, false)
screen:flip()
end
if pad:triangle() then
screen:blit(0, 0, June, false)
screen:flip()
end
if pad:r() then
screen:blit(0, 0, July, false)
screen:flip()
end
if pad:l() then
screen:blit(0, 0, August, false)
screen:flip()
end
if pad:select() then screen:save("screenshot.t ga") end
if pad:start() then
break
end
-
11-16-2006, 01:59 PM #4149QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- Cross Country Course
- Beiträge
- 794
- Points
- 6.863
- Level
- 54
- Downloads
- 0
- Uploads
- 0
What exactly are you making? An image loader that shows the background that your PSP has each month?
Anyway...
while true do
screen:blit(0, 0, background)
screen.waitVblankStart()
screen.flip()
end
pad = Controls.read()
That, in bold, is not needed(to my knowledge)
Try this:
while true do
screen:blit(0, 0, background)
pad = Controls.read()
Oh, and at the end:
if pad:start() then
break
end
You need to add another end at the end so it should look like this:
if pad:start() then
break
end
end
-
11-16-2006, 02:11 PM #4150Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
actually, when you load an image, luaplayer (or C/C++) searches for the image in the directory specified, so having a lot of images could slow the loading time. not too significant though
Zitat von pspgamer81
--------------------------------------------------------------------------------------
-
11-16-2006, 02:38 PM #4151I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
First of all, for the LuaPlayer things. It doesn't run what the program is named. So if it's named index.lua, it could still run script.lua. You have to edit the .bat file to your script name. And second, here's how the oldpad thing goes:
Zitat von GuitarGod1134
Code:oldpad = Controls.read() while true do screen:clear() pad = Controls.read() code code screen.waitVblankStart() screen.flip() oldpad = pad end

-
11-16-2006, 05:33 PM #4152QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- Cross Country Course
- Beiträge
- 794
- Points
- 6.863
- Level
- 54
- Downloads
- 0
- Uploads
- 0
Alright, I need help on getting my bomb to drop. I've searched for answers but have received nothing. So I need to know how to make my bomb move from the top of the screen to the spot where i want it to move. Its been bugging me b/c i cannot figure out how to do it....Help please.
-
11-16-2006, 05:50 PM #4153words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
Uh, blit it where you want on the screen *rolls eyes*

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
11-16-2006, 06:00 PM #4154QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- Cross Country Course
- Beiträge
- 794
- Points
- 6.863
- Level
- 54
- Downloads
- 0
- Uploads
- 0
No, I want animation of the bomb droping
-
11-16-2006, 06:28 PM #4155I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
while true do
screen:clear()
screen:blit(bomb.x,bomb.y ,bomb)
bomb.y = bomb.y -2
-
11-16-2006, 06:36 PM #4156QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- Cross Country Course
- Beiträge
- 794
- Points
- 6.863
- Level
- 54
- Downloads
- 0
- Uploads
- 0
Its not working
-
11-16-2006, 06:38 PM #4157
for loading images
I was looking before, and i dunno if you got it already, but to load an image you need the .\ thingy. ex.
Code:July = Image.load("./Images/July.png")
-
11-16-2006, 06:40 PM #4158I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
No you don't this will do fine:
Zitat von emericaska8r
July = Image.load("Images/July.png")
-
11-16-2006, 06:44 PM #4159QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
Is there any way to make it load alot of photos?
because i have like 12 photos loading and it always comes up with an error
but when i limit the number of photos it works fine
-
11-16-2006, 07:09 PM #4160Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
luaplayer only has like 3mb of ram, and each picture takes up like 500k (some less, some more). so yeah, if you want more, C/C++ will work.
Zitat von cheese the psp
--------------------------------------------------------------------------------------
-
11-16-2006, 07:15 PM #4161I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Here's a small example, but you must name them like this:
Zitat von cheese the psp
photo = {}
photo[1] = "Images/Janruary.png"
photo[2] = "Images/February.png"
etc.
etc.
In this code, if you change the value of 'current', it will load the image in the table with that number.Code://insert your image table from above here// current = 1 image = nil while true do screen:clear() image = Image.load(photo[current]) screen:blit(0,0,image) screen.waitVblankStart() screen.flip() end

-
11-16-2006, 07:34 PM #4162QJ Gamer Silver
- Registriert seit
- Oct 2006
- Ort
- 貴方
- Beiträge
- 1.159
- Points
- 7.371
- Level
- 57
- Downloads
- 0
- Uploads
- 0
i used 30 kb images though...
the entire program is 500kb
-
11-16-2006, 07:52 PM #4163I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
It doesn't matter. The PSP loads them in RAW format. A 1kb picture will take up the same amount of RAM as a 1MB picture.
Zitat von cheese the psp

-
11-17-2006, 04:18 AM #4164Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Thanks man Im gonna try that.
Zitat von Access_Denied
Well my parents just took away my psp so i cant work out the bugs or anything on my game so if someone could pm me or something and beta it ill send u the source and the pics and if u get an error keep telling me what error u get. if anyone could do that that would be a big help and i would put u in the heylookatme.txt file in the credits. u need a yahoo messanger mine is
[email protected]
and the yahoo screen name is
douchberryGeändert von GuitarGod1134 (11-17-2006 um 04:31 AM Uhr)
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-17-2006, 11:50 AM #4165
hey when i run my game it comes up loop is gettable what is that and how do i fix it.
-
11-17-2006, 12:18 PM #4166Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Loop is gettable? that doesnt even make sence
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
11-17-2006, 01:43 PM #4167
thats wut comes up
index.lua:3: loop in gettable
press start to restart
-
11-17-2006, 02:07 PM #4168Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
loop in gettable is kinda like a free card. it can be a wide wariety of things. we'll need to see your code.
Zitat von Blackbelttcon
--------------------------------------------------------------------------------------
-
11-17-2006, 02:11 PM #4169
blue = Color.new(0,0,255)
player = Image.c13(32,32)
player.clear(blue)
Player = { x = 30, y = 100 }
dofile("./police circle.lua")
function movePlayer()
pad = Controls.read()
if pad:right() then
Player.y = Player.y + 5
end
if pad:left() then
Player.y = Player.y - 5
end
if pad:down() then
Player.x = Player.x + 5
end
if pad:up() then
Player.x = Player.x - 5
end
end
while true do
screen:clear()
movePlayer()
screen:blit(Player.y,Play er.x,player)
screen.waitVblankStart()
screen.flip()
end
-= Double Post =-
then the cop circle is
green = Color.new(0, 200, 0)
blockImage = Image.cop(64,39)
blockImage:clear(green)
block = { x = 10, y = 100 }
radius = 100
speed = 5
xcenter = 240
ycenter = 135
degree = 0
radian = 0
while true do
screen:clear()
degree = degree + speed
radian = (degree/180)*math.pi
block.x = xcenter+math.cos(radian)* radius
block.y = ycenter-math.sin(radian)*radius
screen:blit(block.x,block .y,blockImage)
screen.waitVblankStart()
screen.flip()
end
endGeändert von Blackbelttcon (11-17-2006 um 02:11 PM Uhr) Grund: Automerged Doublepost
-
11-17-2006, 03:24 PM #4170I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I'm assuming this:
player = Image.c13(32,32)
player.clear(blue)
should be this:
player = Image.createEmpty(32,32)
player:clear(blue)


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