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; HEY CHEEZ PIRATE CATCH!!!!!! http://dl.qj.net/lua-player-v0.20-mo...8717/catid/151 Lol....
-
12-03-2006, 01:36 AM #4471Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
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!
-
12-03-2006, 01:46 AM #4472QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
edit - nvrmind.
...the mistake was embarrassing...lol
Geändert von EminentJonFrost (12-03-2006 um 02:03 AM Uhr)
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 02:04 AM #4473QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
Allright EminentJonFrost, seems like errors never end:
Error: index.lua 27: ´then´ expected near ´x64´My PSP Projects:
___________________
None.
-
12-03-2006, 02:07 AM #4474QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
um, lol, wheres the script?
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 02:11 AM #4475QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
Here it is:
white = Color.new(255, 255, 255)
screen
rint(136, 136, "Loading LUA Pong...", white)
screen.flip()
background = Image.load("Background.pn g")
bat11 = Image.load("Bat1.png")
bat21 = Image.load("Bat2.png")
bat1 = { x = 20, y = 100 }
bat2 = { x = 460, y = 100 }
ball = { x = 240, y = 146, image = Image.load("Ball.png") }
screen.waitVblankStart(60 )
while true do
screen:clear()
screen:blit(bat1.x, bat1.y, bat11, true)
screen:blit(bat2.x, bat2.y, bat21, true)
pad = Controls.read()
if ball.x == bat.x and ball.y >= bat.y and ball.x < 16x64 then
bounce away
end
if pad:down() then
bat1.y = bat1.y +2
end
if pad:up() then
bat1.y = bat1.y -2
end
if pad:cross() then
bat2.y = bat2.y +2
end
if pad:triangle() then
bat2.y = bat2.y -2
end
if pad:start() then
break
end
screen
rint(136, 136, "Welcome to the world of PPP.", white)
screen.waitVblankStart()
screen.flip()
endMy PSP Projects:
___________________
None.
-
12-03-2006, 02:14 AM #4476Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Are you trying to say if ball.x is greater then the number that is the answer of 16 multiplied by 64? Because I dont see a variable 16x64 in your code.
So if you would like that to be 16 multiplied by 64 which is pointless I think because you can just use the number 1024. but if thats what you want then this should work.
if ball.x == bat.x and ball.y >= bat.y and ball.x < (16*64) then
but i would just do
if ball.x == bat.x and ball.y >= bat.y and ball.x < 1024 then
not to mention bounce away isnt a valid statement.
also while ur loading ur background there is a space in the suffix it should be Background.png not background.pn gIf 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!
-
12-03-2006, 02:20 AM #4477QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
EminentJonFrost explained that i should write the size of my image there.
And the error with background.pn g thats not me, its a little error in QJ or something, because my script is not like that.My PSP Projects:
___________________
None.
-
12-03-2006, 02:21 AM #4478Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
But Am I right u mean 16 multiplied by 64 right?
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!
-
12-03-2006, 02:22 AM #4479QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
Yes. Not ment as a variable.
And the "bounce away" that was eminentjonfrost who told me to write that.My PSP Projects:
___________________
None.
-
12-03-2006, 02:24 AM #4480QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
i shoulda clarified a bit there...
sorry
lemme do it in an edit...gimme a sec
EDIT - ok, lets say that your image of the bat is 5x20. so its 4 times as high is it wide. that wont make a pretty paddle for ping pong, but it fits this example.
the coordinates (i use this word alot lately..) for the image, if it were blitted at (10, 10) would be:
10,10-----15, 10
|
10, 30-----15, 30
pretend thats an image. lol
now, the way to make the ball do something when it comes into contact is to make sure the ball cannot enter the image without something happening.
those numbers are from 'image' i made above. look at it until it makes sense.Code:image = { x = 10, x2 = 15, y = 10, y2 = 30 } -- see where i got these numbers from?
so this is the code for the 'if' statement. (the if statement is for this example, you gotta change the numbers to fit your case)
it looks like you're alot newer to this than i thought. you're supposed to put your own code in the if statement so that you get the ball to do what you want, but i dont think you know how to yet...Code:if ball.x < image.x2 and ball.x > image.x and ball.y < image.y2 and ball.y > image.y then bounce away or do something end
Geändert von EminentJonFrost (12-03-2006 um 02:37 AM Uhr)
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 02:24 AM #4481Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Ok well you use (16*64) then because the x is read according to lua player as a letter the multiplication operator is *.
And do you know what to put where bounce away is? could help u if u dont.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!
-
12-03-2006, 02:28 AM #4482QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
allright.
My PSP Projects:
___________________
None.
-
12-03-2006, 02:50 AM #4483QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
my last post should help...
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 07:14 AM #4484Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Im really gettin angry i'm making my game and there must be such a simple error but i just cant see it. line 12 loop in gettable. Whats wrong ?
white = Color.new(255,255,255)
kitchen = Image.load("kitchen.png")
Player = Image.load("mouse.png")
while true do
pad = Controls.read()
if pad:up() then
Player.y = Player.y + 1
end
if pad:down() then
Player.y = Player.y - 1
end
if pad:right() then
Player.x = Player.x + 1
end
if pad:left() then
Player.x = Player.x - 2
end
screen:clear()
screen:blit(0,0,kitchen)
screen:blit(240,130,Playe r)
screen.waitVblankStart()
screen.flip()
end
-
12-03-2006, 07:16 AM #4485Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
you havent defined anything called "Player.x" or "Player.y"
Zitat von eldiablov
--------------------------------------------------------------------------------------
-
12-03-2006, 07:29 AM #4486Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Erm i just thought that it'd know that it's the players co-ordinates ?
-
12-03-2006, 07:30 AM #4487QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
you gotta give player.x and player.y values.
edit - nope. you gotta spell it out for luaplayer.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 07:34 AM #4488QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Luaplayer doesn't know ANYTHING except for what to do when you give it a command. You can't go off using undefined variables.
-
12-03-2006, 07:36 AM #4489Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Ive added this in
Player = {}
Player.x = 230
Player.y = 135
then carry on as normal but it still doesnt work. Someone give me some sort of direction
-
12-03-2006, 07:39 AM #4490QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
"but it doesn't work"
What error does it give?
I know what's wrong, but you DO need to be more specific in "it doesn't work"
Anyways, you need to define the player's image with a different variable than the x-y table. Also you need to put player.x and player.y inside the table, like this:
Player = { x = blah, y = blah }
-
12-03-2006, 07:41 AM #4491Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Ok thank you ill try it
-
12-03-2006, 07:44 AM #4492Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
after you do player = {}
Zitat von eldiablov
do: Player.img = Image.load("mouse.png")
then change all the times you use Player to Player.img
--Vaza
-= Double Post =-
you don't HAVE to do that.
Zitat von -TacticalPaper-
you can define like player.x, but its cleaner this way^^
--VazaGeändert von Vaza (12-03-2006 um 07:44 AM Uhr) Grund: Automerged Doublepost
-
12-03-2006, 07:50 AM #4493Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
white = Color.new(255,255,255)
kitchen = Image.load("kitchen.png")
Player.img = {x = 240, y = 130}
Player.img = Image.load("mouse.png")
while true do
pad = Controls.read()
if pad:up() then
Player.img.y = Player.y + 1
end
if pad:down() then
Player.img.y = Player.img.y - 1
end
if pad:right() then
Player.img.x = Player.img.x + 1
end
if pad:left() then
Player.img.x = Player.img.x - 2
end
screen:blit(240,130,Playe r.img)
screen:clear()
screen:blit(0,0,kitchen)
screen.waitVblankStart()
screen.flip()
end
ATtempt to index Player a nil value ?
-
12-03-2006, 07:56 AM #4494QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
You defined player as a table then you defined it as an image.
Luaplayer thinks player is an image.
You need to use different variables when defining them.
-
12-03-2006, 08:10 AM #4495Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Sorry to go on but could you go further into what you're saying i'm quite new to this
-
12-03-2006, 08:15 AM #4496QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
white = Color.new(255,255,255)
kitchen = Image.load("kitchen.png")
Player = {x = 240, y = 130, img = Image.load("mouse.png") }
while true do
pad = Controls.read()
if pad:up() then
Player.y = Player.y - 1
end
if pad:down() then
Player.y = Player.y + 1 -- You had the +/- backwards
end
if pad:right() then
Player.x = Player.x + 1
end
if pad:left() then
Player.x = Player.x - 2
end
screen:clear()
screen:blit(0,0,kitchen)
screen:blit(Player.x,Play er.y,Player.img)
screen.waitVblankStart()
screen.flip()
end
You needed to fix a few different things. There's a script that SHOULD do as intended.
-
12-03-2006, 08:19 AM #4497Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
You don't know how much i appreciate that. Thanks very much to all three of you
-
12-03-2006, 09:56 AM #4498QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Toronto, Ontario
- Beiträge
- 92
- Points
- 4.413
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Okay, I just started LUA yesterday... I made a little sample of an RPG I'm trying to make... I can't seem to get it to work... I attached the file here so you can download it and see it... Also, I need help with adding images underneath the text of the player/enemy. I know how to load/display images, I just can't get them to display properly in the game, it gives me an error when I try... Please try out the sample/demo I made... And please, don't flame me. I'm just looking for help
-
12-03-2006, 10:56 AM #4499QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
pspillows, heed my advice, it will help indefinitely. you say you got started with lua yesterday? if thats the extent of your programming history its best not to aim high and try to make an RPG. not gonna happen. sorry, way of the virtual world my friend. see how long i've been a member here? i still dont get alot of the things people do on here, even in lua, my most experienced field. heck, in a second i'm about to post about my problem. i cant say what you should do to further yourself in this, but i can tell you what NOT to do. dont aim high with a crossbow when you need a sniper. look at what other devs do and ask a question here and there after honestly putting effort into it and, before you know it, you'll be doing fine.
EDIT - i need help with reading and writing other files. i'm making a save file, if you will, that tracks progress so the player cant do some of the things that are possible in the beginning. in my game, players will first have to customize their..er..characters (cant really call them characters really, but thats another story) then they set off to play the rest of the game. i'm making a save file so that the result would be something like:
-= Double Post =-Code:while (player hasnt played before, variable from save file) do customize character else while (player has played before, same variable with different value) do whatever comes next end
my menu leaves to another script which starts here:
the script automatically goes back to the menu after it flickers.Code:screen:clear(black) screen.flip() screen:clear(black) bg = Image.load("project pics/statsbg.png") size = 2 speed = 2 recovery = 2 selectstat = 3 save = io.open("save.lua", "r") -- \ first = save:read() ------------- heres whats giving me trouble save:close() -------------------/ while first== true doGeändert von EminentJonFrost (12-03-2006 um 10:56 AM Uhr) Grund: Automerged Doublepost
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 11:02 AM #4500I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Use a different file name, not save. There's probably a function that starts with 'save:'
Zitat von EminentJonFrost



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