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; So, to reiterate, no one has any idea how I can turn the screen object into an image?...
-
01-15-2008, 10:25 AM #8281
So, to reiterate, no one has any idea how I can turn the screen object into an image?
-
01-15-2008, 11:19 AM #8282Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
the only way that has been mentioned by me and others that we know of is to screen:save() the screen load the image and use that
Zitat von Highsight
there may be another way but as i suggested it may work if you use a blank image as the screen
myscreen = image.createempty(480, 272)
then
myobject = myscreen
may work may not
otherwise the only way we know of is to save the image------ 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).
-
01-15-2008, 02:35 PM #8283
FaT3oYCG, that's almost correct.
The screen is already an image object(although of a special type), and any image can be blitted into another image:
scrncap = image.createempty(480, 272)
scrncap:blit(0, 0, screen)
One thing though, with some versions of luaplayer this won't always work if you are using the gu to draw some of the graphics
-
01-15-2008, 04:21 PM #8284
Wow, thanks FaT3oYCG for doing that for me - i will look over it and take your advice.
Many thanks, that must have taken you a lot of time.
Will keep you updated as soon as i get time to write some more!
Oh, and one other thing - can anyone please reccomend me an IDE to i dont have to keep transferring my scripts to the PSP and rebotting it when it crashes (which happens allot!)?
Many thanks!Geändert von Andysan (01-15-2008 um 04:32 PM Uhr)
-
01-16-2008, 03:20 AM #8285
Ohhh, so close. I already tried this once and I ended up getting an: "Image Expected, got Table" error. >_< Thanks anyway guys, I guess I'll just have to settle for a fading effect. :)
Zitat von Merick
-
01-16-2008, 03:39 AM #8286
That error is just because I forgot to capitalize a couple of letters: image.createempty instead of Image.createEmpty
-
01-16-2008, 09:36 AM #8287
Er, when I did it I capitialized it correctly. :P It is giving me that error when I am blitting. ;) Here's the exact code:
Zitat von Merick
And the error:Code:zoomOut = Image.createEmpty(480,272) --Line 115 zoomOut:blit(0,0,screen) --The Offending Line (Line 116)
If I were to guess, screen is a structure, and the image is some sort of variable in the structure, the only problem is, I don't know the variable name. Does anyone know a way I could find out what the variable name is? I ran a table.getn on the screen objects, it has 0 elements. >_<Code:error: INDEX.LUA:116: bad argument #2 to 'blit' (Image expected, got table) Error: No script file found. Press start to restart
-
01-16-2008, 09:47 AM #8288Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
i explained why you cant do something like that in one of my other posts read over it again
------ 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).
-
01-16-2008, 01:36 PM #8289QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Code:copyofscreenimage = screen screen:blit(0,0,copyofscreenimage)
-
01-16-2008, 02:17 PM #8290
we must be using different versions of lua player, it works in 0.20
As for screen, it's not a table but is what in lua terms is called userdata. Basically, instead of being a reference to data held inside the luaVM, a userdata object is a pointer to a memory structure that is controlled by the underlying (non-lua) code of the interpreter. The screen functions (clear, flip, etc...) are not regular table elements as such, but are instead what are called metamethods, which is why they don't show up with table.getnGeändert von Merick (01-16-2008 um 02:35 PM Uhr)
-
01-17-2008, 02:49 PM #8291Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
following that up as i tried to explain
Zitat von Merick
think of the screen as a box not a table the items are put in the box but not in a specific order the items are not put in any particular location in the box but the location where they are placed is remembered by the screen - basically the memory adress
we can use the items from the screen but as they are not layed out in any specific order we cannot class the screen as one object as it contains these items
thanks------ 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).
-
01-17-2008, 03:41 PM #8292QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Umm, no.
In the PSP Luaplayer, the screen is a variable which acts as both a table and an image - most often an image in functions like screen:clear() and screen:blit(), but as a table in screen.flip() and screen.waitVblankStart(). Your attempt to explain it makes no sense at all, and I'm sure merick understands how the screen variable works anyways - he's made some good stuff.
-
01-17-2008, 03:52 PM #8293Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
ok i seem to be getting an error hen trying to use luaplaer on my pc, never tried this before so im not sure what im doing wrong heres the error message:

