Thanks LMelior. I should have asked you in the first place :D seeing as its your code.
-= Double Post =-
well, no same problem.. it pauses the game, when X or start is pressed it unpauses and displays the screen for a split second..
Printable View
Thanks LMelior. I should have asked you in the first place :D seeing as its your code.
-= Double Post =-
well, no same problem.. it pauses the game, when X or start is pressed it unpauses and displays the screen for a split second..
What do you mean by: "when X or start is pressed it unpauses and displays the screen for a split second"? Do you mean it shows the game and exits immediatly, OR do you mean it pauses for a split second and immediatly goes back to the game?
Oh yeah, you also forgot to flip the screen in the while loop.
STRANGE ERROR!
As soon as a try to .filip() with another image then screen, i get the "Loop in gettable" error.
I get error fore this(Not the acutall code, just a example)
The <- represents what gives me the error.
Code:background = Image.createEmpty(480, 272)
background:blit(0,0,example) <-
screen:blit(0,0,example)
background.flip() <-
screen.flip()
"example" has to be a valid image.
You only flip the screen, you don't flip any other images.
Well, the screen:flip() worked just fine.. this isnt a question but for some reason you can only have a fully transarent image or either a colored image.. say in photoshop i made the image of the start menu frame and added a fully black layer over it.. well when i changed the opacity level to make it like a greyish transparent level it made the image fully black.. but when i deleted that layer its fully transparent.. wierd.
I'm trying to make a simple program that each time u press cross it reads the next or prefferably a random line in a .txt this is the best i can come up with but it doesnt work,
red = Color.new(255, 0, 0)
file = io.open("something.txt", "r")
ourline = file:read()
file:close()
while true do
screen:clear()
pad = Controls.read()
if pad:triangle() then
return
end
if pad:cross() then
screen:print(10,10,ourlin e,red)
screen.waitVblankStart()
screen.flip()
end
looking forward to any help.
p.s i'm very new to lua so dont be mean :P
-= Double Post =-
anyone?
not that i'm impatient.. its just been 1 and a half hours and i cant see whats wrong with it :P
Anyone know how to use the Lua GU commands for 3D? I would really like to learn for lua as I learn the actual GU (I know, sounds stupid...)
can someone point me in the direction of the windows lua files?
http://evilmana.com/tutorials/lua_tutorial_01.phpZitat:
Zitat von Hooger
OT - ZOMG!!!!!!!!!!!!!!!!!!!!! ! 1337 POST!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!! !!!!!1111!!!!one!!!!eleve n!!!!!!!!!!!!
=p
thanks mister leet guy
PSPduh - ... just ... lol
Bronx - Check your other post... And why not learn C GU if your doing LUA GU. Its pretty much the same, just the syntax is completely off...
Im learning both ;)
Are you kidding me? I said that it wasen't the actuall code! It's a example!Zitat:
Zitat von head_54us
It is inself the canvas that gives me error. And yes, here comes a example.
Code:board:blit(0,0, example)
Pretty sure of this:Zitat:
Zitat von Branin
That's only in luaplayer for windows. Try it on the PSP and it will work fine, unless you aren't saving your transparency levels in Photoshop.
I'm not sure what you mean this time (this code looks fine to me), but his second sentence was the important part.Zitat:
Zitat von HaxxBlaster
I solved it, but it does not turn out the same way as the "screen.blit".
It can't display any transparency at all. It just skips the transparent pixels and show the solid ones, strange..
can someone plz say how i can get lua to read a random line from a txt file and print it to screen?
or show me how my code on the last page is wrong.
Mraellis, I can't tell you off the top of my head (I couldn't even write it out without a reference), but take a look at Snake (included in Luaplayer). It reads and writes from different lines of options.txt. I think the functions are called saveOptions() and loadOptions().
ok im using the 5 bullet code from evil mana and i have it set up so that when the bullet enter a certain are (hits the target) the score goes up by one
i have it working but the score continues to go up repeatedly unless i fire 5 bullets out of the zone. here is my code
if Wario[1].y + 72 > BulletInfo[i].y and BulletInfo[i].x + 8 > Wario[1].x and BulletInfo[i].x < Wario[1].x + 107 then
BulletInfo[i].firing = false
score = score + 1
end
please tell me what to do to make the score go up by JUST one not one repeated
Zitat:
Zitat von jamz1825
the problem is, even after uve declared bullet firing to false, the x and y valuse retain their valuse. you need a bool:
try thatCode:hit = false
if Wario[1].y + 72 > BulletInfo[i].y and BulletInfo[i].x + 8 > Wario[1].x and BulletInfo[i].x < Wario[1].x + 107 then
BulletInfo[i].firing = false
hit = true
end
if hit == true then
score = score + 1
hit = false
end
Why does everyone use Charlie's method? Sure its greats for begginers, but not when you go on to greater tasks. I mean his tutorials are for getting people started in lua, and provide a foundation. NOT provide a way you will use your whole career of lua
ive already tried that the score just continues to rise
EDIT: i double checked and tried urs, still no luck
-= Double Post =-
and bronx... about the getting started part...this is my first lua
whos charlie???Zitat:
Zitat von Bronx
no worries i just got it, i had to move the coordinates of the bullet after it hit to a random spot that wouldnt make a difference
Oh, sorry dude... Continue on learning then :tup:
Charlie is the owner of Evilmana >.> (AKA PSPMillionare)
o his bullet code.. i see now. :tup:Zitat:
Zitat von Bronx
thx aphonia, but the index.lua in snake goes on about strings and stuff i dont get in that bit >.<
i can wait till more program lua tuts come out as it might help me.
That's an ugly fix... All you had to do was add an extra part to your if statement:Zitat:
Zitat von jamz1825
Since the if statement will only trigger when firing == true and you immediately set it to false if it does trigger, than it will only run once.Code:if (collision stuff) and BulletInfo[i].firing then
BulletInfo[i].firing = false
score = score + 1
end
we all got pwnt. :PC:Zitat:
Zitat von LMelior
Check out the io.lines entry in the Lua Reference Manual. I've never had to do what you want before, but if I did then I would probably use that. I don't know if this will work or not, but I'd try this:Zitat:
Zitat von mraellis
No guarantees, of course. :)Code:tableoflines={}
k=0
for line in io.lines("filename.txt") do
k=k+1
tableoflines[k]=line
end
randomline=tableoflines[math.random(k)]
ok, there could be a very simple answer to this but of coarse i dont know...i am jsut begining
andway
can you tell me how to make it so when i press start the game pauses and if i press it agin it resumes.
i know something exists like
system.sleep()
anyway could anyone help me out?
anyone?
i got it so i can pause but i haveto resume with another button
how could i do it with the smae button (start)
did you use this for the pause code?
Code:--This goes somewhere near the start--
function pause()
while true do
pad:Controls.read()
screen:clear()
screen:print(200,200,"Game Paused",red)
if pad:start() and oldpad:start()~=pad:start() then
break
end
screen.waitVblankStart()
screen.flip()
end
end
--This goes in the main loop--
if pad:start() and oldpad:start()~=pad:start() then
pause()
end
thanks lmelior but that doesnt work :(
and that lua link is confusing.
i think i'll wait till a few more lua tuts for program luas out before i make something.
ok heres my problem i got my code pretty much sorted out but when i olay it the loading screen stays on 0% and then turns off my psp whats wrong anybody know?
Zitat:
Zitat von %chrono trigger%
can we see your code?
its probably a loading problem.
nope didnt find it here is my code:
pink = Color.new(255, 0 , 153)
GameStatus = "Loading"
LoadingTimer = Timer.new()
LoadingTimer:start()
if GameStatus == "Loading" and LoadingTimer:time() >= 1 and LoadingTimer:time() < 50 then
screen:clear()
screen:print(194, 136, "Loading: 0%", pink)
screen.flip()
gunscreen = Image.load("gunscreen.jpg ")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 50 and LoadingTimer:time() > 100 then
screen:clear()
screen:print(194, 136, "Loading: 20%", pink)
screen.flip()
gunman = Image.load("gunman.jpg")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 100 and LoadingTimer:time() > 150 then
screen:clear()
screen:print(194, 136, "Loading: 40%", pink)
screen.flip()
background = Image.load("background.jp g")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 150 and LoadingTimer:time() > 200 then
screen:clear()
screen:print(194, 136, "Loading: 60%", pink)
screen.flip()
playera = Image.load("playera.png")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 200 and LoadingTimer:time() > 250 then
screen:clear()
screen:print(194, 136, "Loading: 80%", pink)
screen.flip()
playerb = Image.load("playerb.png")
end
if GameStatus == "Loading" and LoadingTimer:time() >= 250 and LoadingTimer:time() > 300 then
screen:clear()
screen:print(194, 136, "Loading: 90%", pink)
screen.flip()
end
if GameStatus == "Loading" and LoadingTimer:time() >= 300 and LoadingTimer:time() > 350 then
screen:clear()
screen:print(194, 136, "Loading: 100%", pink)
screen.flip()
end
if GameStatus == "Loading" and LoadingTimer:time() > 351 then
LoadingTimer:stop()
LoadingTimer:reset()
GameStatus = "Menu"
end
screen:blit(0,0,gunman)
screen.waitVblankStart(60 )
screen:clear()
screen.waitVblankStart(60 )
screen:clear()
screen:blit(0,0,backgroun d)
playera = {}
player[a] = {x = 200, y = 50}
playerb = {}
player[b] = { x = 400, y = 100 }
screenwidth = 480 - player.width()
screenheight = 272 - player.width()
player[b] = { x = 400, y = 100 }
screen:blit(Player [a].x,Player [a].y,playera)
screen:blit(Player[b].x,Player.y,playerb)
screenwidth = 480 - player.width()
screenheight = 272 - player.width()
Playerb = { x = 400, y = 100 }
if pad:left() and Player[1].x > 0 then
Player[1].x = Player[1].x - 2
end
if pad:right() and Player[1].x < screenwidth then
Player[1].x = Player[1].x + 2
end
if pad:up() and Player[1].y > 0 then
Player[1].y = Player[1].y - 2
end
if pad:down() and Player[1].y < screenheight then
Player[1].y = Player[1].y + 2
end
screen.waitVblankStart()
screen.flip()
But why use Lua for "your whole career" when you have C++?Zitat:
Zitat von Bronx
@ Chrono, i think that would load the image into memory over and over again realy quickly, crashing the PSP.
Use
That was terrible i dont even know if there is a ELSE function in Lua.Code:if loading step = 1
IF background (or whatever image) = null
//* Print text saying 20% done or whatever
//* Load Background image...
END
else
load = 2
END
END
Wait, i dont know Lua at all! But anyway what you want done can be acomplished with Null.
So
isCode:
IF Background = null
orCode:
If the memory at the address background is empty then.
Code:
if background is empty then.
where do i put the IF Background = null?
and what does the code do? (so im not just coping and pasting)
I explained it at the bottom. DONT copy that code, i dont know lua, it wont work. It was just theory code.
IF background = null will check to see if there is no image in background.
Soo take out the timer and put that there instead. The timer is what is crashing the PSP.
Ergh ive explained this terribly...