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; When you want the music to stop, put Music.Stop() . If you want it to stop in a different script, ...
-
04-07-2006, 03:18 AM #1381Think, Do, Gloat.
- Registriert seit
- Nov 2005
- Ort
- England, Norwich
- Beiträge
- 1.422
- Points
- 12.687
- Level
- 73
- Downloads
- 0
- Uploads
- 0
When you want the music to stop, put Music.Stop() . If you want it to stop in a different script, put it at the top outside the loop.
or at the top of your script you can change the:
music = Music.PlayFile("music.it" )
to:
music = Music.PlayFile("music.it" , false)
Geändert von TPTaylor (04-07-2006 um 03:25 AM Uhr)
-
04-07-2006, 03:27 AM #1382QJ Gamer Platinum
Awards:
- Registriert seit
- Jan 2006
- Ort
- stevens bumhole
- Beiträge
- 10.308
- Points
- 87.718
- Level
- 100
- Downloads
- 0
- Uploads
- 0
ok, but now when i try to start the game it gives me this message:
error: SCRIPT.LUA:47: error loading sound
Error: No script found.
-
04-07-2006, 03:52 AM #1383Think, Do, Gloat.
- Registriert seit
- Nov 2005
- Ort
- England, Norwich
- Beiträge
- 1.422
- Points
- 12.687
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Could you perhaps attatch the script file?
-
04-07-2006, 03:58 AM #1384QJ Gamer Platinum
Awards:
- Registriert seit
- Jan 2006
- Ort
- stevens bumhole
- Beiträge
- 10.308
- Points
- 87.718
- Level
- 100
- Downloads
- 0
- Uploads
- 0
yeas! it works now!! great!
now i only need to make some images!
im very soon finnished with my own lua game!!!!
-
04-07-2006, 04:23 AM #1385QJ Gamer Platinum
Awards:
- Registriert seit
- Jan 2006
- Ort
- stevens bumhole
- Beiträge
- 10.308
- Points
- 87.718
- Level
- 100
- Downloads
- 0
- Uploads
- 0
how do i make this image trasparent?

im mean so the black around it disepear when i play the game.
-
04-07-2006, 05:06 AM #1386Think, Do, Gloat.
- Registriert seit
- Nov 2005
- Ort
- England, Norwich
- Beiträge
- 1.422
- Points
- 12.687
- Level
- 73
- Downloads
- 0
- Uploads
- 0
Can't you photoshop the black bit out?
If you don't have photoshop i believe GIMP is a good program.
-
04-07-2006, 05:32 AM #1387Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
how can you make all those fakes and not know how to make a image transparent!!!
Zitat von madsoul
-
04-07-2006, 12:33 PM #1388QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
ok im a n00b at lua and when i play this it stops straight waway i know it is something to do with the loop but could someone tell me what it is because i have no clue
-- Green Color Object
green = Color.new(0, 255, 0)
-- Store birth year in varible myBirthYear
myBirthYear = 1986
-- Store current year in currentYear
currentYear = 2006
-- create an empty varible
myAge = nil
-- Store some text in a varible
someText = "My age is roughly "
-- Subtract myBirthYear from cureentYear and store inmyAge
myAge = currentYear - my BirthYear
-- Print my text varible to the screen
screen:print(10, 100, someText .. myAge,green)
-- Buffer offscreen to onscreen
screen.flip()
--Loop forever
while true do
screen.waitVblankStart()
end
the p is in bold becuase if it was not it would look like this
-
04-07-2006, 12:57 PM #1389Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
How would I make something (a spike specifically) fall down the screen?

--XBL Gamertag: PhenoM904--
-
04-07-2006, 01:04 PM #1390Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Try this:
Code:pic= image.load('whatever') picx=400 picy=0 while true do screen.blit(picx,picy,pic ,0,0,pic:width(),pic:heig ht()) if picy+pic:height()<260 then (if the ground starts at 260 that is) picy=picy-10 end if picy+pic:height()>260 then picy=260-pic:height() end if picy +pic:height()==260 picx=picx-5 end end
-
04-07-2006, 01:36 PM #1391Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Hm, okay after changing filenams around and bliting a white background it loads but no spike...