so i guess if someone could tell me how im supposed to work this thing lol that would be great :)**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
01-17-2008, 04:07 PM #8294QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
1. Get PSP and USB cable
2. Plug USB cable into computer and PSP
3. Put your script on your PSP and run it on the luaplayer it's meant to be run on instead of the windows one that leaves out many functions and is buggy and is an emulator in the first place.
4. Don't use windows luaplayer because it gets errors that have no fix/are related to bad code in general/require rewriting your script
-
01-17-2008, 04:11 PM #8295Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
wow thnx for the useless post.
i didnt ask an opinion, i can use the luaplayer on my psp but id rather use the one for windows. so if anyone can help me get it to work that would be great :)
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
01-17-2008, 04:24 PM #8296lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Listen to him.
Zitat von %chrono trigger%
It wasn't an opinion, its facts. LuaPlayer for windows sucks and is incomplete. you miss alot of functions. Just run it on LuaPlayer for your PSP.
-
01-17-2008, 04:26 PM #8297Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
i did and he explained how to play a script on my psp well thats really not what i want so for arguments sake i dont have a psp. how then would i get lua player for windows to work on my pc?
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
01-17-2008, 04:33 PM #8298lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
First you say you can use it on your PSP, now you say you dont have a PSP.
Well, I don't know what that error means.
Maybe your using code that isn't in LuaPlayer for windows?
-
01-17-2008, 04:36 PM #8299Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
lol i said i didnt have a psp so that we would not begin something that need not be started hence the phrase "for arguments sake". anyway is there a guide you all know of for it then?
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
01-17-2008, 04:39 PM #8300lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
mhmm.
Zitat von %chrono trigger%
Well, I dont think their is a guide as I never saw one but why not google it?
-
01-17-2008, 04:41 PM #8301Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
i have and did not find a definite answer that i liked so i thought mybe the nice people at qj might know
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
01-18-2008, 09:47 AM #8302Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
alright srry for the double post, but i think ill get a better answer to my questionthis way
theres my code and my problem is i traded my phat psp for a slim this code above was working on my 3.71m33-4 phat psp, but it wont work now on my slim 3.80m33-4. My question is is it because of my firmware or type of psp that it wont run? By the way there are no error messages just a black screen, and to my knowledge i havent change the code. So any help is appreciatedCode:System.usbDiskModeActivate() red = Color.new(0,0,255) green = Color.new(0,255,0) ground = Image.createEmpty(480,5) ground:clear(green) oldpad = Controls.read() currentBullet = 0 direction = "right" floor = Image.load("background.png") pic1 = Image.load("enemy.png") pic2 = Image.load("pic2.png") shell = Image.load("bullet.png") Floor = {} Floor.x = 0 Floor.y = 0 Pic = { } Pic[1] = { x = 286, y = 107} Mine = { } Mine[1] = { x = 275, y = 143, h = pic2:height(), w = pic2:width() } Pic = { } Pic[1] = { x= 286, y = 107, h = pic1:height(), w = pic1:width() } Player = {} Player[1] = { oldx = 50, oldy = 107 } Player.gravity = 107 Player.y = 10 Player.x = 20 Player.jumpspeed = 10 Player.jumpstate = "ground" Player.weapon = "gun" Player.img = { ["gun"] = Image.load("player_gun.png"), ["none"] = Image.load("player.png"), ["flame"] = Image.load("player_flame.png"), ["machine"] = Image.load("player_machine.png"), ["crouch"] = Image.load("player_crouch.png"), ["kneel"] = Image.load("player_crouch2.png")} BulletInfo = {} BulletInfo[1] = { pic = shell, firing = false, direction = "right", x = Player.x + 32, y = Player.y + 16, h = shell:height(), w = shell:width() } playerHeight = 90 playerWidth = 90 function movePlayer() pad = Controls.read() if pad:left() then Player.x = Player.x - 1 end if pad:right() then Player.x = Player.x + 1 end end Player.x = Player[1].oldx Player.y = Player[1].oldy function bulletSetup() if direction == "left" then BulletInfo[1].x = Player.x BulletInfo[1].y = Player.y + 16 end if direction == "right" then BulletInfo[1].x = Player.x + 32 BulletInfo[1].y = Player.y + 16 end BulletInfo[1].direction = direction BulletInfo[1].firing = true end function bulletFire() if BulletInfo[1].firing == true then if BulletInfo[1].direction == "right" then BulletInfo[1].x = BulletInfo[1].x + 10 end if BulletInfo[1].direction == "left" then BulletInfo[1].x = BulletInfo[1].x - 10 end screen:blit(BulletInfo[1].x,BulletInfo[1].y,BulletInfo[1].pic) end if BulletInfo[1].x < 0 or BulletInfo[1].x > 480 then BulletInfo[1].firing = false end end alpha = true while true do pad = Controls.read() screen:clear() screen:blit(0,262,ground) screen:blit(Floor.x, Floor.y,floor) screen:blit(Pic[1].x,Pic[1].y,pic1) screen:blit(Player.x,Player.y,Player.img[Player.weapon]) if pad:left() and Player.x > 0 then Player.x = Player.x - 2 end if pad:right() and Player.x < 480 then Player.x = Player.x + 2 end if pad:up() then Player.weapon = "kneel" end if pad:down() then Player.weapon = "crouch" end if pad:r() then Player.weapon = "gun" end if pad:l() then Player.weapon = "machine" end if pad:cross() and Player.jumpstate == "ground" then Player.jumpstate = "jumping" end if Player.jumpstate == "jumping" then Player.jumpspeed = Player.jumpspeed - 0.5 Player.gravity = Player.gravity - Player.jumpspeed end if Player.gravity < 0 then Player.jumpstate = "falling" end if Player.gravity < 107 and Player.jumpstate == "falling" then Player.gravity = Player.gravity + (Player.jumpspeed + 3) end if Player.gravity == 107 then Player.jumpspeed = 10 Player.jumpstate = "ground" end if Player.gravity > 107 then Player.gravity = 107 end Player.y = Player.gravity if Player.x == 380 then screen:print(200,80,"you beat level 1") screen.flip() screen.waitVblankStart(40) screen:clear() end if Player.x == 286 then Player.x = Player[1].oldx Player.y = Player[1].oldy and screen:print(210,80,"you lost") screen.flip() screen.waitVblankStart(30) screen:clear() end if pad:circle() and oldpad:circle() ~= pad:circle() then bulletSetup() end bulletFire() screen.waitVblankStart() screen.flip() oldpad = pad end**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
01-18-2008, 10:29 AM #8303Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
here is my copy of luaplayer for windows that works
- put all of your files for that project in the luaplayer 0.20 for windows folder edit the basic.cmd the open the main file of your project and double click basic.cmd it will run if it has an error it will show you it and if not carry on working this folder works on my computer so i dont see why it wont work on yours here you go
DL LINK------ 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).
-
01-19-2008, 09:41 AM #8304Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
hi guys i am making myself an osk - (on screen keyboard), and since i changed some of the variables i now get an error where there previously wasn't one
here is the problematic area of code
the problem arises on the first screen:print()Code:function keyb_draw(text_colour) screen:blit(107, 98, bg) screen:blit(currentX,currentY, selector) character_X = 100 character_Y = 100 for a = 1, 3 do add_width = 0 add_height = add_height + 10 add_row = add_row + 9 for b = 1, 9 do add_width = add_width + 10 if mode == 1 then screen:print(character_X + add_width, character_Y + add_height, characters[b + add_row], text_colour) elseif mode == 2 then screen:print(character_X + add_width, character_Y + add_height, string.upper(characters[b + add_row]), text_colour) elseif mode == 3 then screen:print(character_X + add_width, character_Y + add_height, symbols1[b + add_row], text_colour) elseif mode == 4 then screen:print(character_X + add_width, character_Y + add_height, symbols2[b + add_row], text_colour) end end end add_width = 0 add_height = 0 add_row = 0 end
here is the error
error: osk.lua:54: bad argument #2 to 'print' (string expected, got nil)
- the reason i changed the variable names was to make it easier for me to understand and so that i can make it function dependent so it can be easily implemented into an lua file
anyway any help appreciated thanks------ 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).
-
01-19-2008, 09:08 PM #8305QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Looking at this screen
rint():
With arg #2 being nil (arg count actually starts at 0 so arg # 2 is the third item, the string to be printed) I'd think either the characters table is not created (but I think if that were the case the error would relate to attempting to access an index) or the sum of b and add_row is greater than the number of items in the characters table. Basically, it's a problem with the letter it tries to print not existing.Code:screen:print(character_X + add_width, character_Y + add_height, characters[b + add_row], text_colour)
-
01-20-2008, 03:46 AM #8306Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
thanks turtles i fixed it myself last night but you were spot on as the program itterates over the character table i had it set to add 9 characters every row baically but it started at 9 for a reason i cant figure out so i just set it to - 9 and the other variable the height to - 10 to print in the right area
Zitat von TurtlesPwn
thanks------ 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).
-
01-25-2008, 05:34 AM #8307
Some of the Flash0 folders are hidden in 3.80 fw.
Which is messing my Flasher up, because it will not recognize the hidden "module" folder, so it's writing to the "podule" folder instead.
Ive tried defining the file path... That did not work...
Tried writing to an alternate folder, then renaming the folder to "module"... Just got an error from that...
Any ideas ??
Thanks
~
shizzyPSP: PSP SLIM 2001 TA-088v2Custom Firmware: 5.00 M33-6
-
01-25-2008, 10:28 AM #8308Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Sort out your code.
Zitat von %chrono trigger%
And it's pointless trying to code for something that you don't actually own.
-
01-25-2008, 03:31 PM #8309
Being hidden doesn't mean anything. That's just an attribute that Windows recognizes and hides the file. It in no way effects the PSP.
Zitat von Mr_Shizzy
[IMG]http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Zoso.svg/744px-Zoso.svg.png[/IMG]
Looking for some good C programming tutorials for the PSP? Look no further! [URL="http://psp-coding.com/"]PSP-Coding.com[/URL] is your source for all your PSP coding needs.
-
01-25-2008, 03:56 PM #8310QJ Gamer Platinum
- Registriert seit
- Dec 2005
- Ort
- h0000000rj
- Beiträge
- 12.867
- Points
- 57.528
- Level
- 100
- Downloads
- 0
- Uploads
- 0
err... except that sometimes, it does. sometimes it acts like the files aren't even there.
[I fail @ life]


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