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; Yup, you do this: In your while true do loop put this code just below: Code: pad = Controls.read() Now, ...
-
06-01-2006, 12:26 AM #2551Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Yup, you do this:
In your while true do loop put this code just below:
Now, below that put this:Code:pad = Controls.read()
you can of course change cross and square to what ever buttons you want.Code:if pad:cross() and pad:square then action here end
-
06-01-2006, 12:31 AM #2552QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- This Forum
- Beiträge
- 1.825
- Points
- 15.884
- Level
- 81
- Downloads
- 0
- Uploads
- 0
Thank you :) but do i need a () at the end of the other pad:button
Zitat von kozine
Taking things too far one step at a time
-
06-01-2006, 12:33 AM #2553Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Yea you do sorry:
Code:if pad:cross() and pad:square() then action here end
-
06-01-2006, 12:34 AM #2554QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- This Forum
- Beiträge
- 1.825
- Points
- 15.884
- Level
- 81
- Downloads
- 0
- Uploads
- 0
Thank you :)
Zitat von kozine
Last question, can i limit the amount of time
you can use this?Taking things too far one step at a time
-
06-01-2006, 12:43 AM #2555Developer

- Registriert seit
- Mar 2006
- Ort
- Isle of Wight
- Beiträge
- 491
- Points
- 12.360
- Level
- 72
- Downloads
- 0
- Uploads
- 0
Probaly but I dont know how. Sorry!
-
06-01-2006, 12:45 AM #2556QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- This Forum
- Beiträge
- 1.825
- Points
- 15.884
- Level
- 81
- Downloads
- 0
- Uploads
- 0
Thabk you for your help, Ill leave that out for now :)
Zitat von kozine
Taking things too far one step at a time
-
06-01-2006, 04:03 AM #255711th Squad Captain
- Registriert seit
- Jun 2005
- Ort
- You are here -----> 名前: アダム | 飲むコー
- Beiträge
- 2.562
- Points
- 26.490
- Level
- 97
- Downloads
- 0
- Uploads
- 0
Try
Zitat von Ralan
That should count the control's until they are pressed 10 times.Code:controltimer=0 if pad:cross() and pad:square() and controltimer <= 10 then --\\action here\\-- controltimer=controltimer+1 end
You may also need to insert another function to stop the pad
from looping really fast ;).
Sorry i just woke up so i can't exactly give a you a 110% brilliant
padtacular code snippet :icon_razz .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!
-
06-01-2006, 04:08 AM #2558Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
I think u mean:
Add that to your if(the one c5cha7 showed),and make it suit your code(the button inputted may be different)to slow down the pad looping.Code:if pad:cross() and oldpad:cross() ~= pad:cross()
EDIT try this:
I think thats right...Code:controltimer=0 if pad:cross() and pad:square() and oldpad:cross() ~= pad:cross() and oldpad:square() ~= pad:square and controltimer <= 10 then --\\action here\\-- controltimer=controltimer +1 end
--VazaGeändert von Vaza (06-01-2006 um 04:11 AM Uhr)
-
06-01-2006, 08:53 AM #2559QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
I've been meaning to ask this a long time: Whats with the "oldpad" and "pad" people keep using? Whats the difference?Code:controltimer=0 if pad:cross() and pad:square() and oldpad:cross() ~= pad:cross() and oldpad:square() ~= pad:square and controltimer <= 10 then --\\action here\\-- controltimer=controltimer +1 end
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
06-01-2006, 09:53 AM #2560QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- The Migrant Fleet
- Beiträge
- 908
- Points
- 9.678
- Level
- 66
- Downloads
- 0
- Uploads
- 0
Zitat von EminentJonFrost
Well you put oldpad = Controls.read() at the beginning of the code. It makes it so you cant hold down the button to do the action, you have to hit it repeatedly.
-
06-01-2006, 12:10 PM #2561
quick question. Would this be the way to make the bullet stop after it hits a wall?
Code:for e = 1,5 do if (paintballInfo[e].x + bulletwidth > wall.x) and (paintballInfo[e].x < wall.x + wallwidth) and (paintballInfo[e].y + bulletheight > wall.y) and (paintballInfo[e].y < wall.y + wallheight) then paintballInfo[e].firing = false end
-
06-01-2006, 02:10 PM #2562QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
does anyone know how to edit strings?
the value of somthing in my array is
"2DU"
when i hit left(i can do that) i want it to get rid of(subtract) the U and when i hit right i want it to put(add) the U back into the string.
-
06-01-2006, 03:11 PM #2563QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
http://lua-users.org/wiki/StringLibraryTutorial
Zitat von soadnation
:)
That should help.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
06-01-2006, 03:13 PM #2564QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
looks like it.
Zitat von Mr.Game
i gotta see the values for all those variables to be sure though.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
06-01-2006, 08:55 PM #2565Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
hi, im posting from india. (that was random)
quik question:
i cant download windows lua here for a personal reason, so here is my question:
is it possible to put timers in an array?? ex:
can someone test it out pls? thx.Code:dude = {} for dudet = 1, 50 do dude[dudet] = Timer.new() end--------------------------------------------------------------------------------------
-
06-01-2006, 09:21 PM #2566words 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
yes, you can put anything into an array, as long as you define it before hand. In LUA you have nothing to worry about really, C theres syntax that you must get right before you do anything.
oh and a quick reality check thing, a flashing on and off screen means too many flippings of the draw to display buffer, correct?
...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
-
06-01-2006, 09:23 PM #2567words 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
I cant tell exactly but Im sure that you have a variable for the speed of the paintball? Just make an array of speeds for each individual paintball, that way you can make a simpel if statemnet saying if speed[x] hits wall/collision, then that speed = 0, then time it for like 2 seconds to make it disappear, x++.
Zitat von Mr.Game
hope you understand it somewhat?
...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
-
06-02-2006, 02:11 AM #2568QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
Correct SG57, if the screen flashes too much, it means you have extra "screen.flip()"s around your script somewhere.
Zitat von SG57
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
06-02-2006, 03:33 AM #2569QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
has anyone had experience in string manipulation?
-
06-02-2006, 05:35 AM #2570QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- Sweden
- Beiträge
- 460
- Points
- 6.520
- Level
- 52
- Downloads
- 0
- Uploads
- 0
Manipulation how?
Zitat von soadnation
[CENTER]Some of my homebrew Applications/Games:
[URL=http://forums.qj.net/showthread.php?t=47294&page=1&pp=10]Planet Fighter[/URL] | [URL=http://forums.qj.net/showthread.php?p=641672#post641672]Graphic Creator (V2.0)[/URL] | [URL=http://forums.qj.net/showthread.php?p=512717]Fire Pong[/URL] | [B][URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html#post1430891"][COLOR="Red"][SIZE="3"]Brushes v2.0[/COLOR][/SIZE][/B][/URL] [URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][B][SIZE="2"][COLOR="Black"]Released![/COLOR][/SIZE][/B][/URL]
[URL="http://haxxblaster.2u.se/"][COLOR="black"][FONT="Arial Black"]www.HaxxBlaster.com[/FONT][/COLOR][/URL]
[URL="http://forums.qj.net/f-psp-development-forum-11/t-release-brushes-v20-99207.html"][IMG]http://img19.imageshack.us/img19/1346/brushesbannerqz3.png[/IMG][/URL][/CENTER]
-
06-02-2006, 03:05 PM #2571QJ Gamer Blue
- Registriert seit
- Jun 2005
- Beiträge
- 375
- Points
- 5.631
- Level
- 48
- Downloads
- 0
- Uploads
- 0
this is what i have
"2DU"
what i want to do is have it replace the 3rd charecter in it. but instead of supplying the text i want tell it to look at a certain part of the array
-
06-02-2006, 04:12 PM #2572QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- New Zealand
- Beiträge
- 397
- Points
- 8.216
- Level
- 61
- Downloads
- 0
- Uploads
- 0
I'm making my first game in Lua, a Tag clone called TagX, which is basicly two player tag (on one psp) with fun maps, powerups stuff like that. Trust me, its fun. But it won't be fun unless I complete it, so please help me!
I need to find out a way to get collision detection (tagging) working. There are 4 sprites for each player, one for each direction.
Eg.
Player1n
Player1e
Player1s
Player1w
Player2n
Player2e
Player2s
Player2w
What I want to do, is make it so that when a player goes over another player, they swap sprites so that the player1 is now player2 and the player2 is player1 for every angle. If I didnt make it so they change directions it would be easy, but it has to swap for EVERY sprite in every direction.
Can anyone help me? :mrgreen:92% of the teenage population listens to rap music. If you're part of the 8% that listens to real music, copy and paste this into your sig.
-
06-02-2006, 04:34 PM #2573QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
how about this:
Do you understand that?Code:Player = { Player1 = { n = Image.load("image"), e = Image.load("image"), s = Image.load("image"), w = Image.load("image") }, Player2 = { n2 = Image.load("image"), e2 = Image.load("image"), s2 = Image.load("image"), w2 = Image.load("image") } } x = 1 if [player1 and 2 meet] then if x == 1 then x = 2 elseif x == 2 then x = 1 end end screen:blit(player_x, player_y, Player[x].n) -- when the 'x' changes, the sprites used will change.[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
06-02-2006, 05:00 PM #2574QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- New Zealand
- Beiträge
- 397
- Points
- 8.216
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Sort of...
How would I do 'the IF Player1 and player2 meet' thing?Geändert von fraseyboy (06-02-2006 um 05:06 PM Uhr)
92% of the teenage population listens to rap music. If you're part of the 8% that listens to real music, copy and paste this into your sig.
-
06-02-2006, 05:06 PM #2575QJ Gamer Green
- Registriert seit
- Dec 2005
- Ort
- Here
- Beiträge
- 2.715
- Points
- 13.310
- Level
- 75
- Downloads
- 0
- Uploads
- 0
dont get it? you may need to learn a bit more then.
Zitat von fraseyboy
as for the two players meeting:
in words, that 'if' statement is:Code:if player1_x == player2_x and player1_y == player2_y then
If player1 is on the same 'x' point and the same 'y' point as player2 then...
[the code i showed before][CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
-
06-02-2006, 05:08 PM #2576QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- New Zealand
- Beiträge
- 397
- Points
- 8.216
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Ohhh i think i get it now... I'll try it and see.
Zitat von EminentJonFrost
92% of the teenage population listens to rap music. If you're part of the 8% that listens to real music, copy and paste this into your sig.
-
06-02-2006, 05:20 PM #2577QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- New Zealand
- Beiträge
- 397
- Points
- 8.216
- Level
- 61
- Downloads
- 0
- Uploads
- 0
Hmm. It says 'attempt to index global ?, a nil value'.
Its on line 157 and that appears to be the...
screen:blit(player_x, player_y, Player[x].n) bit....
Where does Player_x and Player_y come from?
Heres my code BTW: http://pastebin.com/754753Geändert von fraseyboy (06-02-2006 um 05:38 PM Uhr)
92% of the teenage population listens to rap music. If you're part of the 8% that listens to real music, copy and paste this into your sig.
-
06-02-2006, 06:13 PM #2578words 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
I found this in your code, looks to me like the co-ordinates for the player, and there not in use because?Code:- <LI class=li2>-- Player Coordinates
- <LI class=li1>x1 = 45 <LI class=li2>y1 = 34 <LI class=li1>x2 = 415 <LI class=li2>y2 = 240

...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
-
06-02-2006, 06:42 PM #2579QJ Gamer Silver
- Registriert seit
- Jun 2005
- Ort
- New Zealand
- Beiträge
- 397
- Points
- 8.216
- Level
- 61
- Downloads
- 0
- Uploads
- 0
where'd you get them from? I can't see them anywhere in my code...
Zitat von SG57
92% of the teenage population listens to rap music. If you're part of the 8% that listens to real music, copy and paste this into your sig.
-
06-02-2006, 10:29 PM #2580words 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
Well i got it from that luabin crud, i coopied and pasted, but look past the HTML junk to see it, imtoo lazy to do it myself ;-)

...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


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