Zeige Ergebnis 3.121 bis 3.150 von 10238
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; Thanks slicer4ever. You gave me the basic idea....
-
08-04-2006, 07:31 PM #3121I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Thanks slicer4ever. You gave me the basic idea.
Geändert von Access_Denied (08-04-2006 um 07:33 PM Uhr)

-
08-04-2006, 07:33 PM #3122QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
access look back a page i just tried to help you
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
-
08-04-2006, 07:41 PM #3123I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Yeah, I just seen that. Thanks.

-
08-04-2006, 07:43 PM #3124QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- This Forum
- Beiträge
- 1.825
- Points
- 15.884
- Level
- 81
- Downloads
- 0
- Uploads
- 0
I have images bilting then biltig again, Can i put in a 1 second wait between these?
Taking things too far one step at a time
-
08-04-2006, 07:44 PM #3125QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
i'm testing the code i wrote i just can't remeber the image.createnew command i know it's sometin like that
edit: @ralan try it and see what happens or post your code is it working like you want or not?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
-
08-04-2006, 07:47 PM #3126QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Zitat von slicer4ever
That what you're looking for?Code:player = Image.createEmpty(height,width) player:clear(color)
-
08-04-2006, 07:50 PM #3127Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
@ Grimfate126
If you haven't figured it out yet, have a look at the entry for "table.maxn" in the Lua 5.1 Reference Manual. This seems like it would work if you have a simple one dimensional table like the example you made. If there are two dimensions, though, things may get a little hairy.
If that doesn't work for you, you'd have to write your own function to find it, which might not be easy at all, because Lua will probably quit on you if you try to reference a nonexistent entry in a table. I think there's a way to get around that but I couldn't tell you what it is (assert, maybe?).
@ Access_Denied
You could always do it the simple way and put a screen.waitVblankStart(#) right after the program finds a button press. Something like this:
You'll have to tinker with the input argument to find a value you like.Code:if pad:down() then screen.waitVblankStart(7) end
(I also had something like what slicer posted but he beat me to it)
Hope this helps.
-
08-04-2006, 07:51 PM #3128QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
thanks pspduh
ok access this works for moving a character just hold down the left button=-)
i tested it and i know it works=-)Code:blue = Color.new(0,0,255) black = Color.new(0,0,0) player = Image.createEmpty(5,5) -- i know it's sometin like that player:clear(blue) button = "no" time_held = 0 x = 240 y = 0 oldpad = pad while true do screen:fillRect(0,0,480,272,black) pad = Controls.read() if time_held < 60 then if pad:left() then time_held = time_held + 1 else time_held = 0 end if pad:left() and oldpad:left() ~= pad:left() then x = x - 1 end end if time_held > 59 then if pad:left() then x = x - 1 else time_held = 0 end end screen:blit(x,y,player) screen.flip() screen.waitVblankStart() oldpad = pad end
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
-
08-04-2006, 07:55 PM #3129QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Your welcome. :)
Zitat von slicer4ever
I haven't posted in this thread in a while...
-
08-04-2006, 08:00 PM #3130Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von Access_Denied
simple way:
oldpad = Controls.read()
Code:if pad:down() and oldpad:down() = pad:down() then statusbar = statusbar + 10 end if pad:down() and oldpad:down() ~= pad:down() then statusbar = statusbar + 1 end
--------------------------------------------------------------------------------------
-
08-04-2006, 08:13 PM #3131QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
edit:nvm i figure out a diffrent way
-= Double Post =-
ok here you go access all 4 directions:
tested to workCode:blue = Color.new(0,0,255) black = Color.new(0,0,0) player = Image.createEmpty(15,15) -- i know it's sometin like that player:clear(blue) button = "no" time_held = 0 x = 240 y = 0 oldpad = pad while true do screen:fillRect(0,0,480,272,black) pad = Controls.read() if pad:left() then if time_held < 60 then time_held = time_held + 1 if pad:left() and oldpad:left() ~= pad:left() then x = x - 1 end end if time_held > 59 then x = x - 1 end end if pad:right() then if time_held < 60 then time_held = time_held + 1 if pad:right() and oldpad:right() ~= pad:right() then x = x + 1 end end if time_held > 59 then x = x + 1 end end if pad:up() then if time_held < 60 then time_held = time_held + 1 if pad:up() and oldpad:up() ~= pad:up() then y = y - 1 end end if time_held > 59 then y = y - 1 end end if pad:down() then if time_held < 60 then time_held = time_held + 1 if pad:down() and oldpad:down() ~= pad:down() then y = y + 1 end end if time_held > 59 then y = y + 1 end end if pad:left() and oldpad:left() ~= pad:left() then time_held = 0 end if pad:right() and oldpad:right() ~= pad:right() then time_held = 0 end if pad:up() and oldpad:up() ~= pad:up() then time_held = 0 end if pad:down() and oldpad:down() ~= pad:down() then time_held = 0 end screen:blit(x,y,player) screen.flip() screen.waitVblankStart() oldpad = pad end
Geändert von slicer4ever (08-04-2006 um 08:13 PM Uhr) Grund: Automerged Doublepost
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
-
08-04-2006, 08:27 PM #3132Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von slicer4ever
thats wayy too long/complicated. my way works better (it not exactly accurate, but right like 99 percent of the time.)--------------------------------------------------------------------------------------
-
08-04-2006, 08:30 PM #3133QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
the hard/complicated way may be long but usually it ensures less bugs=-)
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
-
08-04-2006, 08:33 PM #3134QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- This Forum
- Beiträge
- 1.825
- Points
- 15.884
- Level
- 81
- Downloads
- 0
- Uploads
- 0
Its way to fast... brb while i find my script
Zitat von slicer4ever
Taking things too far one step at a time
-
08-04-2006, 08:40 PM #3135QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
ok well when you do be sure to include what you want it to do
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
-
08-06-2006, 12:14 PM #3136Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
ok guys new problem.

here is my code: ( i have loaded all the images already)
Code:test = {} frames = 1 test[frames+1] = Timer.new() test[frames+2] = 1 test[frames+3] = 1 x = 5 y = 5 screen:blit(x, y, test[test[frames+2]]) test[frames+1]:start() for test[frames+3] = 1, frames do -- THIS IS THE LINE OF THE ERROR-- if test[frames+1]:time() >= ((test[frames+3] -1) * interval) and test[frames+1]:time() <= (test[frames+3] * interval) then test[frames+3] = test[frames+2] end end
the error says: (in windows lua)
thx for help!Code:ERROR: '=' or 'in' expected near '[''
--------------------------------------------------------------------------------------
-
08-06-2006, 01:02 PM #3137QJ Gamer Bronze
- Registriert seit
- Oct 2005
- Ort
- Alabama
- Beiträge
- 272
- Points
- 5.975
- Level
- 50
- Downloads
- 0
- Uploads
- 0
I don't think you can use an array there in the for loop.
Use a temp variable, something like
Code:for x = 1, frames do
My lua tutorials for PSP - www.evilmana.com/tutorials
PSP Lua CodeBase - Add your own code examples to the codebase! - www.evilmana.com/tutorials/codebase/
-
08-07-2006, 04:55 AM #3138QJ Gamer Green
- Registriert seit
- Oct 2005
- Ort
- Scotland, UK
- Beiträge
- 571
- Points
- 7.057
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hey im working on my new game and ive got the animation done but what i want to know is how do i get my game to know when the button is not pressed and what direction the sprite should be facing. And also is there a way to check how long a button has been pressed for
Geändert von mark.sparky (08-07-2006 um 05:16 AM Uhr)
-
08-07-2006, 05:20 AM #3139QJ Gamer Blue
- Registriert seit
- Jul 2006
- Ort
- Alabama
- Beiträge
- 142
- Points
- 4.241
- Level
- 41
- Downloads
- 0
- Uploads
- 0
For direction:
if pad:left() then
player.direction= "left"
player.x = player.x - 1
end
For the button, do you mean something like this?(from Snake):
while not Controls.read():start() do
I haven't tested it, but I think that would also work as:
if not Controls.read():start()
--or--
and not Controls.read():start()
and any other command.
-
08-07-2006, 05:32 AM #3140words 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
... To everyone ...
Please run tests and small example programs, made by you, to learn the basic concept of programming... Once that is understood, the syntax of any language is the real challenge...
So in your case, mark.sparky, there's multiple ways to determine what direction, even with your vague question... As for when a button isnt pressed, Im using the basic concept of the 'not' operator with-in an argument/function returning 1 on pressed, 'not-1' when not pressed... So you do the basic puesdo code for this...
I dont even know probably 1/2 of the LUA syntax as an average LUA coder does, yet i understand the concept/routines to use in accomplishing what you want... It comes in very handy... Anyway, good luck with your new game mark.sparky!Code:-- I dont know all the syntax of LUA, so w/e the 'not' operator is, use it... Im -- guessing it's the ~ thing... in C its the ! while true do sg57 = Controls.read() -- Ex: Pause if ~sg57:start() then --While not paused, have movement calls here else -- if start is pressed -- app now paused... end end
...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
-
08-07-2006, 05:32 AM #3141words 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
... To everyone ...
Please run tests and small example programs, made by you, to learn the basic concept of programming... Once that is understood, the syntax of any language is the real challenge...
So in your case, mark.sparky, there's multiple ways to determine what direction, even with your vague question... As for when a button isnt pressed, Im using the basic concept of the 'not' operator with-in an argument/function returning 1 on pressed, 'not-1' when not pressed... So you do the basic puesdo code for this...
I dont even know probably 1/2 of the LUA syntax as an average LUA coder does, yet i understand the concept/routines to use in accomplishing what you want... It comes in very handy... Anyway, good luck with your new game mark.sparky!Code:-- I dont know all the syntax of LUA, so w/e the 'not' operator is, use it... Im -- guessing it's the ~ thing... in C its the ! while true do sg57 = Controls.read() -- Ex: Pause if ~sg57:start() then --While not paused, have movement calls here else -- if start is pressed -- app now paused... end end
...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
-
08-10-2006, 06:55 PM #3142I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
How do you exit the program and go back to the XMB? Besides using the "HOME" button?

