yes you can.Zitat:
Zitat von Sousanator
Printable View
yes you can.Zitat:
Zitat von Sousanator
yeah. It says something like "attempt to call WaitVblankStart (nil value) help please!Zitat:
Zitat von Greenskull
EDIT: aha! The "w" was capitalized. im good now:D but how do I make my animation loop over and over until I press X again?
try this:Zitat:
Zitat von Greenskull
Code:white = Color.new(255, 255, 255)
frame_1 = Image.load("frame_1.png")
frame_2 = Image.load("frame_2.png")
frame_3 = Image.load("frame_3.png")
showAnimation = true
timer = Timer.new()
while true do
pad = Controls.read()
timer:start()
screen:clear()
if showAnimation then
if timer:time() >= 0 and timer:time() <= 135 then
screen:blit(0, 0, frame_1)
elseif timer:time() > 135 and timer:time() <= 270 then
screen:blit(0, 0, frame_2)
elseif timer:time() > 270 and timer:time() <= 405 then
screen:blit(0, 0, frame_3)
elseif timer:time() > 405 then
timer:stop()
timer:reset()
end
else
screen:print(0, 0, "Paused!", white)
end
if pad:cross() and pad ~= oldpad then
if showAnimation then showAnimation = false else showAnimation = true end
end
oldpad = pad
screen.flip()
screen.waitVblankStart(6)
end
here's the updated version of your deal or no deal script.it should work... it only takes each prize value once. from $0 to $1,000,000. The reason you had so many repeats is you had a couple prize values the same. This also displays the prize value in $0.00 format.Zitat:
Zitat von Grimfate126
Ok, the blipping stopped, but the highlighter doesn't move at all now. Which is fairly logic, because if right() is pressed, both pad and oldpad would be right(), so the if value would not be true.Code:pad = Controls.read()
oldpad = Controls.read()
if pad:right() and pad ~= oldpad then
x = x + 10
oldpad = pad
elseif pad:left() and pad ~= oldpad then
x = x - 10
oldpad = pad
end
if pad:start() then
break
end
Ah yeah thats what i thought. Its because you pause the loop by using the waitVblanck's. So what you have to do is make a timer and if the timer is at a specific value (the length of your music) then you play the other musicfile.Zitat:
Zitat von cools
@SjaakRake
I dont know why people use that code, but i know this works:With this it puts the value of pad in oldpad after everything is done, so when it does a new loop then it has the value of the last loop and that is what you want.Code:pad = Controls.read()
if pad:right() and pad ~= oldpad then
x = x + 10
oldpad = pad
elseif pad:left() and pad ~= oldpad then
x = x - 10
oldpad = pad
end
if pad:start() then
break
end
oldpad=pad
Haha, thanks, I'm so damn stupid, pretty logic.
PS. As you might have guessed, I'm dutch too, if you're interested in contacting me. PM me.
Ok, so it was the screen.waitVblank's that were messing up the code and I only need to change it to a timer. Thanks Altair!Zitat:
Zitat von Altair
no problem at all. Im looking forward to playing monopoly on my PSP!
How would I make a string containing "? Can this be done through the hex value? If yes, how?
Blegh, I ask too much.
ok yea well done altair - how retarded of me, soz that was off the top of my head Sjaakrake
How do you compile a LUA app/game to an eboot.pbp so you dont have to run it with Luaplayer? I have Cygwin installed and the psptoolchain installed. What else do I need to do?
I am very confused about this "oldpad" thing. How do you make it so when you press X it starts and when you press it again it stops etc.?Zitat:
Zitat von califrag
Use this: \"Zitat:
Zitat von SjaakRake
This has to be in the quotations of the string itself. So say you want to put "hello" in a variable but with the quotations, you have to do this:
text="\"hello\""
[Dutch]Ja dat dacht ik al ja. "Sjaak" kom je niet zo vaak tegen in het buitenland :D.[/Dutch]
Everybody has its "off"-days (is that how you say it?) and thxZitat:
Zitat von Glynnder- PSPro
hi!
how do you repeat a sound so when it ends it start at the begining again? please help! thanks! :) btw, its a wav file if that helps.
and how big should the wav file be so the lua player duzent hangs?? thanks
I dont know if there's a limit to the length or size, but i know it needs to be mono sound.
Here's the command and its argument:
So if you want it to loop then you say:Code:Sound.load(filename, [bool loop])
This site is really usefull: http://wiki.ps2dev.org/psp:lua_player:functionsCode:Sound.load(filename, true)
need help again!
ive made a menu. everything works exept that the intro song repeats it self from the moment it starts! :( wtf is wrong? help! please! :) here:
finalizar=1
while finalizar>0 do
screen:blit (0,0,menu)
music:play()
Music.volume(128)
screen:print (420,10,"v 0.1",negro)
screen:print (421,261,"MADSOUL",Color. new(80,80,math.random (1 , 255)))
screen:print (420,260,"MADSOUL",Color. new(255,255,math.random (1 , 255)))
screen:print (120,5,"This is your",rojo)
screen:print (177,15,"last Score",rojo)
screen:print (270,10,puntos,Color.new (math.random (1 , 255),math.random (1 , 245),math.random (1 , 255)))
screen.waitVblankStart()
screen.flip()
pad = Controls.read()
if pad:cross() then
juego()
end
if pad:start() then
finalizar=0
end
end
When you want the music to stop, put Music.Stop() . If you want it to stop in a different script, put it at the top outside the loop.
or at the top of your script you can change the:
music = Music.PlayFile("music.it" )
to:
music = Music.PlayFile("music.it" , false)
ok, but now when i try to start the game it gives me this message:
error: SCRIPT.LUA:47: error loading sound
Error: No script found.
Could you perhaps attatch the script file?
yeas! it works now!! great! :D now i only need to make some images! :D im very soon finnished with my own lua game!!!! :D
how do i make this image trasparent?
http://img114.imageshack.us/img114/8450/heli19qw.png
im mean so the black around it disepear when i play the game.
Can't you photoshop the black bit out?
If you don't have photoshop i believe GIMP is a good program.
how can you make all those fakes and not know how to make a image transparent!!!Zitat:
Zitat von madsoul
ok im a n00b at lua and when i play this it stops straight waway i know it is something to do with the loop but could someone tell me what it is because i have no clue
-- Green Color Object
green = Color.new(0, 255, 0)
-- Store birth year in varible myBirthYear
myBirthYear = 1986
-- Store current year in currentYear
currentYear = 2006
-- create an empty varible
myAge = nil
-- Store some text in a varible
someText = "My age is roughly "
-- Subtract myBirthYear from cureentYear and store inmyAge
myAge = currentYear - my BirthYear
-- Print my text varible to the screen
screen:print(10, 100, someText .. myAge,green)
-- Buffer offscreen to onscreen
screen.flip()
--Loop forever
while true do
screen.waitVblankStart()
end
the p is in bold becuase if it was not it would look like this :p
How would I make something (a spike specifically) fall down the screen?
Try this:
Code:pic= image.load('whatever')
picx=400
picy=0
while true do
screen.blit(picx,picy,pic ,0,0,pic:width(),pic:heig ht())
if picy+pic:height()<260 then (if the ground starts at 260 that is)
picy=picy-10
end
if picy+pic:height()>260 then
picy=260-pic:height()
end
if picy +pic:height()==260
picx=picx-5
end
end
Hm, okay after changing filenams around and bliting a white background it loads but no spike...
hmm. Post your code plz.
try this:Zitat:
Zitat von mark.sparky
-- Green Color Object
green = Color.new(0, 255, 0)
-- Store birth year in varible myBirthYear
myBirthYear = 1986
-- Store current year in currentYear
currentYear = 2006
-- create an empty varible
myAge = nil
-- Store some text in a varible
someText = "My age is roughly "
-- Subtract myBirthYear from cureentYear and store inmyAge
myAge = currentYear - my BirthYear
-- Print my text varible to the screen
-- Buffer offscreen to onscreen
screen.flip()
--Loop forever
while true do
screen:print(10, 100, someText .. myAge,green)
screen.waitVblankStart()
screen:flip()
end
K. All I changed was the "pic" text and added a white background. (if ur talking about the code to the game I dont have it because im totally rewriting the code)Code:spike = Image.load("spike.png")
background = Image.load("background.png")
spikex = 400
spikey = 0
while true do
screen:blit(0,0, background, false)
screen:blit(spikex, spikey, spike, 0, 0, spike:width(), spike:height())
if spikey + spike:height() < 260 then
spikey = spikey-10
end
if spikey + spike:height() > 260 then
spikey = 260 - spike:height()
end
if spikey + spike:height() == 260 then
spikex = spikex-5
end
screen.flip()
screen.waitVblankStart()
end
Whats the problem/error you get?Zitat:
Zitat von MaSt3r_ShAk3
and maybe i can help yas :icon_bigg .
Okay, im attempting to make my first ever lua game. Ive been doing lua for roughly three days and ive grasped most of it. I wanted to do a shooter and gutya(great guy) has been aiding me. Fair enough, its an in depth first project, but i wanted to try.
So i used evil manas snippets and attempted to merge them together, to get a moving shooting character.
But at the moment ive fixed a few errors but then This comes up
" Error: index.lua:29: attempt to index field '?' <a nil value>
Id appreciate someone helping me out with this code, as i dont understand parts of it myself. After this error im sure there will be more.
Code:--Activiate usb
System.usbDiskModeActivate()
--generating colours
red = Color.new(255,0,0)
black = Color.new(0,0,0)
green=Color.new(0,255,0)
white = Color.new(255,255,255)
--Create shapes
player1 = Image.createEmpty(32,32)
player1:clear(red)
ground = Image.createEmpty(480,10)
ground:clear(green)
bullet = Image.createEmpty(4,4)
bullet:clear(green)
--variables
oldpad = Controls.read()
currentBullet = 0
direction = "right"
--Arrays
player = {}
player.gravity = 230
player.y = 230
player.x = 50
player.jumpspeed = 10
player.jumpstate = "ground"
--bullet array
BulletInfo = {}
for a = 1,5 do
BulletInfo[a] = { pic = bullet , firing = false, direction = "right", x = player[1].x + 32,
y = player[1].y + 16 }
end
--Functions
function bulletSetup()
--Increase the current bullet by one, or reset it to 1
if currentBullet < 5 then
currentBullet = currentBullet + 1
else
currentBullet = 1
end
if direction == "left" then
BulletInfo[currentBullet].x = Player[1].x
BulletInfo[currentBullet].y = Player[1].y + 16
end
if direction == "right" then
BulletInfo[currentBullet].x = Player[1].x + 32
BulletInfo[currentBullet].y = Player[1].y + 16
end
if direction == "up" then
BulletInfo[currentBullet].x = Player[1].x + 16
BulletInfo[currentBullet].y = Player[1].y
end
if direction == "down" then
BulletInfo[currentBullet].x = Player[1].x + 16
BulletInfo[currentBullet].y = Player[1].y + 32
end
BulletInfo[currentBullet].direction = direction
BulletInfo[currentBullet].firing = true
end
function bulletFire()
for i = 1,5 do
if BulletInfo[i].firing == true then
if BulletInfo[i].direction == "right" then BulletInfo[i].x = BulletInfo[i].x + 10 end
if BulletInfo[i].direction == "left" then BulletInfo[i].x = BulletInfo[i].x - 10 end
if BulletInfo[i].direction == "up" then BulletInfo[i].y = BulletInfo[i].y - 10 end
if BulletInfo[i].direction == "down" then BulletInfo[i].y = BulletInfo[i].y + 10 end
screen:blit(BulletInfo[i].x,BulletInfo[i].y,BulletInfo[i].pic)
end
if BulletInfo[i].x < 0 or BulletInfo[i].x > 480 or BulletInfo[i].y < 0 or BulletInfo[i].y > 272 then BulletInfo[i].firing = false end
end
end
--Print bullet info to screen.
screen:print(10,10,"Bullet 1: ".. tostring(BulletInfo[1].firing),green)
screen:print(10,20,"Bullet 2: "..tostring(BulletInfo[2].firing),green)
screen:print(10,30,"Bullet 3: "..tostring(BulletInfo[3].firing),green)
screen:print(10,40,"Bullet 4: "..tostring(BulletInfo[4].firing),green)
screen:print(10,50,"Bullet 5: "..tostring(BulletInfo[5].firing),green)
screen:print(10,60,"Direction: "..direction,green)
--mainloop
while true do
pad = Controls.read()
screen:clear()
if pad:start() then
break
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 < 230 and player.jumpstate == "falling" then
player.gravity = player.gravity + (player.jumpspeed + 3)
end
if player.gravity == 230 then
player.jumpspeed = 10
player.jumpstate = "ground"
end
if player.gravity > 230 then player.gravity = 230 end
player.y = player.gravity
screen:blit(player.x,player.y,player1)
screen:blit(0,262,ground)
screen:print(10,10,"X: "..player.x.." Y: "..player.y,green)
screen:print(10,20,"Jumpstate: "..player.jumpstate,green)
screen.waitVblankStart()
screen.flip()
end
if pad:cross() and oldpad:cross() ~= pad:cross() then
bulletSetup()
end
bulletFire()
screen.waitVblankStart()
screen.flip()
oldpad = pad
Thats just some test code to make an image fall down th screen. when i test. only the background is blitedZitat:
Zitat von c5cha7
Hey, i hate to sound like a total n00b but how would i get lua player running on the gta eloader, for some reason it wont work (v0.14) - thx. :Argh: :o
anyone?Zitat:
Zitat von Greenskull
I cant figure out how to loop an animation. help please!