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; ok. this is to ALL CODERS. i have seen a lot of code such as: Code: screen:print(100, 130, "blah", red) ...
-
05-15-2006, 05:44 PM #2311Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
ok. this is to ALL CODERS. i have seen a lot of code such as:
if you put this code:Code:screen:print(100, 130, "blah", red) screen:flip()
at the VERRRYYYY END of your codem you dont have to worry about screen:flip() for your ENTIRE CODE. it becomes much easier that way.Code:screen.waitVblankStart() screen.flip() end
Geändert von Grimfate126 (05-15-2006 um 05:46 PM Uhr)
--------------------------------------------------------------------------------------
-
05-15-2006, 05:46 PM #2312Quality Haxing Since 1991
- Registriert seit
- Oct 2005
- Ort
- Pennsylvania, USA Fi
- Beiträge
- 6.206
- Points
- 29.255
- Level
- 99
- Downloads
- 0
- Uploads
- 0
Umm...I'm having a slight problem. Is there any way to "pause" a loop? I ask this because I have an options menu that comes up whenever you press start, the only problem is that when it comes up, the player will keep moving while the menu is up. The menu actually has its own loop because of some stuff I added in there, but this still happens no matter what I do. Does anyone have any suggestions? Thanks guys.
Zitat von Noriko
-
05-15-2006, 05:47 PM #2313QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
Ive never done it but you could try this
while not pad:start() do
-- main loop --
end
if pad:start() then
--menu --
end
-
05-15-2006, 05:50 PM #2314Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von PSPHax0r9
you could have a boolean:
then:Code:pause = false
after:Code:if pause == false then --the code for you character moving..etc end
and finally:Code:if pad:start() and pause == false then pause = true end
try it out.Code:if pause == true then --your menu code end if pad:start() and pause == true then pause = false end
--------------------------------------------------------------------------------------
-
05-15-2006, 05:51 PM #2315Quality Haxing Since 1991
- Registriert seit
- Oct 2005
- Ort
- Pennsylvania, USA Fi
- Beiträge
- 6.206
- Points
- 29.255
- Level
- 99
- Downloads
- 0
- Uploads
- 0
Yea, that's what I was planning on doing but I just wanted to know if there was a simple command I was missing so I wouldn't have to cater my whole game around the options menu.
Zitat von Noriko
-
05-15-2006, 06:27 PM #2316
Look
This is a better example.Code:if true then screen:blit(x1, y1, player2) x1 = x1 + 2 end if true and pause == true then screen:blit(x0, y0, up2) screen.flip() screen.waitVblankStart(10) screen:blit(x0, y0, up1) screen.flip() screen.waitVblankStart(10) y0 = y0 - 2 end if pad:up() then pause = true end
picture "player2" will atomatically move right.
If i press Up, It will not move smooth and will start to skip some pixels
The good thing i liked about the "screen.waitVblankStart(1 0)" is that it makes picture "up1" and "up2" to keep changing atomatically.
The bad thing is that "screen.waitVblankStart(1 0)" Makes picture "player2" movement and the picture "up1" and "up2" movement not smooth and skipping some pixels.
My question is:
Is there a way to fix the bad thing
?
Geändert von natan333 (05-15-2006 um 06:31 PM Uhr)
Bequiet!!!
I'm learning cc©cc
-
05-15-2006, 07:07 PM #2317QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
Hey, a notepad question.. If you go to Edit.. theres an option called GoTo.. This option allows you to go to a certain line in the text, but when i try to click on it nothing happens.. any help?
-
05-15-2006, 07:11 PM #2318TheMarioKartersGuest
I have the same problem.
Zitat von montrob
-
05-15-2006, 07:24 PM #2319QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
Figured it out! Just go to View and uncheck Word Wrap. Then it works.
Zitat von TheMarioKarters
-
05-15-2006, 07:25 PM #2320TheMarioKartersGuest
Ah, thanks mate.
Zitat von montrob
-
05-15-2006, 08:13 PM #2321words 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
Collision..
Zitat von qwerty
Im planning on making a lib for questions asked alot that will be available to all... it will be a simple function... converted from my C to LUA (ravine). then maybe add rotation adn such... I dunno still... maybe someone else is maing somethin alike to it? that i could just addthe collision to 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-16-2006, 02:32 AM #2322
well I know that in LUA-player 0.19 there is a function that lets you rotate images.
A collision lib would be very nice.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-16-2006, 02:35 AM #2323
If you use a function for your menu, and there's a loop in it then everything will pause except for timers. This is how i do it and it works perfectly.
Zitat von PSPHax0r9
This is also logical, since when the program is in the menu loop it cant run in the game loop.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-16-2006, 04:17 AM #2324QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
Use a new function, like Altair said.
Zitat von PSPHax0r9
It'll pause whatever you have running, then when it breaks, it'll go back to whatever to you were doing before pausing.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-16-2006, 07:34 AM #2325QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
OK i need to make my game so that you have to press the button more than once to blow up all the bombs EX - There are 2 circle bombs, right now if you hit circle both blow up, but I need it so that you have to hit circle twice for each one to blow up!
-
05-16-2006, 07:59 AM #2326
Depends on how you have your bombs made. Im assuming you use a table.
Just say that if you you press circle ones, make the bomb[n] blow up. And each time you press circle add 1 to n.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-16-2006, 08:28 AM #2327QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
Ya it works.. Almost ready for a public beta of my game!
Zitat von Altair
-
05-16-2006, 01:02 PM #2328QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
question!!!(sorry just thought i make myself clear) is their anyway to attach an image to another image without going into a the image and manually because this would make scrolling for my game easyier
--thanks in advance1. 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
-
05-16-2006, 01:05 PM #2329Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
?
U mean like create a image canvas that is double the length of your map and blit both oin there, cos i think thats possible.
?
-
05-16-2006, 01:49 PM #2330QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
no i mean so i can scroll my map and the other images are attached to my map so they scroll with it else i well have to set them all to scroll individually but if i can attach them to my main map then it all works out=-)
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
-
05-16-2006, 03:17 PM #2331words 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
Ohh... i understand... theres multiple ways...