-
08-10-2006, 06:57 PM #3143QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
I think break; or break works. Like:
Zitat von Access_Denied
Code:if pad:cross() then break; -- I think it's break, try both ways. break; and break. end
-
08-10-2006, 06:57 PM #31446201ymereJ

- Registriert seit
- Jul 2005
- Ort
- Baltimore
- Beiträge
- 588
- Points
- 7.062
- Level
- 55
- Downloads
- 0
- Uploads
- 0
you can't exit back to the XMB from LUA. Only back to a Lua Browser (if app. is launched from within the same Lua Browser)
Zitat von Access_Denied
-
08-10-2006, 07:04 PM #3145I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Well my PSP is currently unavailable, but I tried "break" on LUA Player for Windows and it immedately exited the program. So I think it worked.

-
08-10-2006, 07:07 PM #3146QJ Gamer Gold
- Registriert seit
- Mar 2006
- Ort
- LOLWUT
- Beiträge
- 2.625
- Points
- 18.627
- Level
- 86
- Downloads
- 0
- Uploads
- 0
@Jeremy - If that's the case, then it need to be a stand alone eboot, then do break and it will exit back to the XMB.
@Access_Denied - I'm not sure if it is going to exit to the XMB or the lua browser, since with the computer you can't tell.
-
08-10-2006, 07:15 PM #3147Developer

- Registriert seit
- Jun 2006
- Ort
- USA, Virginia
- Beiträge
- 580
- Points
- 5.650
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Well, I have tried this with an eboot. using the break function just gives you a black screen with the text, Press start to restart.
-
08-10-2006, 07:31 PM #3148I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
I'm using a standalone EBOOT. But if it doesn't work, I'll just settle with the home button. Unless anyone else knows a way?

-
08-10-2006, 07:31 PM #31496201ymereJ

- Registriert seit
- Jul 2005
- Ort
- Baltimore
- Beiträge
- 588
- Points
- 7.062
- Level
- 55
- Downloads
- 0
- Uploads
- 0
in a standalone eboot the "break" command simply restarts the lua application.
Zitat von PSPduh
-
08-10-2006, 07:33 PM #3150Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
You have to use unofficial Luaplayer versions, such as v0.17dk2 by Dark Killer or v0.20 mod by Cools, both of which have a System.Quit() function (Cools got his from Dark Killer's) that "exits Lua Player back to the psp browser." I haven't tested this yet but I assume it works. I'm sure somebody here could confirm this.


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