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; Zitat von Tritoch i meant all lua coders... :icon_razz :icon_sad: ...aww man...(lol) :icon_razz...
-
05-10-2006, 02:29 PM #2191QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
:icon_sad:
Zitat von Tritoch
...aww man...(lol)
:icon_razz
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-10-2006, 05:00 PM #2192
a bug in my code
In my code, all the graphics keep blinking and they should just stay in the center if you move the player close enough to the wolf. Also, the wolfs health should erase so the new value will not write over the old one. Here is my code, any help would be great!
grass = Image.load("grass.png")
player = Image.load("player.png")
wolf = Image. load("wolf.png")
oldpad = Controls.read()
red = Color.new(255,0,0)
green = Color.new(0,255,0)
screenwidth = 480 - player:width()
screenheight = 272 - player:height()
Player = {}
Player[1] = { x = 100, y = 50 }
Player[2] = { Health = 100, Weapon = "Sword", Level = 1, Type = "Warrior"}
Player[3] = { Exp = 0 }
Wolf = {}
Wolf[1] = { x = 250, y = 150 }
Wolf[2] = { Health = 100, Weapon = "Claws", Type = "Wolf", Level = 1}
--Label the fighting sequence for the Function fight
function Fight()
--Paste in the grass
for a = 0, 14 do
for b = 0,8 do
screen:blit(32 * a, 32 * b, grass)
end
end
--Paste player and enemy in center
screen:blit(75,125, player)
screen:blit(200,125, wolf)
screen
rint(1,1,"Fight!!!")
screen
rint(50,50,"Weapon: " .. Player[2].Weapon, red)
screen
rint(250,125,"Weapon: " .. Wolf[2].Weapon, red)
screen
rint(250,150,"Type: " .. Wolf[2].Type, red)
screen
rint(250,175,"Level: " .. Wolf[2].Level, red)
screen
rint(50,75,"Type: " .. Player[2].Type, red)
screen
rint(50,100,"Level: " .. Player[2].Level, red)
screen.flip()
while true do
screen
rint(250,100,"Wolf's Health: " .. Wolf[2].Health, green)
screen
rint(50,25,"Player's Health: " .. Player[2].Health, green)
screen:flip()
pad = Controls.read()
if pad:cross() and oldpad:cross() ~= pad:cross() and Wolf[2].Health > 0 then
Wolf[2].Health = Wolf[2].Health - 5
end
oldpad = pad
screen.waitVblankStart()
end
end
while true do
pad = Controls.read()
screen:clear()
for a = 0, 14 do
for b = 0, 8 do
screen:blit(32 * a, 32 * b, grass)
end
end
screen:blit(Player[1].x, Player[1].y, player)
screen:blit(Wolf[1].x, Wolf[1].y, wolf)
--Check to see if they are near enough to battle
xvalue = Player[1].x - Wolf[1].x
yvalue = Player[1].y - Wolf[1].y
if xvalue < 0 then
xvalue = xvalue * -1
end
if yvalue < 0 then
yvalue = yvalue * -1
end
if xvalue < 90 and yvalue < 40 or xvalue < 90 and yvalue <40 then
screen:clear()
Fight()
end
if pad:left() and Player[1].x > 0 then
Player[1].x = Player[1].x - 2
end
if pad:right() and Player[1].x < screenwidth then
Player[1].x = Player[1].x + 2
end
if pad:up() and Player[1].y > 0 then
Player[1].y = Player[1].y - 2
end
if pad:down() and Player[1].y < screenheight then
Player[1].y = Player[1].y + 2
end
screen.waitVblankStart()
screen.flip()
end
-
05-10-2006, 05:01 PM #2193
the smileys should be periods and then a 'p' btw
-
05-11-2006, 03:01 AM #2194
- Registriert seit
- May 2006
- Beiträge
- 41
- Points
- 4.063
- Level
- 40
- Downloads
- 0
- Uploads
- 0
hmm, sorry if this has been asked and answered before but i don't have time to trawl through 220 pages

