this is what i found online:
*a - reads the entire file from the current position. ex: file.read("*a")
so i don't know what went wrong for you
Printable View
this is what i found online:
*a - reads the entire file from the current position. ex: file.read("*a")
so i don't know what went wrong for you
For anyone who cares and develops in KDevelop,Kate,KWrite or KEdit, I have added all the PSP LuaPlayer functions to the SVN (much better than the default(which doesn't even support block comments or code collapsing) ) syntax highlighting script.
Put the lua.xml of your choice in ~/.kde/share/apps/katepart/syntax/ or /opt/kde/share/apps/katepart/syntax/ (depending on your distribution)
Please post any suggestions/problems/comments.
hello, i have only just started learning lua yesterday and am VERY new to it so please don't be harsh.
i try to add a background to my simple text and it doesn't work, this is my lua script:
i know that this is probably i very easy answer for most of you but it isn't working for me and i need to know why. i have a 480 by 272 pivture in the same folder called background and it is a .PNG pictureCode:red = Color.new(255, 0, 0)
blue = Color.new(0, 0, 255)
green = Color.new(0, 255, 0)
white=Color.new(255,255,255)
background = Image.load("background.png")
screen.flip()
screen.waitVblankStart()
screen:print(130, 130, "background", white)
screen:print(100, 200, "SUPID BACKGROUND ISN'T WORKING!!!", red)
screen.flip()
while true do
screen.waitVblankStart()
end
thanks for the help
Aye, it is a simple mistake. Common among new developers as the tutorials are misleading (IMO). There are a few mistakes ultimately making it not do as you wish. For one, you aren't ever really blit'ing the image ,rather just loading it into the var 'background' and printing the var's name ;). Secondly, you have an even number of screen.flip()'s therefore making anything you wish to actually display 'hidden'. It's best to only have 1 screen.flip() and 1 screen.waitVblankStart() (unless you have specific needs for them). Since you aren't doing anything needing to continually check for something, you just need an indefinate delay at the end, nothing more :)
P.S. Use [ code][/ code] tags as well, they prevent smilies and preserve tabs) And yeah, if you do get flamed, it's no biggie, ask one of the vet's to look over the situation to see what's really what ;)Code:red = Color.new(255, 0, 0)
blue = Color.new(0, 0, 255)
green = Color.new(0, 255, 0)
white=Color.new(255,255,255)
background = Image.load("background.png")
screen:blit(0,0,background)
screen.waitVblankStart()
screen.flip()
while true do
end
thanks, but it still doesn't work, i even tried to copy and paste the code you wrote. i also fixed theso there was a space between the = and the C.Code:white =Color.new(255, 255, 255)
btw, im using "luaplayerwindows-0.20"
lua for the computer. i dont yet know how to make it an eboot
What's your error exactly? You probably don't have the background.png in the same folder. The space between the = and C isn't an error. And you don't make Lua scripts into EBOOTs ;) You get the Lua Player for PSP and run the script just like on windows.
kk, thaks a bunch for the help SG57. i finaly figured out how to fix, it was i nooby mistake of having the pic a different format to what i wrote.
thanks again :)
and i figured out my lua for PC doesn't work (can't do anything except text on a black background :( ), cause the exact thing works on my psp.
anyone got a link to a Lua player for PC that works properly,
thanks
Does anyone know how I can blit 25 10x10 images over 3D objects? For some reason, whenever I try to do it, it goes behind the 3D model. :/
I don't think you can. However you can compromise by bliting the Image as a 3D model (two textured triangles)
That problem will be fixed in the next version of Lua Player.
I don't know anything about 3D yet, but I would guess that you just have to make sure you're blitting the images after you blit your textures.Zitat:
Zitat von Highsight
That sounds like it could work fine, the only problem is I need to ensure that it stays exactly in the top left corner of the screen, rather than staying somewhere on the 3D plane. Any suggestions on how I could do that?Zitat:
Zitat von Nielkie
i dunno if lua supports depth testing, but try this: (this is the 'traditional' way to do in in the GU)
1. turn depth test on
2. do all 3d stuff
3. turn depth test off
4. blit image to top right corner.
done :D
Sadly, that is what I've been trying to do, I guess it doesn't support depth testing. :/Zitat:
Zitat von Grimfate126
Where can i get information on how to compile the oslib(oldschool library) on windows? ive searched the docs and googled it to the bone, any body know?
Shouldn't that question be in C help? Anyway, there's probably some documentation in the readme. If not, check the Makefile, it'll be there.
whoops, wrong topic :S sorry
If you leave out the Gu.translate statement when drawing the image, then the coordinates in the model table will be relative to the top corner instead of the center of the screen. For an example, take a look at this function (the gu start and end calls aren't use inside the function because if you use this to draw a lot of images it works faster to start and stop the gu before and after doing all the calls to this function):Zitat:
Zitat von Highsight
Code:function Gu.blit(x, y, image, scale, flip)
if scale then
if type(scale) == "string" then
flip = scale
scale = 1
else
scale = (scale/100)
end
end
if flip then
if flip == "H" then
x_start = image:width()
y_start = 0
x_end = 0
y_end = image:height()
elseif flip == "V" then
x_start = 0
y_start = image:height()
x_end = image:width()
y_end = 0
elseif flip == "HV" then
x_start = image:width()
y_start = image:height()
x_end = 0
y_end = 0
end
else
x_start = 0
y_start = 0
x_end = image:width()
y_end = image:height()
end
temp = {
{x_start, y_start, x, y, 0},
{x_end, y_end, (image:width()*scale)+x, (image:height()*scale)+y, 0}
}
Gu.enable(Gu.TEXTURE_2D)
Gu.texImage(image)
Gum.drawArray(Gu.SPRITES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_2D, temp)
end
Well, in that case, it looks like that function you just posted should do it! But I must be using it wrong, whenever I try to use it, nothing shows up. when I use it I enter in "Gu.blit(0, 0, (image name), 100, false)"
Did I do something wrong? :/
The last argument, "flip" is not a boolean, it takes one of 3 strings: "H" to flip horizontal, "V" to flip vertical, and "HV" to flip it both ways. If you don't want to flip the image just leave it out: "Gu.blit(0, 0, (image name), 100)"
Ok, I figured it out, I just had it outside of the gu.start method. XD It is almost working, it is bliting as a 3D object with a texture, but it is still behind all the other 3D objects. Any ideas how to fix that? As soon as that is done, it will all work!
about the only thing I can think of for that is to mess around with the z coords inside the model table
HAHA! That did it! I just made the z values 1000000000000000000. Thanks so much Merick! Expect your name in my MazeGen credits. ;)
Is it possible to play a sound when you hit a button.
yes it is
request - conversions
i would like as many people as possible to help with this
i would like and and all of the conversions for lua code to c and vice versa
e.g.
screen:print = pspDebugScreenPrintf
and so on for a program that i am makeing to help people who know lua to learn c as i do not yet know c myself i cannot convert them all and even if i could i would probably forget some
the program will help people who know lua to learn c and even if they dont want to lean it it will help them to compile their lua programs into c code
which would be useful for every one and more people would learn lua and c
please if you have any conversions for me or have any suggestions of how to do some of the conversions please pm me !!!!!!!!!
You can compile your LUA scripts into C files? How? :ROFL:Zitat:
Zitat von FaT3oYCG
I'm don't know how to do this with C, however on the FreeBasic messageboard one of the guys posted a macro that will cause a file (of any type) to be compiled into the exe. When the program is run, the data from that file is loaded into a memory buffer. Using this, I was able to compile some scripts into my FreeBasic programs and run them with lual_loadbuffer and lua_pcall
CAn some one put the code for have a sound play when i push a button and an ohther one when i push another button.
Can't you code it yourself, it'll take like 5 lines.
load sound
if pad cross then
play sound1
elseif pad circle then
play sound2
end
ehh... I usually don't help people who ask for code as basic as this, but it was just too easy to mash up...
Code:sound1 = Sound.load("sound1.wav",false)
sound2 = Sound.load("sound2.wav",false)
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:print(10,10,"Press X for first sound, and O for the second")
if ((pad:cross() ~= oldpad:cross()) and pad:cross()) then sound1:play() end
if ((pad:circle() ~= oldpad:circle()) and pad:circle()) then sound2:play() end
oldpad = pad
screen.waitVblankStart()
screen.flip()
end
Tanks a lot.
Does "sound1:play" really work? I made a cleaner alternative, removed unnecessary "(" and ")"s.Zitat:
Zitat von Nielkie
I may not have to be this way, but i think it's a cleaner alternative, since LUA don't need the highlighted ones "if (something) then"Code:sound1 = Sound.load("sound1.wav",false)
sound2 = Sound.load("sound2.wav",false)
oldpad = Controls.read()
while true do
pad = Controls.read()
screen:print(10,10,"Press X for first sound, and O for the second")
if pad:cross() ~= oldpad:cross() and pad:cross() then sound1:play() end
if pad:circle() ~= oldpad:circle() and pad:circle() then sound2:play() end
oldpad = pad
screen.waitVblankStart()
screen.flip()
end
Also the "sound1:play", it may not need the "sound1:play()" but i think it's a lot less confusing.
Sorry, I have got a habit of over-bracketing my code. Oh, and yeah, it is : play().
Does anyone here have any experience with the 3D lighting functions?
ive been working on a horizontal scrolling shooting for a couple of days now and have run into a problem. i want to create another enemy after 1-2 seconds. ive looked at the timer tutorials at evilmana.com but cant get them to work. anyone know what to do?
Zitat:
Zitat von drag_93
A basic timer goes like this:
yourtimer = timer.new(0)
This creates a new timer.
Next, you must create a variable to hold the current time.
yourtime = yourtimer:time()
This must be put in your main loop - to update every frame.
Next, you must start the timer.
yourtimer:start()
To stop the timer you have:
yourtimer:stop()
And you can reset the timer to 0 like this:
yourtimer:reset(0)
Now, you can do this:
If yourtime >= 1000 then
enemy.new()
yourtimer:reset(0)
end
thanks
could someone help me figure out why this doesnt work please
i dont have much time to work on things at the moment and this is taking too long to work out
ALL help appreciated thanks
i know i have a few extra ends in there at the moment but the main error araises before thatCode:-- image resizer
-- either the file name or variable that holds file name
origpic = Image.load(browserbg.png)
-- either the file name or variable that holds file name
-- creates an empty variable that holds the values that need to be resized
resize = ""
-- creates an empty variable that holds the values that need to be resized
-- creates an empty variable that stores the picture to be used
pictouse = ""
-- creates an empty variable that stores the picture to be used
-- will check if the image needs to be resized
-- if not it will skip the resize process
-- if it does it will check the height, width or both height and width
function sizecheck()
if
origpic:height() > 240 -- set to the largest x value wanted
or
origpic:width() > 230 -- set to the largest y value wanted
then
resizecheck()
else
pictouse = screen:blit(244, 37, origpic)
end
end
-- end of size check function
rvx = 0
rvy = 0
-- resize check value - checks which values need to be resized
-- for example if the x is bigger than the y then the x will be
-- the value to be checked to see if the new image is small enough
-- and vice versa if they are the same then the x valuse will be used
function resizecheck()
if
origpic:height() > origpic:width()
then
resize = y
elseif
origpic:width() > origpic:height()
then
resize = x
elseif
origpic:height() == origpic:width()
then
resize = x
end
resizevalues()
end
-- end of resizecheck function
-- stores the new x and y values
function resizevalues()
if
resize == x
then
rvx = origpic:width() / 2
rvy = origpic:height() / 2
until
rvx < 240 -- set to the largest x value wanted
elseif
resize == y
then
rvx = origpic:width() / 2
rvy = origpic:height() / 2
until
rvy < 230 -- set to the largest y value wanted
end
end
end
resizepicture(rvx, rvy, origpic)
end
-- stores the new x and y values
-- creates a new version or the image that you have resized
function resizepicture(newx, newy, theimage)
newpicture = Image.createEmpty(newx, newy)
for
thex = 1, newx
do
for
they = 1, newy
do
newpicture:blit(thex, they , theimage, math.floor(thex * (theimage:width() / newx)), math.floor(they * (theImage:height() / newy)), 1, 1)
end
end
return pictouse = newpicture
end
-- creates a new version or the image that you have resized
function blitpic()
pictouse
end
while true do
blitpic()
the error message is
line 64 'end' expected (to close 'if' at line 59) near 'until' but if you look i dont want to end it there
thanks