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; nope..that didnt do anything...i changed every "save" to "profile". oh, if you were wondering, 'save.lua' file only has the word ...
-
12-03-2006, 12:09 PM #4501QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
nope..that didnt do anything...i changed every "save" to "profile". oh, if you were wondering, 'save.lua' file only has the word 'true' in it. thats it.
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 12:16 PM #4502I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Maybe it should be:
while first == "true" do
Try adding the quotes.
-
12-03-2006, 12:23 PM #4503QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
didnt work either...

i even added these: "" to the save file text...still nothing.
could it be luaplayer? i have cool's mod.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 12:27 PM #4504I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I don't think so. Cools mod is the same thing, only with a few more functions. Could you post your whole code?

-
12-03-2006, 12:51 PM #4505QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
this is all the code that has anything to do with the problem. without these codes, it runs fine, but not how i want it to.
main script -
Save File -Code:profile = io.open("save.lua", "r") first = profile:read() profile:close() -- skipping some code while first == "true" do -- skipping alot of code end
Code:"true" -- player's first time playing
Geändert von EminentJonFrost (12-03-2006 um 01:03 PM Uhr)
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 01:08 PM #4506I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Maybe instead of writing true, write 0 for false and 1 for true. Numbers might be easier to work with.
Zitat von EminentJonFrost

