Lua Programming Help Thread
This is a discussion on Lua Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; this is what i found online: *a - reads the entire file from the current position. ex: file.read("*a") so i ...
-
09-25-2007, 04:01 PM #8041
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
-
10-13-2007, 07:16 AM #8042QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
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.Geändert von Nielkie (10-13-2007 um 07:30 AM Uhr)
-
10-14-2007, 09:09 PM #8043QJ Gamer Blue
- Registriert seit
- Sep 2007
- Beiträge
- 53
- Points
- 3.280
- Level
- 35
- Downloads
- 0
- Uploads
- 0
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 helpGeändert von BJ2 (10-14-2007 um 10:21 PM Uhr)
-
10-14-2007, 09:58 PM #8044words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
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
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
10-14-2007, 10:31 PM #8045QJ Gamer Blue
- Registriert seit
- Sep 2007
- Beiträge
- 53
- Points
- 3.280
- Level
- 35
- Downloads
- 0
- Uploads
- 0
thanks, but it still doesn't work, i even tried to copy and paste the code you wrote. i also fixed the
so 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
-
10-14-2007, 11:00 PM #8046words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
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.

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
10-16-2007, 04:37 AM #8047QJ Gamer Blue
- Registriert seit
- Sep 2007
- Beiträge
- 53
- Points
- 3.280
- Level
- 35
- Downloads
- 0
- Uploads
- 0
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,
thanksGeändert von BJ2 (10-16-2007 um 06:10 AM Uhr)
-
10-16-2007, 02:43 PM #8048lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
-
10-23-2007, 06:13 PM #8049
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. :/
-
10-24-2007, 12:23 AM #8050QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
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.
-
10-24-2007, 03:31 AM #8051
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 von Highsight
-
10-24-2007, 08:19 AM #8052
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 von Nielkie
-
10-24-2007, 12:51 PM #8053Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
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
--------------------------------------------------------------------------------------
-
10-24-2007, 01:20 PM #8054
Sadly, that is what I've been trying to do, I guess it doesn't support depth testing. :/
Zitat von Grimfate126
-
10-24-2007, 03:34 PM #8055QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
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?
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
10-24-2007, 04:37 PM #8056
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.
-
10-24-2007, 06:56 PM #8057QJ Gamer Silver

- Registriert seit
- Oct 2006
- Ort
- Pimp'en in the US F#
- Beiträge
- 1.254
- Points
- 7.278
- Level
- 56
- Downloads
- 0
- Uploads
- 0
whoops, wrong topic :S sorry
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
10-27-2007, 07:59 AM #8058
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 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
-
10-31-2007, 09:41 AM #8059
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? :/
-
10-31-2007, 01:09 PM #8060
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)"
-
11-01-2007, 08:36 AM #8061
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!
-
11-01-2007, 02:14 PM #8062
about the only thing I can think of for that is to mess around with the z coords inside the model table
-
11-02-2007, 08:38 AM #8063
HAHA! That did it! I just made the z values 1000000000000000000. Thanks so much Merick! Expect your name in my MazeGen credits. ;)
-
11-02-2007, 12:09 PM #8064
Is it possible to play a sound when you hit a button.
-
11-02-2007, 12:15 PM #8065Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
yes it is
-
11-02-2007, 02:12 PM #8066Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
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
rint = 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 !!!!!!!!!------ FaT3oYCG -----
AKA Craig, call me what you want to It's your preference.
My Website: http://www.modern-gamer.co.uk/
Currently working on:
(0) MediaGrab
(0) PGE Gears Of War - On hold (Very large project).
(0) PS???? -On Hold A tactical 2d side scrolling game involving AI and online multiplayer features. - Tile engine nearley finished (1 bug to fix).
-
11-02-2007, 02:45 PM #8067lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
You can compile your LUA scripts into C files? How? :ROFL:
Zitat von FaT3oYCG
-
11-02-2007, 03:44 PM #8068
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
-
11-02-2007, 04:43 PM #8069
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.
-
11-02-2007, 05:34 PM #8070QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Can't you code it yourself, it'll take like 5 lines.


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum