Thanks, i've got some simple AI working now :)Zitat:
Zitat von yaustar
Printable View
Thanks, i've got some simple AI working now :)Zitat:
Zitat von yaustar
So how exactly do I fix it?
You make it stop double flipping it every loop.
wehn i do that. like if i remove the first screen.flip() it will load everything so fast and stop.
Well take it out of the loop or make the data loading in the loop then add a break then load the animation in another while loop.Zitat:
Zitat von Cheez Pirate
Well why dont you just ditch a loading screen? What you have loads in like 0.1 seconds, why unnecessarily make people wait?
what is the pad:Controls:read() for??Code:white = Color.new(255,255,255)
red = Color.new(255,0,0)
black = Color.new(0,0,0)
dofile("lib/animlib.lua")
logo = ANIM.new(8,"logo","png","logo/")
loadingscreen = Image.load("images/loadingscreen.png")
loadingbar = {}
loadingbar.y = 11
data = {}
data.loaded = 0
cursor = Image.load("images/cursor.png")
data.loaded = data.loaded + 25 * 4
nameofimage = nil
while true do
pad = Controls.read()
screen:clear(white)
logo:advancedBlit(0,0,500,1)
screen.flip()
screen:clear(white)
screen:blit(0,0,loadingscreen)
screen:fillRect(47,205,data.loaded,loadingbar.y,red)
screen.waitVblankStart()
screen.flip()
end
-= Double Post =-
Exactly there is no need to make a loading screen unless you use something that takes a while like netlib or sumfinZitat:
Zitat von TacticalPinguin
Well the thing is... That isn't a complete game lol. There will be a lot more. Now what does break do? :X
the keyword 'break' does just what it says - 'breaks' the current running loop.
pad = Controls.read() will return the current state of the PSPs buttons, each true or false. So, by placing it in a loop, your constantly checking for a changae in button presses, therefor calling if pad:cross() your checking the pad metatable (or wahtever it is in lua... its a structure in C) to see if the cross button is checked to true indicating its being pressed.
Or something like that im sure
I don't think the 2 of you before SG57 know what i'm saying.
How can I blit the animation and when it's OVER load the loading screen. And I know the load screen is 0.1 seconds. It's not anywhere near what else i'll be loading in the future.Code:white = Color.new(255,255,255)
red = Color.new(255,0,0)
black = Color.new(0,0,0)
dofile("lib/animlib.lua")
logo = ANIM.new(8,"logo","png","logo/")
loadingscreen = Image.load("images/loadingscreen.png")
loadingbar = {}
loadingbar.y = 11
data = {}
data.loaded = 0
cursor = Image.load("images/cursor.png")
data.loaded = data.loaded + 25 * 4
nameofimage = nil
while true do
pad = Controls.read()
screen:clear(white)
screen:clear(white)
logo:advancedBlit(0,0,500,1)
screen:blit(0,0,loadingscreen)
screen:fillRect(47,205,data.loaded,loadingbar.y,red)
screen.waitVblankStart()
screen.flip()
end
Ok then put the animation in the script (not in a while loop) then make a while loop put your loading stuff in it then "break" and move on to whatever your going to.
TO SG57 : I know what the pad = Controls.read() is im just saying first it is in the loop why?? and I see no need for that since he hasnt used it ;)
he probably will use it in the future...
alright. loading stuff. by that you mean the loadingscreen, data.loaded, or screen:fillRect?
mmmm, got the weirdest error that I've ever seen just now....
I Had just put an image in the images folder (the Pxp compo Splash Screen)
then loaded up my app on my psp, then it gave me
error: index.lua:4:Image.load Error loading image
now, that is nothing new the weird part is what happened when i opened up the images folder of my app that was on my psp after that..., what i found was..
http://img136.imageshack.us/my.php?image=screenstn2.png
all of those which look like it Fragments of lua code used to be images and folders of images...
really weird, any suggestions?
Edit: Looks like things just got worse....seems i cant delete that images directory, wouldn't let me, I went on to my psp, and that didn't work, it said "delete Failed"... WTF is going on?
Clear everything off your PSP then format. Then put everything back on it
ouch, sounds like a virus.Zitat:
Zitat von BlackShark
if reformatting doesnt work (it should though), try deleting it with IR shell or FileAssistant.
Zitat:
Zitat von BlackShark
you memory card is corrupted. formating will make it work again. however, if it happens often, you memory card is either getting old, or is fake.
Hey when I print font text EG:
screen:fontPrint(font,0,0 ,"I have probleme with this",White)
The script works fine the image and everythig blit exept the Font script.Is it maybe because the .fft is to big if yes can somone explain me how to use this and how to resise the .ttf to the size of a normal screen:print function.Actualy I just want to know what is number dpiX/Y
Font Font:setCharSize(number width, number height, number dpiX, number dpiY)
ok, well, i think it was a corrupted Eboot, cuz I got a new kxploited one and put my game stuff in that one then moved everything to the stick so now every thing works as it should, however i still have that damn folder with the damned Image folder....i WOULD reformat it but i got about 3 and half GIGS of stuff on it...various..stuff...... o0... Got a 4 gig for Xmas :P I love it any way the folder only takes up about 150 kb so its not a Big problem...not anymore...
Backshark I have the same type of problem when I was deleting the folder 'dh' Devhook it said it could not be deleted beacuase of one file called COOKIE.DAT So I went and found the file under 271 and deleted it. It WAS GONE. I tried deleting 'dh' and the FILE JUST CAME BACK???
-= Double Post =-
TO CHEEZPIRATE HOLD ON IM gonna make you your script again.
use File Assistant for corrupted things :)
Does anyone know how to create a FPS counter??
yes, i made a small snippet in the lua snippets thread.
K thanks
how do i check if a part of a table exists?
what would be the correct way to do that case? i cant find an "isset" kind of functionCode:test = {foo=true, bar=0}
if test.meep then
-- was found
else
-- was not found
end
Okay, so I have just begun learning lua recently, and I am making a stupid app for practice/learning. I have this code:First let me tell you what it is supposed to do- there is a start screen that is a menu with choices between 2 different songs to play. If you click (cross) on a song, it should go to a new screen that says "press x to play song, press x again to pause song, enjoy." The selected song should play once pressing cross, pause if cross is pressed again, and that's about it. I have many problems-the selector for the menu doesn't move, when I press X it sometimes plays music, sometimes it doesn't, and instead of pausing it stops it completely and starts back over when I press X again. Thanks for any help, I know this is confusing. Hopefully the code is at least sort of neat.Code:--App by andyauff
--Version .02 of "Useless Music App", finished January , 2007
--define colors---------------------------------------------------
white = Color.new (255,255,255)
blue = Color.new (0,0,255)
black = Color.new (0,0,0)
red = Color.new (255,0,0)
green = Color.new (0,255,0)
yellow = Color.new (255,255,0)
purple = Color.new (255,0,255)
--create the menu function----------------------------------------
function drawMenu()
gamestate = "menu"
oldpad = Controls.read()
song = "mindwave"
selector = { image = Image.createEmpty (145,15), x = 147, y = 77}
selector.image:clear(yellow)
screen:clear(green)
pad = Controls.read()
screen:blit(selector.x,selector.y,selector.image)
screen:print(150,80,"Mindwave",blue)
screen:print(150,100,"Minute",blue)
--controls
if pad:up() and oldpad:up() ~= pad:up() then
selector.y = 77
song = "mindwave"
end
if pad:down() and oldpad:down() ~= pad:down() then
selector.y = 97
song = "minute"
end
if pad:cross() and oldpad:cross() ~= pad:cross() then
inGame()
end
screen.flip()
end
--create the game funtion------------------------------------------
function inGame()
gamestate = "start"
pad = Controls.read()
screen:clear(red)
screen:print(150,100,"To play song, press X.",green)
screen:print(150,120,"To pause song, press X again.",yellow)
screen:print(150,140,"Enjoy!",purple)
if pad:cross() and gamestate == "start" and song == "mindwave" then
Music.playFile("mindwave.mod", false)
gamestate = "playing"
end
if pad:cross() and gamestate == "start" and song == "minute" then
Music.playFile("minute.xm", false)
gamestate = "playing"
end
if pad:cross() and gamestate == "playing" then
Music.pause()
gamestate = "paused"
end
if pad:cross() and gamestate == "paused" then
Music.resume()
gamestate = "playing"
end
if pad:start() then
gamestate = "menu"
end
screen.flip()
end
--main loop---------------------------------------------------------
while true do
drawMenu()
oldpad = pad
end
It would work since test.meep will return nil although I wouldn't recommend it from a programming style/design standpoint.Zitat:
Zitat von eyece
no, thats what i tried, it didn't work, it just returns the "attempt to index field '?'" error,
i may have to have all the table parts set to false, kind of gay though, LUA-Player v0.21 should have implemented something like this:
if ~variable then
...
end
Hey how can i like change print to a function like this:
toCode:print(buffer)
Some thing like that. What im trying to say is how can i transfer what is printed to somewhere elseCode:if buffer ... then
...
end
Can somone anwser to my question please.Page 516 firstpost.