...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-16-2006, 03:52 PM #2332QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
I'm just making a for-fun script that has a visual effect, well, what I'm trying to achieve is a visual effect.
an error that keeps popping up: lua: 36 : argument was incorrect
heres my short script:
whats wrong?Code:black = Color.new(0, 0, 0) white = Color.new(255, 255, 255) red = Color.new(255, 0, 0) green = Color.new(0, 255, 0) blue = Color.new(0, 0, 255) width = 480 height = 272 while true do pad = Controls.read() if pad:cross() then break end screen:clear(black) h = math.random(1, 100) x = width/h y = height/h z = math.random(1, 4) if z == 1 then screen:pixel(x, y, white) end if z == 2 then screen:pixel(x, y, red) end if z == 3 then screen:pixel(x, y, green) -- this is line 36 end if z == 4 then screen:pixel(x, y, blue) end screen.flip() screen.waitVblankStart() end
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-16-2006, 04:12 PM #2333Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
try this:
Zitat von EminentJonFrost
you should use elseif statemnts, they lower the chance of an error bigtime.Code:math.randomseed(os.time()) black = Color.new(0, 0, 0) white = Color.new(255, 255, 255) red = Color.new(255, 0, 0) green = Color.new(0, 255, 0) blue = Color.new(0, 0, 255) width = 480 height = 272 h = math.random(1, 100) z = math.random(1, 4) x = width/h y = height/h while true do pad = Controls.read() if pad:cross() then break end screen:clear() if z == 1 then screen:pixel(x, y, white) elseif z == 2 then screen:pixel(x, y, red) elseif z == 3 then screen:pixel(x, y, green) elseif z == 4 then screen:pixel(x, y, blue) end screen.flip() screen.waitVblankStart() end
--------------------------------------------------------------------------------------
-
05-16-2006, 04:15 PM #2334
how can i do
if player.y == 138(pixel on my screen) then gravity = 138 so tha when i jump i don't past trugh the floor. cause the floor im jumping on is higherFree Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
05-16-2006, 04:21 PM #2335QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
you need to post a little more coding up.
Zitat von ZereoX
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-16-2006, 04:38 PM #2336
Here is the part of my code
i want to do when the legs of the player that mean the player.y touches the floor where its higher then the normal floor the gravity changes so that he stay on and not pass true it up to the same high as the prvious floor.Code:player = {} player.gravity = 160 player.y = 230 player.x = 50 player.jumpspeed = 10 player.jumpstate = "ground" while true do pad = Controls.read() screen:clear() screen:blit(0,0,Background1) if pad:r() and oldpad:r() ~= pad:r() then bulletSetup() 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 < 160 and player.jumpstate == "falling" then player.gravity = player.gravity + (player.jumpspeed + 3) end if player.gravity == 160 then player.jumpspeed = 10 player.jumpstate = "ground" end if player.gravity > 160 then player.gravity = 160 end player.y = player.gravity screen:blit(player.x,player.y,player1) screen:blit(0,0,ground)Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
05-16-2006, 05:04 PM #2337QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
try it now.Code:player = {} player.gravity = 160 player.y = 230 player.x = 50 player.jumpspeed = 10 player.jumpstate = "ground" while true do pad = Controls.read() screen:clear() screen:blit(0,0,Background1) if pad:r() and oldpad:r() ~= pad:r() then bulletSetup() 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 < 160 and player.jumpstate == "falling" then player.gravity = player.gravity + (player.jumpspeed + 3) end if player.gravity == 160 then player.jumpspeed = 10 player.jumpstate = "ground" end if player.gravity > 160 then player.gravity = 160 end player.y = player.gravity screen:blit(player.x,player.y,player1) screen:blit(0,0,ground) second_floor = {} second_floor.y = 220 -- made it lower, just in case the player cant reach. second_floor.x1 = 100 second_floor.x2 = 200 if player.y <= second_floor.y and player.x >= second_floor.x1 and player.x <= second_floor.x2 then player.y = second_floor.y -- I forgot the ".y" last time. end
i made two changes from the last time, one correcting a stupid mistake on my part.Geändert von EminentJonFrost (05-17-2006 um 07:13 AM Uhr)
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
05-16-2006, 05:21 PM #2338
does't work it don't even change somthing.
Want me to send everything or you still have.Free Prizes at Prizerebel Join us!
I already got 11 Gifts. Ask me for details or proof.
-
05-16-2006, 05:33 PM #2339QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
Well instead of changing player.gravity you could say
Zitat von ZereoX
Code:if player.y >= 138 then player.y = 138
-
05-16-2006, 05:49 PM #2340
noone yet helped me yet, (i think noone knows how to fix it).Code:if true then screen:blit(x1, y1, player2) x1 = x1 + 2 end if true and pause == true then screen:blit(x0, y0, up2) screen.flip() screen.waitVblankStart(10 ) screen:blit(x0, y0, up1) screen.flip() screen.waitVblankStart(10 ) y0 = y0 - 2 end if pad:up() then pause = true end
anyways, is there a way to make the up1 and up2 change after each move?Bequiet!!!
I'm learning cc©cc


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