-
12-03-2006, 01:13 PM #4507QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
nope.
...
i'm gonna have to find some way around this then...
if anyone thinks they know whats wrong though, please tell me.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 01:30 PM #4508QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
did you try adding
to the savefile?Code:first = "true"
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
12-03-2006, 01:36 PM #4509QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
this, translated, pretty much means that.
Code:first = profile:read()
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 01:39 PM #4510QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
i know but you may have to define it in the savefile then just us do:file(filename)
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
12-03-2006, 01:45 PM #4511QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
hmm...i'll try that :)
so simple, it just might work.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 02:12 PM #4512Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von slicer4ever
taht wont work.
-= Double Post =-
Zitat von EminentJonFrost
try this:
main script -
Code:profile = io.open("save.lua", "r") first = profile:read() profile:close() -- skipping some code if first == "true" then -- skipping alot of code endGeändert von Grimfate126 (12-03-2006 um 02:12 PM Uhr) Grund: Automerged Doublepost
--------------------------------------------------------------------------------------
-
12-03-2006, 04:14 PM #4513QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
Grimfate - that didnt work...errors started coming up about how many 'ends' there were
slicer4ever - i did that, sorta. and it worked!
i did this:
worked like a charm! :)Code:dofile("./save file.lua") while first == true do ... if button pressed save = io.open("save file.lua", "w") save:write("first = false") save:close() end ... end
successful bypass gentlemen! lol
thanks Access_Denied, Grimfate, and slicer4ever! :Punk:[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-03-2006, 06:58 PM #4514
tight, i don't know why nobody could get it to work, but this is a great bypass! nice ideas!!!
Zitat von EminentJonFrost
-
12-04-2006, 06:03 AM #4515QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
I need help with my ping pong game, once more...
What i need is, the variable for "bounce away" because i dont know what to write there.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 < (16*64) 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-04-2006, 06:40 AM #4516QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Setup a direction system for the ball and make collisions change its directio. then do if direction == blah then ballx = ballx-1 or whatever
-
12-04-2006, 06:46 AM #4517QJ Gamer Bronze
- Registriert seit
- Sep 2006
- Ort
- Denmark
- Beiträge
- 664
- Points
- 9.316
- Level
- 64
- Downloads
- 0
- Uploads
- 0
Sry Tactical, to be honest, i didn't understand a (beep) of what you said.
Im a total n00b to lua...My PSP Projects:
___________________
None.
-
12-04-2006, 11:12 AM #4518No longer a community member.
- Registriert seit
- Jun 2006
- Ort
- Nederland
- Beiträge
- 3
- Points
- 17.748
- Level
- 84
- Downloads
- 0
- Uploads
- 0
Allright I hava a problem,
1st time in this thread so don't pLh4M3 me
When I run this code:
Spoiler for Code:
Lowser will just do nothing,
It loads something for about 2 seconds,
and then it doesn't do anything!
I can still use home and such...
Can someone help me?!?
btw: does anyone know where to download that luaplayer for windows that displays the error code, instead of just shutting off?
I know it exists......
-
12-04-2006, 12:33 PM #4519Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
on bounce away this is what i would do. I would assign a variable at the beginning of ur code outside of the main loop.... u know what let me just rewrite your code
Zitat von gameo
Spoiler for Your code:
Right off the top if any other coders find problems tell me. or just fix itGeändert von GuitarGod1134 (12-04-2006 um 12:33 PM Uhr) Grund: Automerged Doublepost
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-04-2006, 02:06 PM #4520Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von gameo
well, you cant just magically call a function called "bounceBall". set-up a physics system. ill get you started:
then..Code:ball = {x = 50, y = 50, img = Image.load("ball.png"), xMove = 3, yMove = 3 }
Code:ball.x = ball.x + ball.xMove ball.y = ball.y + ball.yMove if (ball hits paddle) then ball.xMove = (something else) ball.yMove = (something else) end
--------------------------------------------------------------------------------------
-
12-04-2006, 02:58 PM #4521QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
@frost np anytime
@game you need to set up a direction system where it well move the ball based on it's current direction just make a simple variable called direction then based on the way the ball hits adjust the direction and so on and so forth1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been
-
12-04-2006, 03:10 PM #4522QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
"@game you need to set up a direction system where it well move the ball based on it's current direction just make a simple variable called direction then based on the way the ball hits adjust the direction and so on and so forth
"
Issn't that exactly what I said? Anyways, by direction system I mean this:
Add a variable called "d"or "direction" to the table for the ball. However, since the ball will be moving diagonally, you need to use two variables. For this ill use d1 and d2. The number on the endof the direction indicates how fast the ball should go when it is going that direction.
Then to make the ball move do something like:
if ball.d == u1 and ball.y > 0 then
ball.y = ball.y - 1
elseif ball.d == u2 and ball.y > 0 then
ball.y = ball.y - 2
end
And then do that for however many you want each direction. The ball will move differently depending on what and how high its two directions are. Then for changing the ball's directions, make some formulas and then do something like
if collision then ball.d1 = something ball.d2 = something end
The something in there can be determined by a ricochet formula which I'll leave youto figure out.
-
12-04-2006, 03:17 PM #4523QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
whats the name of the file of that script. it should be "index.lua". if thats not the problem then come back.
Zitat von savagefreak
oh, to have luaplayer for windows display the error you have to do this:
right-click the "test" file. its a "Windows NT Command Script". (hover the mouse over the file to see it)
Edit it.
it should open and say "luaplayer index.lua"
just go down one line (hit enter) and type "pause". then save. done![CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
12-04-2006, 08:58 PM #4524Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von -TacticalPaper-
its not called that but here is the basic formula:
when you have a rounded object, that hits against a flat surface, your incoming angle is that angle between an imaginary perpendicular (which is drawn straight up from the point of collision), and the path of the object. your path of "reflection" (im using wave terminology) is equal to the incoming angle. a picture to help:
so basically, you will have to use trig (sin and cos) to have a perfectly simulated game. but, no one cares that much, thankfully.--------------------------------------------------------------------------------------
-
12-05-2006, 06:32 PM #4525
i made my own simple pong game, and i just had two variables for the x and y values of the ball's slope, and another variable for the speed.
when the ball collides, just think about where it is going next, and it is easy to figure out what the new slope must be
-
12-06-2006, 02:37 AM #4526.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Anyone know whats wrong with this?
if (housex + house:width() > packx) and (housex < packx + pack:width()) and (housey + house:height() > packy) and (housey < packy + pack:width()) then
score = score + 1
end
-
12-06-2006, 03:56 AM #4527I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I don't see anything wrong, but sometimes I miss things. If I were you, I would use the evilmana tutorilas. It teaches you how to make a function, so you don't need to write dozens of if statements.
Zitat von Yongobongo

-
12-06-2006, 05:41 AM #4528QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Its probably because hes using housex when it should be house.x and house.img:width()
-
12-06-2006, 08:16 AM #4529Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
how would u make a racing game in lua? im confused on how.... want to make one after playing some racing games i was inspired lol. you would need like speed variable and acceleration but im not quite sure how to make it can someone give a quick example.
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-06-2006, 11:04 AM #4530QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
u mean 3d racing game like wedge racer??
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]


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