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; How are we suppost to help you if we have no idea what you are trying to do?...
-
11-19-2005, 05:52 PM #301Developer

- Registriert seit
- Jun 2005
- Ort
- At my house...
- Beiträge
- 886
- Points
- 8.360
- Level
- 61
- Downloads
- 0
- Uploads
- 0
How are we suppost to help you if we have no idea what you are trying to do?
F.A.L.O?
-
11-20-2005, 02:06 PM #302words 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
You know, an arrow arcs when shot, a bullet arcs but slowly, stuff like that
what im asking is so that when i shoot my bullet or arrow, it arcs about 3 pixels and rotates a lil every 1/4 a second
Do you know what I mena yet? I have an idea but i doubt itll work

...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-21-2005, 01:37 AM #303
- Registriert seit
- Jul 2005
- Beiträge
- 4
- Points
- 4.574
- Level
- 43
- Downloads
- 0
- Uploads
- 0
Files and tables
Someone know which is the command to create a new file (text file) where i can put a table?
-
11-21-2005, 11:23 AM #304
still no answer for my question?
-
11-21-2005, 12:06 PM #305QJ Gamer Silver
- Registriert seit
- Oct 2005
- Ort
- Sheffield, UK
- Beiträge
- 844
- Points
- 8.201
- Level
- 61
- Downloads
- 0
- Uploads
- 0
i solved my problem now
Geändert von will1234 (11-22-2005 um 09:58 AM Uhr)
-
11-23-2005, 05:47 AM #30611th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Okay hi everyone.
I am making a new game...
This is gonna be my first side scroller.
Now some of my code was from my chao garden
so it might not be all Fancy and neat..
Anyway i need to know how to make my Player
Jump on a barrier or image.
Here's alittle bit of my code. \\//
This isnt all my code but it'a what i have found that help's me.Code:sprite = {} sprite[1] = Image.load("sprite.png") sprite[2] = Image.load("sprite2.png") sprite[3] = Image.load("sprite3.png") sprite[4] = Image.load("sprite2-2.png") sprite[5] = Image.load("sprite3-3.png") sprite[6] = Image.load("sprite-1.png") sprite[7] = Image.load("sprite4.png") sprite[8] = Image.load("sprite4-4.png") Spriteimg=sprite[1] anim = 1 animTimer = 0 LastDirection = sprite[1] function duck() if LastDirection==sprite[1] then Spriteimg=sprite[7] elseif LastDirection==sprite[6] then Spriteimg=sprite[8] end end function walkRight() LastDirection=sprite[1] animTimer=animTimer+1 if animTimer>=1 and animTimer<=4 then Spriteimg=sprite[2] elseif animTimer>=5 and animTimer<=8 then Spriteimg=sprite[3] end if animTimer>=9 then animTimer=0 end end function walkLeft() LastDirection=sprite[6] animTimer=animTimer+1 if animTimer>=1 and animTimer<=4 then Spriteimg=sprite[4] elseif animTimer>=5 and animTimer<=8 then Spriteimg=sprite[5] end if animTimer>=9 then animTimer=0 end end while true do screen:blit(0, 0, Background) pad = Controls.read() if pad:right() then walkRight() x=x+3 Spriteimg=Spriteimg elseif pad:left() then walkLeft() x=x-3 Spriteimg=Spriteimg elseif pad:up() then walkLeft() y=y+3 Spriteimg=Spriteimg elseif pad:down() then walkLeft() y=y-3 Spriteimg=Spriteimg else Spriteimg=LastDirection end
If anyone's intrested in making GFX or helping for my new project then
please PM me as it's Invite's ONLY.
Thank's :icon_bigg
P.S
I Also have a jumping problem lol.FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
-
11-23-2005, 06:48 PM #307QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- script.lua
- Beiträge
- 426
- Points
- 6.087
- Level
- 50
- Downloads
- 0
- Uploads
- 0
There's not really a function to create a file, you just tell lua what the file name is and then make it write on it. Here's an example:
Zitat von aldebaran
You could prob replace SaveFile for the file's name inCode:SaveFile="save.txt" function saveTable() file=io.open(SaveFile,"w") if file then file:write("MyTable={") for index, value in Table do--TABLE WOULD BE THE TABLE'S NAME! file:write(value..",")--THE VALUE ALONE end file:write("}") file:close() end end
Also, I only made it write the index's value in that example, but you can make it write the index too that's all up to you.Code:file=io.open(SaveFile,"w")
So just expirement. :)
-
11-23-2005, 07:02 PM #308QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- script.lua
- Beiträge
- 426
- Points
- 6.087
- Level
- 50
- Downloads
- 0
- Uploads
- 0
I think I understand what you mean by ARCing down. Make the bullet fall on the ground after a while right? Anyway, here's a cheap way you could do it.
Zitat von SG57
I'm assuming the bullet's Y is "bulletY", so here goes.
That would be like I said a cheap trick. But then again, I never saw your code and this might not be the best idea.Code:function bulletGravity() local CurrentY=bulletY local time=0 time=time+1 if time>=50 then --WHEN THE BULLET START'S DROPPING DOWN for y=CurrentY,272 do --FROM TRAJECTORY TO BOTTOM OF SCREEN bulletY=bulletY-0.5 end end end
On top of that, it might freeze the game and make the bullet stop going forward if its used as a single function. Your best bet would be to create one big function and have the bullet's velocity ,arcing effect and what not into one function.
Anyway good luck.
(sorry for the double post.)Geändert von XteticX (11-23-2005 um 07:05 PM Uhr)
-
11-24-2005, 12:48 AM #309
- Registriert seit
- Jul 2005
- Beiträge
- 4
- Points
- 4.574
- Level
- 43
- Downloads
- 0
- Uploads
- 0
Thanks! I'll try it ASAP
-
11-24-2005, 06:11 AM #31011th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Please could someone help?
Sorry on such short notice but i have a small problem....
Well i have made my Sprite's and character's and done all the code for my game BUT, Know my character cant jump properly?
Oh and how can i make barrier's?
Like on mario when you can jump on the ledge above.
I just really need to know how to make barrier's so my player can
hit thing's and stand on them lol.
Thank's in return.FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
-
11-24-2005, 04:25 PM #311QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 152
- Points
- 5.114
- Level
- 45
- Downloads
- 0
- Uploads
- 0
I would like to know the same
Zitat von c5cha7
-
11-25-2005, 09:50 AM #312words 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
Thanks and you were right on thats what i wanted!
Zitat von XteticX
anyway, i have just figured out the resizer function and it works! its sweet!
Well, now all ineed is to know how to make a sidescroll type of thing, but its not really a sidescrolling thing, its more ofa one picture backround flying horizontly past the screen over and over again so can someone please help me with this?
...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-25-2005, 10:04 AM #313Developer

