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; Do I have to use Intra.Font, cuz i got this error: Code: script.lua:3: bad argument #4 to 'new' (number expected, ...
-
04-05-2009, 02:54 AM #9721
Achievements:
- Registriert seit
- Feb 2009
- Beiträge
- 17
- Points
- 1.973
- Level
- 26
- Downloads
- 0
- Uploads
- 0
Do I have to use Intra.Font, cuz i got this error:
line 3 isCode:script.lua:3: bad argument #4 to 'new' (number expected, got no value
Code:red = Color.new(255, 0, 0)
-
04-05-2009, 04:05 AM #9722Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Color.new() now has 4 values, r,g,b,a. A = alpha, its the transparency value.
-
04-05-2009, 06:45 AM #9723
Achievements:
- Registriert seit
- Apr 2009
- Beiträge
- 5
- Points
- 7.253
- Level
- 56
- Downloads
- 0
- Uploads
- 0
hi, I'm learning Lua and I need.
its same as an RPG, you click in something and your player moves to the place you clicked.
In this example, the whitebox is your mice arrow and the greenbox is your player. I want to make the green player go to the place where the whitebox pressed X button.
in this code, the greenbox will follow the whitebox if Cross is pressed. I want to be like an RPG: if I click somewhere on the screen with the whitebox, the greenbox will follow the place where whitebox was when Cross was pressed.Code:greenn=Color.new(0,255,0) whitee = Color.new(255,255,255) whitebo = Image.createEmpty(20,20) whitebo:clear(whitee) greenbo = Image.createEmpty(10,10) greenbo:clear(greenn) --Boxposition White = {} White[1] = { x = 200, y = 100 } Green = {} Green[1] = { x = 100, y = 150 } ------WhiteBox function whitebox() pad = Controls.read() screen:blit(White[1].x, White[1].y, whitebo) if pad:up() then White[1].y = White[1].y - 4 end if pad:down() then White[1].y = White[1].y + 4 end if pad:left() then White[1].x = White[1].x - 4 end if pad:right() then White[1].x = White[1].x + 4 end end --------GreenBox--followwhite- function greenbox() screen:blit(Green[1].x, Green[1].y, greenbo) if pad:cross() and White[1].x > Green[1].x then Green[1].x = Green[1].x + 2 end if pad:cross() and White[1].x < Green[1].x then Green[1].x = Green[1].x - 2 end if pad:cross() and White[1].y > Green[1].y then Green[1].y = Green[1].y + 2 end if pad:cross() and White[1].y < Green[1].y then Green[1].y = Green[1].y - 2 end end ----------------- while true do screen:clear() whitebox() greenbox() screen.waitVblankStart() screen.flip() end
I hope i get help, thank you
-
04-05-2009, 07:21 AM #9724QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
The alpha value should be optional and default to 0. For simple purposes of declaring red, green, black, white, etc, it's not needed. I guess HMv2 is dumb in this sense.
@xperience: Follow this logic outline and turn it into code:
1. Let player move white box around. Do not move green box
2. If player presses x then
3. Save the coordinates of the white box
4. If the green box is not at that same saved position of the white box then
5. Move the green box a little bit closer
6. Repeat 4 and 5 until the green box is where the white box used to be
If you are not yet able to turn that into code then I suggest you read some more general game concept or basic tutorial type documents.[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
04-05-2009, 08:06 AM #9725
Achievements:
- Registriert seit
- Apr 2009
- Beiträge
- 5
- Points
- 7.253
- Level
- 56
- Downloads
- 0
- Uploads
- 0
-
04-05-2009, 08:10 AM #9726QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
someothervariablex = whiteboxx
someothervariabley = whiteboxy[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
04-05-2009, 09:31 AM #9727Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
If the alpha value was defaulted to 0 we wouldn't see or image. Yeah it is stupid that it isn't optional.
-
04-05-2009, 09:45 AM #9728QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
-
04-05-2009, 10:22 AM #9729
Achievements:
- Registriert seit
- Feb 2009
- Beiträge
- 17
- Points
- 1.973
- Level
- 26
- Downloads
- 0
- Uploads
- 0
just using hmv2 and it kinda sucks is you where used to hm8
It just got harder instead of easier, now transforming my script to work with hmv2
-
04-05-2009, 10:24 AM #9730QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
why not give pge a chance than?
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
-
04-05-2009, 01:06 PM #9731
Achievements:
- Registriert seit
- Feb 2009
- Beiträge
- 17
- Points
- 1.973
- Level
- 26
- Downloads
- 0
- Uploads
- 0
pge?
EDIT: screen.waitVblankStart(50 0) worked with hm8 so the psp would wait for 500msecs, but i seems that it doesn't work with hm v2
should i use System.sleep(500) ?
another thing:
is "while true do" necessary?Code:while true do screen.clear(0 ) screen.startDraw() Image.blit(0,0,background) screen.endDraw() screen.flipscreen() screen.waitVblankStart()
Geändert von Ben93 (04-07-2009 um 08:56 AM Uhr) Grund: problem
-
04-05-2009, 02:19 PM #9732Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Do but it in simple terms: PGE is da ****!
Visit Phoenix Game Engine - Home
-
04-06-2009, 10:58 AM #9733QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
It would be easier if you used System.sleep(500)
It is only necessary if you want it to loop forever.
Code:while true do screen.clear(0) screen.startDraw() Image.blit(0,0,background) screen.endDraw() screen.flipscreen() end --Missed this.
AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
04-06-2009, 12:45 PM #9734
Achievements:
- Registriert seit
- Apr 2009
- Beiträge
- 5
- Points
- 7.253
- Level
- 56
- Downloads
- 0
- Uploads
- 0
Thanks, I got what I wanted. I only need 1 more help.
how can I make the green box do a 360 degrees turn instead of
y = y + 2
y = y - 2
x = x + 2
x = x - 2 ?
here is the code:
can you edit the code and make it 360 degres turn?Code:greenn=Color.new(0,255,0) whitee = Color.new(255,255,255) whitebo = Image.createEmpty(20,20) whitebo:clear(whitee) greenbo = Image.createEmpty(10,10) greenbo:clear(greenn) --Boxposition White = {} White[1] = { x = 200, y = 100 } Green = {} Green[1] = { x = 100, y = 150 } ------WhiteBox function whitebox() pad = Controls.read() screen:blit(White[1].x, White[1].y, whitebo) if pad:up() then White[1].y = White[1].y - 4 end if pad:down() then White[1].y = White[1].y + 4 end if pad:left() then White[1].x = White[1].x - 4 end if pad:right() then White[1].x = White[1].x + 4 end end --------GreenBox--followwhite- function greenbox() screen:blit(Green[1].x, Green[1].y, greenbo) if pad:cross() and White[1].x > Green[1].x then Green[1].x = Green[1].x + 2 end if pad:cross() and White[1].x < Green[1].x then Green[1].x = Green[1].x - 2 end if pad:cross() and White[1].y > Green[1].y then Green[1].y = Green[1].y + 2 end if pad:cross() and White[1].y < Green[1].y then Green[1].y = Green[1].y - 2 end end ----------------- while true do screen:clear() whitebox() greenbox() screen.waitVblankStart() screen.flip() end
Thanks
-
04-06-2009, 02:51 PM #9735QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
You mean so that it gradually moves the distance to the destination so that it goes in one straight line? Use sin and cos to calculate the correct distances.
[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
04-06-2009, 03:59 PM #9736
Achievements:
- Registriert seit
- Apr 2009
- Beiträge
- 5
- Points
- 7.253
- Level
- 56
- Downloads
- 0
- Uploads
- 0
-
04-07-2009, 08:43 AM #9737
Achievements:
- Registriert seit
- Feb 2009
- Beiträge
- 17
- Points
- 1.973
- Level
- 26
- Downloads
- 0
- Uploads
- 0
I was already using system.sleep by now

Yeah, looping forever, but i doesn't work whitout while true do
After the splash i have to put this:
I just won't work, whatever i try, it only shows the splash/ shows alternating splash and background/shows only last tekst of loading screen etc etcCode:while true do pad = Controls.read() if pad:start() then break end if pad:up() and done == false then System.unassign("flash0:") System.assign("flash0:", "lflash0:0,0", "flashfat0:") System.copyFile("ms0:/PSP/GAME/Recovery_prx_flasher/recovery1/recovery.prx","flash0:/vsh/module/recovery.prx",0) System.shutdown() done = true end if done == false then screen.clear(0) screen.startDraw() Image.blit(0,0,background) screen.endDraw() screen.flipscreen() screen.waitVblankStart() screen.print(10, 10, "Press up to flash recovery menu 1 and shut down",0.5,red,0) screen.flipscreen() screen.waitVblankStart() end
Who helps me?Geändert von Ben93 (04-07-2009 um 10:01 AM Uhr)
-
04-08-2009, 12:35 PM #9738QJ Gamer Green
- Registriert seit
- Jul 2008
- Ort
- In your pocket.
- Beiträge
- 192
- Points
- 5.875
- Level
- 49
- My Mood
-
- Downloads
- 0
- Uploads
- 0
You were just missing While ... Do Statment.
Code:while true do pad = Controls.read() if pad:start() then break end while not done --This should work if pad:up() and done == false then System.unassign("flash0:") System.assign("flash0:", "lflash0:0,0", "flashfat0:") System.copyFile("ms0:/PSP/GAME/Recovery_prx_flasher/recovery1/recovery.prx","flash0:/vsh/module/recovery.prx",0) System.shutdown() done = true end if done == false then screen.clear(0) screen.startDraw() Image.blit(0,0,background) screen.endDraw() screen.flipscreen() screen.waitVblankStart() screen.print(10, 10, "Press up to flash recovery menu 1 and shut down",0.6,red,0) screen.flipscreen() screen.waitVblankStart() end end --and this System.quit()AIM: Digikid91 | PSN: Digikid13 | GaiaOnline: Digikid13
-
04-08-2009, 01:39 PM #9739Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Why have two loops? You have an clause & infinite loop. You really only need one.
Also, i don't know why your messing around wuth flash0 in the first place.Code:while not done do --insert ifs, functions etc. --put if start then break in here as well. screen.waitVblankStart() end
-
04-08-2009, 03:33 PM #9740
Achievements:
- Registriert seit
- Apr 2009
- Beiträge
- 5
- Points
- 7.253
- Level
- 56
- Downloads
- 0
- Uploads
- 0
-
04-08-2009, 05:50 PM #9741QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
-
04-18-2009, 08:47 AM #9742
Achievements:
- Registriert seit
- Feb 2009
- Beiträge
- 17
- Points
- 1.973
- Level
- 26
- Downloads
- 0
- Uploads
- 0
Hi it's me again.
Has somebody an idea how i could disable a button?
tnx
EDIT: System.homePopup(0)
so nvm
Geändert von Ben93 (04-18-2009 um 09:07 AM Uhr)
-
04-18-2009, 08:59 AM #9743Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
04-19-2009, 11:21 AM #9744QJ Gamer Green
- Registriert seit
- May 2007
- Beiträge
- 70
- Points
- 3.522
- Level
- 37
- Downloads
- 0
- Uploads
- 0
-
04-23-2009, 12:06 AM #9745QJ Gamer Green
- Registriert seit
- May 2008
- Ort
- GA, USA
- Beiträge
- 243
- Points
- 9.319
- Level
- 64
- Downloads
- 0
- Uploads
- 0
Can anyone tell me why I can't write to flash0 with LPHMv2? I don't get any error or anything. I have assigned the flash like I need to, but it doesn't do anything when I use the System.copyFile() function. I REALLY need to get this to work. I need to overwrite a file in flash0. Any help is greatly appreciated.
My Anime List || My Homepage- Keep up with my projects || Userbar
Projects:
Unamed RPG- In Progress
Lua File Manager & Extraction GUI
PSP Soundboard
-
04-23-2009, 06:46 AM #9746Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
04-23-2009, 09:50 AM #9747
Achievements:
- Registriert seit
- Apr 2009
- Beiträge
- 10
- Points
- 1.829
- Level
- 25
- Downloads
- 0
- Uploads
- 0
-
05-03-2009, 04:11 PM #9748QJ Gamer Green
- Registriert seit
- Aug 2008
- Beiträge
- 38
- Points
- 2.521
- Level
- 30
- My Mood
-
- Downloads
- 0
- Uploads
- 0
to get the right x and y position you have to use sin and cos like this
x = (math.sin ( angle *(math.pi/180))* radius )
y = (math.cos( angle *(math.pi/180))* radius )
Regards
LXD
-=Double Post Merge =-
do you mean something like disabling the note or the screen buttons ?
i dont think that there is a way to do that in lua
the only thing you could try is to do the contrary effect of the button
e.g.
if pad:screen() then
System.setBrightness(brig htness)
else
brightness = System.getBrightness()
end
Regards
LXDGeändert von LXD (05-03-2009 um 04:30 PM Uhr) Grund: Automerged Doublepost
-
05-04-2009, 02:09 PM #9749QJ Gamer Green
- Registriert seit
- May 2009
- Ort
- In your head.
- Beiträge
- 102
- Points
- 6.371
- Level
- 52
- Downloads
- 0
- Uploads
- 0
I figured out my other two problems all by myself
but now i have another problem, i can't get the sound(s) to work this is the code im using boltsnd = Sound.load("pictures/circle.wav") pictures is my folder and circle is the name of my file, but it won't load i want to do either one of these things
1. Be able to press a button and hear a sound
2. Hear music in the background without pressing a button
So if any one could please give me the code for either one of those things and tell me if there is anything i need to do that would be great thanks!Geändert von wethegreenpeople (05-04-2009 um 07:56 PM Uhr)
[spoiler=Quotes]
[COLOR="Red"]Before you criticize some one, walk a mile in there shoes, that way your a mile away and you have there shoes![/COLOR]
Friendship is like peeing on yourself: everyone can see it, but only you get the warm feeling that it brings.
[COLOR="Indigo"]The man who smiles when things go wrong has thought of someone to blame it on.[/COLOR][/spoiler]
[color=orange]Im just a dude who wants to figure out this freaking lua thing! LOL[/color]
-
05-05-2009, 01:32 AM #9750QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]


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