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)
Printable View
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)
Color.new() now has 4 values, r,g,b,a. A = alpha, its the transparency value.
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
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.
someothervariablex = whiteboxx
someothervariabley = whiteboxy
If the alpha value was defaulted to 0 we wouldn't see or image. Yeah it is stupid that it isn't optional.
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
why not give pge a chance than?
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()
Do but it in simple terms: PGE is da ****!
Visit Phoenix Game Engine - Home
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.
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
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.
I was already using system.sleep by now :p
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?
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()
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
Hi it's me again.
Has somebody an idea how i could disable a button?
tnx
EDIT: System.homePopup(0)
so nvm :p
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.
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
LXD
I figured out my other two problems all by myself :D 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!
LOL It says ( not in exact terms )
Error: can not load sound :20:
Its kind of obvious LOL and when i remove the sound code it loads all the way
So Now i want to figure something else out LOL How do you make it so like when some one presses a button it takes them somewhere else? Like Main menu >> Sub menu just something simple, if any one could tell me :D
1. How to make sounds when you press a button
2. How to make music play in background ( I got to work :D I told you guys i can figure out stuff LMAO)
3. How to make it go some where else, For example Main menu >> Sub menu
4. How to make something like... Do you want to continue Press O to continue or X to quit
IF any one could answer any one of these questions it would keep me busy for a long time :D HAHAHA thanks
In that case, it is more then likely the .wav is in the wrong format. IIRC, there are some strict guidelines on what sort of wavs can be loaded.
How can the .WAV be in the wrong format? Isn't the format .WAV what do i need to change to make it the right format or where can i download some .WAV in the right format
I think luaplayerHM supports 8 & 16 bit .wav files. You could try an audio converter or just try another file.
OOOOOOOH So is this why i update my lua player? If it will help i can try the new lua player again but it has failed for me in the past
No, you should update because it's faster, better, has more functions for different uses etc.
That's just to name a few, also it has mp3 support, which the original luaplayer lacked .
I did update >,< it did not work none of my scripts worked even the one i could get to work on the old one
Like i explained before, that's because certain functions have changed. You'll need to look it up (the function changes)
LOL Yea, so many different functions then i would have to change the whole code over again and make sure that i changed everything back to the new one LOL
Well not really, there's a only a few functions that you'll use (for now). Mainly the controlling 'main' loop is slightly different. Though, in a way i can see your point, the docs aren't good, they don't provide any examples.