- Registriert seit
- Jun 2005
- Ort
- At my house...
- Beiträge
- 886
- Points
- 8.360
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Thats called sidescrolling
....
F.A.L.O?
-
11-25-2005, 12:08 PM #314QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 152
- Points
- 5.114
- Level
- 45
- Downloads
- 0
- Uploads
- 0
Umm, Help SG57 and I make a sidescrolling BG, because i need the same
-
11-25-2005, 07:10 PM #315words 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
somebody answered me awhile back buttt...
they just said something about a bgXy + 479 and stuff like that heres the post:
"I have a number, bgX, that is default 0
now think about this, i said that if its < 0, then blit the image at bgX and bgX+479
if its after 0, then make it bgX-480
if its less than -(480-480) then make it -480
if you push left or right, make bgX + or -"
can someone explain this alittle better or give me an example of a sidescrolling game?
also, like in the lua windows shell, how do you make it so if you go over a thing, in my case its a menu, it lights up a bit or if you push X on that certain thing/pixel, it does my own file, i know how to do the:
dofile("script.lua)
type thing, anyone can help? thanks alot if yu can!Geändert von SG57 (11-25-2005 um 07:13 PM Uhr)

...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-26-2005, 03:42 AM #31611th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Hmm.
I Would actually like to know how to make a sidescrolling background.
That would be a nice addition to my game lol.
But barrier's would still be nice :icon_biggFAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
-
11-26-2005, 03:49 AM #31711th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Hmm..
Zitat von SG57
I Could help you with that
Here \/
Or something like that.Code:screen:blit(18, 18, image) if x0 < 50 then if x0 > 15 then if y0 < 60 then if y0 > 15 then screen:blit(18, 18, highlighted) if pad:cross() then dofile("script.lua) end end end end
If it's not a mouse then change these \/
That's all i can do for know lol.Code:if x0 < 50 then if x0 > 15 then if y0 < 60 then if y0 > 15 then
FAVORITE GAME! - BEER & ANIME! - SO EXICTING!

開発者, 携帯用プログラマー 日本サポータおよび恋人 本名のアダムの鍛冶屋
Currently Working On: - Flashmod V2.50 - Flashmod V2.60
Currently Drinking: Coffee! - 私はコーヒーを飲む
Chao Garden: DEMO v0.6
Chao Garden V0.5b Review!
-
11-26-2005, 07:56 PM #318QJ Gamer Blue
- Registriert seit
- Aug 2005
- Ort
- USA
- Beiträge
- 214
- Points
- 5.594
- Level
- 48
- Downloads
- 0
- Uploads
- 0
would putting numbers in the () for "if pad:start(###) then" mean if start is held for ### time then, or how eles could this be done?
-
11-26-2005, 08:16 PM #319QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- script.lua
- Beiträge
- 426
- Points
- 6.087
- Level
- 50
- Downloads
- 0
- Uploads
- 0
I dont think pad:start() can hold any arguments. Just create a simple loop. Someting like:
Zitat von sofa king dumb
I never tested if "while pad:start() do" would work. It should. lol :icon_biggCode:while pad:start() do time=time+1 if time>=50 then time=0 "execute and action here" end end
-
11-26-2005, 10:50 PM #320words 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
THAN
THANKS, and ya its with a mouse and i just tried it and it said line 26: trying to compare nil value, so that means at the start of the if statements is where the error is so
Zitat von c5cha7
, now if iwanted to changed where the cursor would go over, say pixel (232, 131) but not that specific pixel, but its a rectangle area, so the area between pixels (232, 142), (249, 142) ,(232, 131) and (249, 131), then what would i do? and its with a cursor.
EDIT
o forgot one major question for my game...how do i rotate an image not 90* like in the function in the developers dungeon, but say like 10* if i press up and down 10*... thank you alot if you can help at allGeändert von SG57 (11-27-2005 um 12:40 AM Uhr)

...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-27-2005, 06:42 AM #321QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 152
- Points
- 5.114
- Level
- 45
- Downloads
- 0
- Uploads
- 0
I got a sidscroller from www.lumo.at.tt and fixed it up so it works better than it initially did
Zitat von c5cha7
and i believe barriers would have to have some collision detection, to know if you hit it
-
11-27-2005, 10:00 AM #322words 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
how to make the backround go faster than that would help a bunch if so,
lastly for about a month or 2 casue im at a friends house so im posting all these questions os i can view the answers on my fired up browser,
i have my menu made and stuff but i cant get the script.lua to load if i go over a certain pixel with my cursor, so heres my code (also, i made it so when i click X, it makes a mouse click, but now i have to hold the X down to move the cursor and it makes too many clicks so ill post that code with it)
here it is guyz, need some help with it too,Code:System.usbDiskModeActivate() level = Image.load("explosive/MAIN.PNG") click = Sound.load("sounds/click.wav") white = Color.new(255, 255, 255) green = Color.new(0, 255, 0) orange = Color.new(255, 128, 0) teal = Color.new(64, 128, 128) blue = Color.new(0, 0, 255) red = Color.new(255, 0, 0) a = Color.new(0, 0, 0) lightgreen = Color.new(0, 180, 0) lightyellow = Color.new(165, 157, 67) brown = Color.new(128, 64, 0) arrow = Image.load("explosive/CURSOR.PNG") arrowX=240 arrowY=136 speed = 5 CurrentArrow = arrow while true do screen:blit(0, 0, level, 0, 0, level:width(), level:height(), false) if x0 < 50 then if x0 > 15 then if y0 < 60 then if y0 > 15 then screen:blit(18, 18, highlighted) if pad:cross() then dofile(./"script.lua") end end end end screen.waitVblankStart() pad=Controls.read() if pad:analogX() < -30 then arrowX = arrowX - speed end if pad:analogX() > 30 then arrowX = arrowX + speed end if pad:analogY() < -30 then arrowY = arrowY - speed end if pad:analogY() > 30 then arrowY = arrowY + speed end screen:fillRect(0, 0, 0, 0, a) screen:blit(arrowX, arrowY, CurrentArrow) if pad:cross() then click:play() screen.waitVblankStart() screen.flip() end end
i think i can remove the click sound from the cursor and make it so if i click X anyway, it does the sound and that fixes that,
i think i might try moving all the things uner my backround picture to my cursor to see if that fixes anything
unless soemone has found a way to get this to work?Geändert von SG57 (11-29-2005 um 06:21 PM Uhr)

...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-29-2005, 01:50 PM #323QJ Gamer Bronze
- Registriert seit
- Jul 2005
- Ort
- USA
- Beiträge
- 496
- Points
- 14.090
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Hi. Im working on a lua game. If i move an object to one side of the screen, how do i make it stop? I have this code, but the object cant move after if hits the side
Code:blockposX = 152 blockposY = 20 while true do screen:blit(0, 0, field) screen:blit(blockposX, blockposY, block3) screen.waitVblankStart() screen.flip() if blockposX >= 427 then blockposX = 452 end pad = Controls.read() if pad:left() then blockposX = blockposX - 25 end if pad:right() then blockposX = blockposX + 25 end
SOLVED!Geändert von CtrlAltDeleteDie (11-29-2005 um 02:21 PM Uhr)
-
11-29-2005, 06:24 PM #324words 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
Hey howd you fix yours? is that the fixed one or what casue that looks right to me
Zitat von CtrlAltDeleteDie

...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
-
12-01-2005, 02:48 PM #325QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 152
- Points
- 5.114
- Level
- 45
- Downloads
- 0
- Uploads
- 0
not really, i would say that he moved the:
Zitat von SG57
screen.waitVblankStart()
screen.flip()
to the end, so i believe if that happened it would work!
SG57, what exactly is your prob?Geändert von monster356 (12-01-2005 um 02:51 PM Uhr)
-
12-01-2005, 07:09 PM #326words 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
my menu wont work, can sum 1 get it to work? its posted a bit up

...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
-
12-02-2005, 01:23 PM #327
I have been trying to learn Lua from the tutorial, but I keep getting this error when I try to implement the example coding for the second lesson, but I keep getting this error. I am using LuaPlayer .14 and selecting using the Lowser function, setting the code, data files, pictures, ect. into an application folder and renaming the lua script to "index.lua". I am using Mac OS X 10.4 and TextEdit to try and code. i am using a plain text document, but the application makes me encode in codex like "Western (Mac OS)" or "Unicode (UTF-16)" or "Western (Windows Latin 1)" and other such encodings.error: index.lua:1: '=' expected near 'e'
Error: No script file found.
Press start to restart
If anyone can help me or any one who uses a Mac enlighten me if I am doing things incorrectly, I would really appreciate the help.
-
12-02-2005, 06:30 PM #328words 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
post ur code... can any 1 help me with mine?

...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
-
12-02-2005, 11:31 PM #329
Unfortunately, the automatic forum respnse is giving me this error when trying to post the code:
The code can alternatively be found in this thread PSP Programming Tutorials in Lua - Lesson One, Hello World in the second tutorial (second post), under the line "NOW! We are done! Now you can really hug yourself, because your PSP Application coded in LUA, is DONE!1. You have included too many images in your signature or in your previous post. Please go back and correct the problem and then continue again.
Images include use of smilies, the vB code [img] tag and HTML <img> tags. The use of these is all subject to them being enabled by the administrator.
Here is what your code should look like:"
-
12-03-2005, 10:25 AM #330QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 152
- Points
- 5.114
- Level
- 45
- Downloads
- 0
- Uploads
- 0
When i was doing it i had a few errors, but i got it figured out, I can send my code to you
Zitat von WraithLeader


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