I've managed to incorporate sounds in .wav format, but they take up too much space and are not good enough quality.
i was wondering how i go about making / converting to .XM format which was included with the luaplayer download.
thanks in advance, Tri
-
05-11-2006, 03:12 AM #2195QJ Gamer Bronze
- Registriert seit
- Apr 2006
- Ort
- germany
- Beiträge
- 38
- Points
- 4.362
- Level
- 42
- Downloads
- 0
- Uploads
- 0
xm is a tracker format, compare it to midi but the latter unfortunately is not included
you must keep the wavs at 11250,8-bit mono max, at least that's what i'm using, not to get in trouble with mikmod. (or you could compile a newer ver of mikmod or sth to play midis?)
wav 2 xm is not an option, just too big. (you could use a wav as a single track and use it like a sample)-=imhotep=-
-
05-11-2006, 03:31 AM #2196QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Isnt the screen:flip() supposed to be screen.flip()?
Zitat von emericaska8r
-
05-11-2006, 03:50 AM #2197QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Is there a way how to see if the LuaPlayer doesn't find a file?
I mean so i can make it skip to load the ect. picure so it donsen't gives a error and forces you to restart?
This is the third time i ask this!Geändert von HaxxBlaster (05-11-2006 um 03:58 AM Uhr)
[CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
05-11-2006, 05:00 AM #2198QJ Gamer Bronze
- Registriert seit
- Jan 2006
- Ort
- Western Australia
- Beiträge
- 1.046
- Points
- 8.803
- Level
- 63
- Downloads
- 0
- Uploads
- 0
the only way you can possibly do that (as far as I know) is put comment parts in your code then when you need it back to normal take away the comment marks.
-
05-11-2006, 05:15 AM #2199QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
just explaining PopcOrn DeVil's answer.
Code:-->anything in the same line as the "--" marks are not read. >This line, however, is read and will result in an error since its not code.
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-11-2006, 05:24 AM #2200QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
No no no! WTF, i am not stupid!
It's like this: In my program Graphic Creator 2.0, that will be released as soon as i fix this last piece. It would load the latest saved work you have done, BUT if you don't have any work done it would be an error "Couldent find the file (xx.png)", and you will be forced to restart the LuaPlayer.
I would like it to jump over the loading of the picure, i would be something with a "return" comand, no one seems to know how to use it.Geändert von HaxxBlaster (05-11-2006 um 08:47 AM Uhr)
[CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
05-11-2006, 09:06 AM #2201QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
how about in the part where you load the image. you put:
Zitat von HaxxBlaster
i'm not sure if it'll work, its an educated guess.Code:elseif error("Autostart error") do return end end[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-11-2006, 09:44 AM #2202QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
I don't see why that would work at all.
But where will the "elseif" fit in to?
It will give no use if there is no way to see if the image is no able to be load, it it would get that error, there is no way to "return" back.
I have thought about this much, and the only way to solve my problem is to know if the picture is succesfully loadable or not, but no one seems to know sheit about it.[CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
05-11-2006, 10:20 AM #2203words 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
hmmm.... I probably could do it... I just need the Lua Source adn edit the blitting function/prototype to an 'int' instead of a 'void', that way it will retrun something... i may look into it...

...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
-
05-11-2006, 10:32 AM #2204QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Thanks man!
[CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
05-11-2006, 10:38 AM #2205QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Mayb something like this:
Zitat von HaxxBlaster
I'm not the best lua coder...Code:All your code here... Then screen:blit(x,y,xx.png) if screen:blit(x,y,xx.png) == false then screen:print(x,y,"You have not any saved work.", color) end
-
05-11-2006, 10:52 AM #2206
- Registriert seit
- Feb 2006
- Beiträge
- 31
- Points
- 4.248
- Level
- 41
- Downloads
- 0
- Uploads
- 0
How do you get netlib v1.4 to work?
-
05-11-2006, 10:53 AM #2207
Hi can anyone please help me with my program on page 220? I changed the screen.flip() but it still acts really weird.
-
05-11-2006, 11:01 AM #2208QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
PSPduh:
I tryed that first of all my ideas to solve my problem, it doesn't work.
I think that it is what SGC is going to take a look at.Geändert von HaxxBlaster (05-11-2006 um 11:07 AM Uhr)
[CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
05-11-2006, 11:03 AM #2209
Hey, nevermind about my program, i fixed it now by putting my whole function fight() as a loop, and put in a screen:clear() too. Thanks though.
-
05-11-2006, 11:50 AM #2210QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
you didnt post any code, so I assumed you made an 'if' statement out of the skip-of-nothing-is-there part of your app.
Zitat von HaxxBlaster
sorry, i'm no help to you here...I'm confident SG57 can fix your problem though!
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-11-2006, 03:16 PM #2211
Hi, i know somone here posted something about it but i can't find it.A sidescrolling code in lua like PSPsoldier to make someone move . counld somone help plz.
-
05-11-2006, 03:24 PM #2212
Hey does anyone know of a 'goto' command in lua. Like instead of calling a function, just actually skip to a part of you code without have to go back. Like the lbl and goto functions on a ti-83+ calculator.
-
05-11-2006, 03:58 PM #2213QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
hmmm.....mayb you could define a variable then check whether it equals a certain number, when it does equal that number then run the code.
Zitat von emericaska8r
On second thought, that might not answer your question.Code:duh = 0 if pad:cross() then duh = duh + 1 end if duh >= 2 then duh = 1 end if duh == 1 then (insert code here) end
Well, I try.
-
05-12-2006, 03:03 AM #2214QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
I'm sorry for the double post, but how would you do that a certain button is held down for 5 seconds or something.
Would it be like that or another way?Code:if pad:cross(180) then <insert code here> end
-
05-12-2006, 03:23 AM #2215
nope another way. You have to use a timer.
And no there isn't a goto command and neither a label command. You have to use functions for this.LUA manual:
[url]http://www.lua.org/manual/5.0/manual.html[/url]
LUA Wiki:
[url]http://wiki.ps2dev.org/psp:lua_player[/url]
-
05-12-2006, 06:59 AM #2216words 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
Hmm.... After looking throuigh the source, the Image loading is an integer, and it returns 1 on completion i belive, so give it a try.. So put a true or false statement, if the loading of an image is == 1, then it retruned completed, if not, do if not loadd an imgae ==1, then failed to load an image.

...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
-
05-12-2006, 07:11 AM #2217QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
that someone suggested looking at the 'music' file bundled with luaplayer. it has a side-scrolling background.
Zitat von ZereoX
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-12-2006, 09:47 AM #2218
Ok tkz il look at it tonight cause im at school.
-
05-12-2006, 01:06 PM #2219QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 166
- Points
- 5.453
- Level
- 47
- Downloads
- 0
- Uploads
- 0
can someone tell we what's wrong with this please?
I tried making a quick game as a joke and It won't work.
I read quick guide and built it around what it said, and whenever I try launching it in luaplayer it says that there is no script file found. I tried saving it as both script.lua and index.lua. any help appreciated.
I wanted to make it so that you had to press the cross button really fast to move the kid over to the "mom" befoe the pimp catches him and shanks him.Code:pimppicture=Image.load("pics/pimp.png") kidpicture=Image.load("pics/kid.png") mom=Image.load("pics/mom.png") background=Image.load("pics/background.png") winner=Image.load("pics/winner.png") loser=Image.load("pics/loser.png") distance=nul timer=1 pimp=430 kid=300 while true do timer=1 screen:clear() pad=Controls.read() if pad:cross() then kid=kid-2 end kid=kid-.5 pimp=pimp-.5 if kid=40 then while timer=1 pad=Controls.read() screen:blit(0, 0, winner) screen.flip() if pad:cross() then timer=2 end end end distance=kid+30 if pimp=distance then while timer=1 pad=Controls.read() screen.blit(1, 1, loser) screen.flip() if pad:cross() then timer=2 end end end screen.blit(0, 0, background) screen.blit(0, 100, mom) screen.blit(kid, 100, kidpicture) screen.blit(pimp, 100, pimppicture) screen.flip() end
-
05-12-2006, 01:19 PM #2220
Your code is horribly hard for me to read.
D:


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