--XBL Gamertag: PhenoM904--
-
04-07-2006, 01:37 PM #1392Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
hmm. Post your code plz.
-
04-07-2006, 01:47 PM #139311th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
try this:
Zitat von mark.sparky
-- Green Color Object
green = Color.new(0, 255, 0)
-- Store birth year in varible myBirthYear
myBirthYear = 1986
-- Store current year in currentYear
currentYear = 2006
-- create an empty varible
myAge = nil
-- Store some text in a varible
someText = "My age is roughly "
-- Subtract myBirthYear from cureentYear and store inmyAge
myAge = currentYear - my BirthYear
-- Print my text varible to the screen
-- Buffer offscreen to onscreen
screen.flip()
--Loop forever
while true do
screen:print(10, 100, someText .. myAge,green)
screen.waitVblankStart()
screen:flip()
endFAVORITE 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!
-
04-07-2006, 01:48 PM #1394Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
K. All I changed was the "pic" text and added a white background. (if ur talking about the code to the game I dont have it because im totally rewriting the code)
Code:spike = Image.load("spike.png") background = Image.load("background.png") spikex = 400 spikey = 0 while true do screen:blit(0,0, background, false) screen:blit(spikex, spikey, spike, 0, 0, spike:width(), spike:height()) if spikey + spike:height() < 260 then spikey = spikey-10 end if spikey + spike:height() > 260 then spikey = 260 - spike:height() end if spikey + spike:height() == 260 then spikex = spikex-5 end screen.flip() screen.waitVblankStart() end
--XBL Gamertag: PhenoM904--
-
04-07-2006, 01:54 PM #139511th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Whats the problem/error you get?
Zitat von MaSt3r_ShAk3
and maybe i can help yas :icon_bigg .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!
-
04-07-2006, 02:08 PM #1396
- Registriert seit
- Apr 2006
- Ort
- Newcastle, england
- Beiträge
- 31
- Points
- 4.163
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Okay, im attempting to make my first ever lua game. Ive been doing lua for roughly three days and ive grasped most of it. I wanted to do a shooter and gutya(great guy) has been aiding me. Fair enough, its an in depth first project, but i wanted to try.
So i used evil manas snippets and attempted to merge them together, to get a moving shooting character.
But at the moment ive fixed a few errors but then This comes up
" Error: index.lua:29: attempt to index field '?' <a nil value>
Id appreciate someone helping me out with this code, as i dont understand parts of it myself. After this error im sure there will be more.
Code:--Activiate usb System.usbDiskModeActivate() --generating colours red = Color.new(255,0,0) black = Color.new(0,0,0) green=Color.new(0,255,0) white = Color.new(255,255,255) --Create shapes player1 = Image.createEmpty(32,32) player1:clear(red) ground = Image.createEmpty(480,10) ground:clear(green) bullet = Image.createEmpty(4,4) bullet:clear(green) --variables oldpad = Controls.read() currentBullet = 0 direction = "right" --Arrays player = {} player.gravity = 230 player.y = 230 player.x = 50 player.jumpspeed = 10 player.jumpstate = "ground" --bullet array BulletInfo = {} for a = 1,5 do BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = player[1].x + 32, y = player[1].y + 16 } end --Functions function bulletSetup() --Increase the current bullet by one, or reset it to 1 if currentBullet < 5 then currentBullet = currentBullet + 1 else currentBullet = 1 end if direction == "left" then BulletInfo[currentBullet].x = Player[1].x BulletInfo[currentBullet].y = Player[1].y + 16 end if direction == "right" then BulletInfo[currentBullet].x = Player[1].x + 32 BulletInfo[currentBullet].y = Player[1].y + 16 end if direction == "up" then BulletInfo[currentBullet].x = Player[1].x + 16 BulletInfo[currentBullet].y = Player[1].y end if direction == "down" then BulletInfo[currentBullet].x = Player[1].x + 16 BulletInfo[currentBullet].y = Player[1].y + 32 end BulletInfo[currentBullet].direction = direction BulletInfo[currentBullet].firing = true end function bulletFire() for i = 1,5 do if BulletInfo[i].firing == true then if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end if BulletInfo[i].direction == "up" then BulletInfo[i].y = BulletInfo[i].y - 10 end if BulletInfo[i].direction == "down" then BulletInfo[i].y = BulletInfo[i].y + 10 end screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic) end if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then BulletInfo[i].firing = false end end end --Print bullet info to screen. screen:print(10,10,"Bullet 1: ".. tostring(BulletInfo[1].firing),green) screen:print(10,20,"Bullet 2: "..tostring(BulletInfo[2].firing),green) screen:print(10,30,"Bullet 3: "..tostring(BulletInfo[3].firing),green) screen:print(10,40,"Bullet 4: "..tostring(BulletInfo[4].firing),green) screen:print(10,50,"Bullet 5: "..tostring(BulletInfo[5].firing),green) screen:print(10,60,"Direction: "..direction,green) --mainloop while true do pad = Controls.read() screen:clear() if pad:start() then break end if pad:left() then player.x = player.x - 2 end if pad:right() then player.x = player.x + 2 end if pad:cross() and player.jumpstate == "ground" then player.jumpstate = "jumping" end if player.jumpstate == "jumping" then player.jumpspeed = player.jumpspeed - 0.5 player.gravity = player.gravity - player.jumpspeed end if player.gravity < 0 then player.jumpstate = "falling" end if player.gravity < 230 and player.jumpstate == "falling" then player.gravity = player.gravity + (player.jumpspeed + 3) end if player.gravity == 230 then player.jumpspeed = 10 player.jumpstate = "ground" end if player.gravity > 230 then player.gravity = 230 end player.y = player.gravity screen:blit(player.x,player.y,player1) screen:blit(0,262,ground) screen:print(10,10,"X: "..player.x.." Y: "..player.y,green) screen:print(10,20,"Jumpstate: "..player.jumpstate,green) screen.waitVblankStart() screen.flip() end if pad:cross() and oldpad:cross() ~= pad:cross() then bulletSetup() end bulletFire() screen.waitVblankStart() screen.flip() oldpad = pad
-
04-07-2006, 02:28 PM #1397Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Thats just some test code to make an image fall down th screen. when i test. only the background is blited
Zitat von c5cha7

