to the point i would like to know how i would go about creating my own font or getting one that is curretly available could someone please help if they know
thanks
Printable View
to the point i would like to know how i would go about creating my own font or getting one that is curretly available could someone please help if they know
thanks
at the top of this page it will tell you how to make or load an existing font. Then, to use this font use:
Code:screen:fontPrint( font, x, y, string, color )
but its very slow... you will see yourself ;)
http://www.pspro.co.uk/forums/index.php/topic,55.0.html
For True Type Fonts.
thanks that helped a load
No problem (if that was directed to me).
i dunno bout the first 2 lines , they were in the code for the swaying arrows i gas given, and i never removed them, but it works fine with them so i just left them in for no reason...Zitat:
Zitat von myschoo
and the 2 last lines as far as i knew are necessary to keep checking what controls are pressed, and are in all the tutorials i have read as far as i remember..... and the code works with them there!
but now that you question them...
They were not in the original code. Go back a page and read carefully, it should beZitat:
Zitat von DtotheK
The way it is now, you are actually never calling screen:clear() but your background is hiding your old screen every cycle so it still works fine, but if you were to break the inner loop (for program exit as an example) you'll be stuck in an infinite black screen loop, so be careful.Code:while true do
screen:clear()
pad = Controls.read()
...rest of code
My bad, got mixed up when i added in all the oldpad stuff...Zitat:
Zitat von KleptoOne
will do, thanks for pointing that out!Zitat:
Zitat von KleptoOne
I got a error for somthing likeAny help im running luaplayer for windows on windows 98, and im just trying to run a simple menu, Any HelpZitat:
C:/luaplayer> luaplayer script.lua:58 error then expected near "="
Post that part of code please.
You need to input a "then" by a "="
-= Double Post =-Zitat:
red = Color.new(255,0,0)
black = Color.new(0,0,0)
white = Color.new(255,255,255)
menustatus = 1
while true do
screen:clear(black)
pad = Controls.read()
if pad:up() then
menustatus = menustatus - 1
screen.waitVblankStart(4)
end
if pad:down() then
menustatus = menustatus + 1
screen.waitVblankStart(4)
end
color={white, white, white, white}
screen:print(50,50,"Road To St. Louis", color[1])
screen:print(50,60,"Exhib ition", color[2])
screen:print(50,70,"Optio ns", color[3])
screen:print(50,80,"Exit" , color[4])
color[menustatus]=red
if menustatus == 1 then
if pad:cross() then
--insert game code here
end
end
if menustatus == 2 then
if pad:cross() then
--insert Exhibition here
end
end
if menustatus == 3 then
-- inserts options here
}
while true do
if up1() and then cursor=cursor-1 end
if down1() and then cursor=cursor+1 end
if cursor==0 then cursor=2 end
if cursor==3 then cursor=1 end
screen:clear(black)
list_options(8,8,options, ">",1,white,red,curso r)
screen:flip()
if cross1() or circle1() then
if cursor==1 then
--Insert Code Here
elseif cursor==2 then
--Insert Code Here
elseif cursor==3 then
--Insert Code Here
elseif cursor==4 then
--Insert Code Here
elseif cursor==5 then
--Insert Code Here
end
end
if menustatus == 4 then
if pad:cross() then
break
end
end
if menustatus <= 0 then
menustatus = 4
end
if menustatus => 5 then
menustatus = 1
end
screen.flip()
screen.waitVblankStart()
end
Opps I forgot to remove some of the Ends to show what the file was like before, ill look at it soon.
-= Double Post =-
Fixed
Um im trying to fix your code via formatting, yet I can't work anything out... Example - why the hell is there a random '}' in the middle there?
Dont you need the options?
-= Double Post =-Code:options = {
"Option 1",
"Option 2"
}
Now that I look at it, Your combining that Menu Status snippet with the list_options example.
Opps i think thats suppose to be a end end there, i had another code in there, but removed it to show what it was like, that explains my newest error. :), i didn't look hard enough and it was 2 am.
-= Double Post =-
Opps i still had some of the extra code in there. From the options, and i removed half of it in the last code heres what it suppose to be.
-= Double Post =-Zitat:
red = Color.new(255,0,0)
black = Color.new(0,0,0)
white = Color.new(255,255,255)
menustatus = 1
while true do
screen:clear(black)
pad = Controls.read()
if pad:up() then
menustatus = menustatus - 1
screen.waitVblankStart(4)
end
if pad:down() then
menustatus = menustatus + 1
screen.waitVblankStart(4)
end
color={white, white, white, white}
screen:print(50,50,"Road To St. Louis", color[1])
screen:print(50,60,"Exhib ition", color[2])
screen:print(50,70,"Optio ns", color[3])
screen:print(50,80,"Exit" , color[4])
color[menustatus]=red
if menustatus == 1 then
if pad:cross() then
--insert game code here
end
end
if menustatus == 2 then
if pad:cross() then
--insert Exhibition here
end
end
if menustatus == 3 then
-- inserts options here
end
end
if menustatus == 4 then
if pad:cross() then
break
end
end
if menustatus <= 0 then
menustatus = 4
end
if menustatus => 5 then
menustatus = 1
end
screen.flip()
screen.waitVblankStart()
end
Okay I think i fixed the error, its now on line 50, no loop near break on the above code
Line 50 area, i know it saying it can't break
Zitat:
if menustatus == 4 then
if pad:cross() then
break
end
end
Remove the break and put something like System.Quit() or os.exit
remove 1 endZitat:
if menustatus == 3 then
-- inserts options here
end
end
1 end from all menu status?
and yes these are from the snippits, im trying them out, and i did have the options in it untill i moved it.
-= Double Post =-
Opps i left out the pad:cross out of the options
Now it should be right.Zitat:
red = Color.new(255,0,0)
black = Color.new(0,0,0)
white = Color.new(255,255,255)
menustatus = 1
while true do
screen:clear(black)
pad = Controls.read()
if pad:up() then
menustatus = menustatus - 1
screen.waitVblankStart(4)
end
if pad:down() then
menustatus = menustatus + 1
screen.waitVblankStart(4)
end
color={white, white, white, white}
screen:print(50,50,"Road To St. Louis", color[1])
screen:print(50,60,"Exhib ition", color[2])
screen:print(50,70,"Optio ns", color[3])
screen:print(50,80,"Exit" , color[4])
color[menustatus]=red
if menustatus == 1 then
if pad:cross() then
--insert game code here
end
end
if menustatus == 2 then
if pad:cross() then
--insert Exhibition here
end
end
if menustatus == 3 then
if pad:cross() then
-- inserts options here
end
end
if menustatus == 4 then
if pad:cross() then
System.Quit()
end
end
if menustatus <= 0 then
menustatus = 4
end
if menustatus => 5 then
menustatus = 1
end
screen.flip()
screen.waitVblankStart()
end
Remove the
and add aCode:screen.waitVblankStart(4)
behind the last vblank at the end of your code.Code:oldpad = pad
Okay so we ended with
Ill go test it.Zitat:
red = Color.new(255,0,0)
black = Color.new(0,0,0)
white = Color.new(255,255,255)
menustatus = 1
while true do
screen:clear(black)
pad = Controls.read()
if pad:up() then
menustatus = menustatus - 1
end
if pad:down() then
menustatus = menustatus + 1
end
color={white, white, white, white}
screen:print(50,50,"Road To St. Louis", color[1])
screen:print(50,60,"Exhib ition", color[2])
screen:print(50,70,"Optio ns", color[3])
screen:print(50,80,"Exit" , color[4])
color[menustatus]=red
if menustatus == 1 then
if pad:cross() then
--insert game code here
end
end
if menustatus == 2 then
if pad:cross() then
--insert Exhibition here
end
end
if menustatus == 3 then
if pad:cross() then
-- inserts options here
end
end
if menustatus == 4 then
if pad:cross() then
System.Quit()
end
end
if menustatus <= 0 then
menustatus = 4
end
if menustatus => 5 then
menustatus = 1
end
screen.flip()
screen.waitVblankStart()
oldpad = pad
end
-= Double Post =-
That gave off another then expected near = error as that is line 56Zitat:
oldpad = pad
if you are using the oldpad technique, then in each keypress if statement you need to do something like:
as for that error it spat out at you i'm not sure why that shouldn't have worked. try putting at the top of your code somewhere:Code:if pad:up() and oldpad:up() ~= pad:up() then ...
i'm not sure if that will fix it or not, i'll do some tests to see if it will real quick thoughCode:oldpad = Controls.read()
-= Double Post =-
ok after thinking about it, i'm not sure why that [then expected near "="] error came up, you would still need that oldpad = Controls.read() at the top of your code somewhere so that it is declared as a controls.read() variable before it is used. otherwise, on the first loop through it wouldn't even be a variable yet.
Same error, just now its on line 70 because of extra coding put in.
Zitat:
pad = Controls.read()
oldpad = pad
currstate="startup"
function printCentered(y, text, color)
local tl=string.len(text)
local xmod = 240-((tl*10)/2)
screen:print(xmod, y, text, color)
end
-----------------
dofile("colors.lua")--contains all color codes, make one yourself
-----------------
screen:clear()
printCentered(131,"Starti ng up...",white)
screen.waitVblankStart(3)
screen.flip()
-----------------------------------------
function mainmenu()
menustatus = 1
while true do
screen:clear(black)
if pad:up() and oldpad:up() ~= pad:up() then
menustatus = menustatus - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
menustatus = menustatus + 1
end
color={white, white, white, white}
screen:print(50,50,"Road To St. Louis", color[1])
screen:print(50,60,"Exhib ition", color[2])
screen:print(50,70,"Optio ns", color[3])
screen:print(50,80,"Exit" , color[4])
color[menustatus]=red
if menustatus == 1 then
if pad:cross() and oldpad:cross() ~= pad:cross() then
--insert game code here
end
end
if menustatus == 2 then
if pad:cross() and oldpad:cross() ~= pad:cross() then
--insert Exhibition here
end
end
if menustatus == 3 then
if pad:cross() and oldpad:cross() ~= pad:cross() then
-- inserts options here
end
end
if menustatus == 4 then
if pad:cross() and oldpad:cross() ~= pad:cross() then
System.Quit()
end
end
if menustatus <= 0 then
menustatus = 4
end
if menustatus => 5 then
menustatus = 1
end
screen.flip()
screen.waitVblankStart()
end
end
---------------------------
screen:clear()
printCentered(131,"Press Start",white)
screen.waitVblankStart()
screen.flip()
if pad:start() and oldpad:start() ~= pad:start() then
currstate="menu"
end
end
----------------------------
if currstate = "menu" then
menu()
end
end
ok. that all worked, and i found out that your error was that you putthat needed to be ">=" ... here is a revised code of it allCode:if menustatus => 5 then
Code:red = Color.new(255,0,0)
black = Color.new(0,0,0)
white = Color.new(255,255,255)
menustatus = 1
oldpad = Controls.read()
while true do
screen:clear(black)
pad = Controls.read()
if pad:up() and oldpad:up() ~= pad:up() then
menustatus = menustatus - 1
end
if pad:down() and oldpad:down() ~= pad:down() then
menustatus = menustatus + 1
end
color={white, white, white, white}
screen:print(50,50,"Road To St. Louis", color[1])
screen:print(50,60,"Exhib ition", color[2])
screen:print(50,70,"Optio ns", color[3])
screen:print(50,80,"Exit" , color[4])
color[menustatus]=red
if menustatus == 1 then
if pad:cross() then
--insert game code here
end
end
if menustatus == 2 then
if pad:cross() then
--insert Exhibition here
end
end
if menustatus == 3 then
if pad:cross() then
-- inserts options here
end
end
if menustatus == 4 then
if pad:cross() then
System.Quit()
end
end
if menustatus <= 0 then
menustatus = 4
end
if menustatus >= 5 then
menustatus = 1
end
screen.flip()
screen.waitVblankStart()
oldpad = pad
end
I use "if pad:cross() and not oldpad:cross()"
Less words, works perfectly.
I put oldpad because somone told me to, earlier, ill test it without it later.
Less words? This less words regardless of the number of buttons wanted:
Code:if oldpad ~= pad then
if pad:cross() then
-- X pressed once
end
end
How would you properly:
Look for a file on memory stick, and do "Action A" If it exists, or do "Action B" if it does not?
file = io.open(ms0:/path)
if file then
-- action a
file:close()
else
-- action b
end
Zitat:
Zitat von myschoo
Cool. Thanks man, turns out i left something out of the file path, and thats why it wasn't working. :P
Thanks for the reply. :)
Gah now i can't this to leave my image sportz.jpg, any help?
Zitat:
black = Color.new(0,0,0)
pad = Controls.read()
white = Color.new(255,255,255)
--------------
function printCentered(y,text,colo r)
local length = string.len(text)
local x = 240 - ((length*8)/2)
screen:print(x,y,text,col or)
end
--------------
function scaleImage(newX, newY, theImage)
resizedImage = Image.createEmpty(newX, newY)
for x = 1, newX do
for y = 1, newY do
resizedImage:blit(x,y , theImage,
math.floor(x*(theImage:wi dth()/newX)),
math.floor(y*(theImage:he ight()/newY)),1,1)
end
end
return resizedImage
end
--------------
screen:clear(black)
printCentered(131,"Starti ng up...",white)
screen.waitVblankStart(3)
screen.flip()
--------------
sportz = Image.load("sportz.jpg")
-------------
scaleImage(480,272, sportz) -- Resize image.
while true do
screen:blit(0,0, resizedImage) -- Show the resized image
screen.waitVblankStart(3)
screen.flip()
currstate="ready"
end
--------------
pad=Controls.read()
screen:clear(black)
if currstate=="ready" then
screen:clear()
printCentered(100,"Press Start",white)
printCentered(300,"Powere d by Sportz",white)
screen.waitVblankStart()
screen.flip()
if pad:start() then
dofile("menu.lua")
end
end
English please? I don't understand what that means.Zitat:
leave my image sportz.jpg
with this code here:i beleive you have to do :Code:scaleImage(480,272, sportz) -- Resize image.
then when you blit the image, instead of trying to blit "resizedImage" you have to put "somevariable" or whatever name you chose.Code:somevariable = scaleImage(480,272, sportz)
this is because when you return a value in a funtion, you need a variable to return it to, so you do: variable = function()
It means that it stays stuck on my image sports.jpg, or it won't leave my img.Zitat:
Zitat von Anti-QuickJay
-= Double Post =-
I added the variable into the screen blit, and fixed around it, but it still stays stuck on my image.
resize the image manually! you are using functons from evilmana and u dont even know how do they work ... >_>
well how big is sportz.jpg originally? because if it is bigger than 512x512 then it wouldn't load in the first place.
The origenal is 600 x 150 pixels, it loads it just won't switch to current state ready, ill try to figure it out on my own.
-= Double Post =-
I fixed it.
Had the end, end something i neededZitat:
black = Color.new(0,0,0)
pad = Controls.read()
white = Color.new(255,255,255)
--------------
function printCentered(y,text,colo r)
local length = string.len(text)
local x = 240 - ((length*8)/2)
screen:print(x,y,text,col or)
end
--------------
function scaleImage(newX, newY, theImage)
resizedImage = Image.createEmpty(newX, newY)
for x = 1, newX do
for y = 1, newY do
resizedImage:blit(x,y , theImage,
math.floor(x*(theImage:wi dth()/newX)),
math.floor(y*(theImage:he ight()/newY)),1,1)
end
end
return resizedImage
end
--------------
screen:clear(black)
printCentered(131,"Starti ng up...",white)
screen.waitVblankStart(3)
screen.flip()
--------------
sportz = Image.load("sportz.jpg")
-------------
sportzimg = scaleImage(480,272, sportz) -- Resize image.
while true do
screen:blit(0,0, sportzimg, false) -- Show the resized image
screen.waitVblankStart(30 0)
screen.flip()
--------------
pad=Controls.read()
screen:clear(black)
screen:clear()
printCentered(100,"Press Start",white)
printCentered(200,"Powere d by Sportz",white)
if pad:start() then
dofile("menu.lua")
end
screen.waitVblankStart()
screen.flip()
end
best place to go if u want to learn about Lua coding http://luaplayer.org/forums/index.php?topic=20.0
hi this code here:(by the way it relates to my game without showing it yet)Code:count = 5
white = Color.new(255,255,255)
function display()
screen:print(140, 248, count, white)
end
for count = 1, 5 do
while true do
screen:clear()
pad = Controls.read()
display()
if pad:square() and oldpad:square() ~= pad:square() then
oldpad = pad
break
end
oldpad = pad
screen.flip()
screen.waitVblankStart()
end
end
basically i wanted a for loop that would decrease a variable, and show it using the display() function. I just wanted to know if anyone could tell me the specifics on why it never displays count decreasing.
i found ways around it, but just want to know why it doesn't.
Thats a lie.Zitat:
Zitat von johnjohnfroboy
Its http://www.lua.org/manual/5.1/