--XBL Gamertag: PhenoM904--
-
04-07-2006, 03:31 PM #1398QJ Gamer Blue
- Registriert seit
- Jan 2006
- Ort
- Adirondacks
- Beiträge
- 83
- Points
- 4.611
- Level
- 43
- Downloads
- 0
- Uploads
- 0
Hey, i hate to sound like a total n00b but how would i get lua player running on the gta eloader, for some reason it wont work (v0.14) - thx. :Argh: :o
-
04-07-2006, 03:38 PM #1399Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
anyone?
Zitat von Greenskull
-
04-07-2006, 04:51 PM #1400Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
I cant figure out how to loop an animation. help please!
-
04-07-2006, 05:45 PM #1401QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- Puerto Rico
- Beiträge
- 310
- Points
- 7.109
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Is there a gravity code for lua example:
a ball that goes up at 10 velocity and starts to slow down ,when it reaches zero it starts to go down and speeds up.
-
04-07-2006, 06:06 PM #1402
Zitat von shadow-evillink
you should just develop a code yourself so you can customize it the way you want...
http://www.google.com/search?hl=en&l...th%27s+gravity
http://www.evilmana.com/tutorials/lu...et_jumping.php
but that should get you started! ;D
-
04-07-2006, 06:19 PM #1403Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Gah, I still need help making objects fall down the screen

--XBL Gamertag: PhenoM904--
-
04-07-2006, 06:56 PM #1404
Download the attached file!
Zitat von MaSt3r_ShAk3
I used a 10x10 image which will fall from a random x location from the top of the screen to the bottom. Press X to pause the spike MID-AIR ;P
HTH
-
04-07-2006, 07:06 PM #1405Simon Champion!
- Registriert seit
- Mar 2006
- Ort
- Calgary, Alberta, Ca
- Beiträge
- 537
- Points
- 11.489
- Level
- 70
- Downloads
- 0
- Uploads
- 0
can someone give me an example animation? How do i make it so when you press X, it starts, looping forever, and when you press X it stops. Then when you press X again it starts again and so on.
Geändert von Greenskull (04-07-2006 um 07:25 PM Uhr)
-
04-07-2006, 07:30 PM #1406Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
THANK YOU! *bows*
Zitat von califrag

--XBL Gamertag: PhenoM904--
-
04-07-2006, 09:54 PM #1407
Humm, how can i make an scrolling screen? (like when you go forward it scrolls with you and if theres objects like then they move/appear too :P)
(making smw game :P )
And also, how can i create a menu with mouse arrow replaced with an hand icon thingy, and also, if i click x while the arrow/hand is over the button, it does some function and menu dissapears(and goes to game of course :P )?Geändert von Rixorster (04-07-2006 um 09:57 PM Uhr)
-
04-07-2006, 11:49 PM #1408
click "search this thread"
Zitat von Greenskull
-
04-08-2006, 05:34 AM #1409Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
How would I have a function loop forever?

--XBL Gamertag: PhenoM904--
-
04-08-2006, 06:54 AM #1410Is in your zone.

- Registriert seit
- Oct 2005
- Ort
- Jacksonville, FL
- Beiträge
- 3.429
- Points
- 24.342
- Level
- 94
- Downloads
- 0
- Uploads
- 0
Okay this is pissing me off... I test the script in luaplayerwindows and nothing happens. It starts but its just a black screen...

--XBL Gamertag: PhenoM904--


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