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; 1) If i clear the screen and make it white, then blit a transperent image on it, and take a ...
-
02-23-2007, 08:17 AM #5791
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
1) If i clear the screen and make it white, then blit a transperent image on it, and take a screen shot will the screen shot be transperent.
2) As for enycryption, could I do something like this:
3) How can I select characters from a txt file from a txt file like maybe the third letter in a txt file. So i want something like this:Code:if VAR == 4 then VAR = "B" end
The "i don't know what goes here" will be the third letter in the txt file.Code:if (i dont what goes here) == "3" then whatever end
-
02-23-2007, 09:17 AM #5792
No, the screen can never have a transparent value.
Zitat von pspfreak9
Yes, but make sure you make the "B" a 4
Zitat von pspfreak9
whatever = string.sub(file:read(3),3 ,3)
Zitat von pspfreak9
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-23-2007, 09:23 AM #5793QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- London, United Kingdom
- Beiträge
- 131
- Points
- 4.812
- Level
- 44
- Downloads
- 0
- Uploads
- 0
2)I had thought about using BASE64 or ROT13 as a method of obfuscation.
Though I have never attempted it as obfuscation. BASE64 is already being used
-
02-23-2007, 09:32 AM #5794
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Ok thanks but can you explain the line of code i bolded, and underlined plz.
Zitat von youresam
-
02-23-2007, 10:30 AM #5795
file:read(3) will return 3 characters from the text file
and Im telling it to take from character 3 to character 3 of that string.
you could also do:
file:seek("set",3)
whatever = file:read(1)牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-23-2007, 10:54 AM #5796
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Ok, I get it thanks youresam.
-= Double Post =-
Are there any tuts on LUA file io anywhere?
-= Double Post =-
any1...Geändert von pspfreak9 (02-23-2007 um 08:13 PM Uhr) Grund: Automerged Doublepost
-
02-24-2007, 08:14 AM #5797Look 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 really could use sme help getting this fixed dont have a clue how to fix it the error is at the bottom
heres the code:
the exact error says: script.lua:47: calling 'blit' on bad self (number expected, got nil)Code:System.usbDiskModeActivate() red = Color.new(225,0,0) player = Image.load("player.png") background = Image.load("background.png") pic1 = Image.load("pic1.png") pic2 = Image.load("pic2.png") Pic = { } Pic[1] = { x= 80, y = 95, h = pic1:height(), w = pic1:width() } Player = { } Player[1] = { x = 50, y = 107, h = player:height(), w = player:width() } screenwidth = 480 - player:width() screenheight = 272 - player:width() playerHeight = 90 playerWidth = 90 function movePlayer() pad = Controls.read() if pad:left() then Player[1].x = Player[1].x - 1 end if pad:right() then Player[1].x = Player[1].x + 1 end if pad:up() then Player[1].y = Player[1].y - 1 end if pad:down() then Player[1].y = Player[1].y + 1 end end function collision(Pic,Player) if (Pic[1].x+Pic[1].w > Player[1].x ) and (Pic[1].x < Player[1].x + Player[1].w) and (Pic[1].y + Pic[1].h > Player[1].y) and (Pic[1].y < Player[1].y + Player[1].h) then return true else return false end end Player[1].x = Player[1].oldx Player[1].y = Player[1].oldy while true do pad = Controls.read() screen:clear() screen:blit(0,0,background) screen:blit(Pic[1].x,Pic[1].y,pic1) screen:blit(140,107,pic2) screen:blit(Player[1].x,Player[1].y,player) 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
so your sam said i was calling a string and not a number, but i dont see where the error comes from.
can anyone fix it?**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
02-24-2007, 10:00 AM #5798
Not sure, the code looks fine to me.
Zitat von %chrono trigger%
-= Double Post =-
Yeah there are. http://www.lua.org/pil/21.1.html
Zitat von pspfreak9
Geändert von youresam (02-24-2007 um 10:01 AM Uhr) Grund: Automerged Doublepost
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-24-2007, 10:02 AM #5799Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
exactly but thanks for trying
anybody else now?
could it be my images?
(im trying everything)**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
02-24-2007, 10:04 AM #5800
You never set a value for Player[1].oldx and Player[1].oldy, so the numbers become nil.Code:Player[1].x = Player[1].oldx Player[1].y = Player[1].oldy
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-24-2007, 10:22 AM #5801Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
that was the problem, so i added those variables into my table. it worked, but now my player wont move.
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
02-24-2007, 02:59 PM #5802
i think you should do:
just switch them that way your player.x and player.y will not be the ones changed, allowing you to moveCode:Player[1].oldx = Player[1].x Player[1].oldy = Player[1].y
-
02-24-2007, 05:44 PM #5803Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
nope didnt work any other suggestions
p.s. thanks for all the help everyone**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
02-24-2007, 05:55 PM #5804
His solution was for my bug report.
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-25-2007, 12:20 PM #5805Look 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 sorry for bugging everyone, but ive got all errors fixed, but i just implemented jumping. now it says my guy is jumping, but he does not appear to be jumping how to i mkae it so he actually changes his "y" value and then comes back down?
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
02-25-2007, 01:58 PM #5806
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Quick Question:
What does that do, return to Lowser?Code:return
-
02-25-2007, 03:15 PM #5807
can someone please tell me where a simple enemy code is
-
02-25-2007, 03:40 PM #5808
Returns from the current function.
Zitat von pspfreak9
-= Double Post =-
http://google.com
Zitat von pspaquaforce
Geändert von youresam (02-25-2007 um 03:41 PM Uhr) Grund: Automerged Doublepost
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-25-2007, 03:52 PM #5809
Ok, I need some help with a bit of code for printing text centered on the screen with truetype fonts.
Here's what I have so far:
Code:blue = Color.new(0,0,255) hyper = Font.load("fonts/hyperion.ttf") hyper:setPixelSizes(10, 20) function printCentered(font, y, text, color) local length = string.len(text) local x = 240 - ((length*10)/2) screen:fontPrint(font, x, y, text, color) end screen:clear() printCentered(hyper, 100, "This is a test", blue) printCentered(hyper, 200, "This should be centered as well", blue) screen.flip() while true do pad = Controls.read() if pad:start() then break end end
Since I've set the font width to 10, If I were using a fixed width font then 240 - ((length*10)/2) or (half of the screen width)-((number of characters in the text string * the pixel width of the font)/2) would center the line. But since I'm using a variable width true type font it's actually coming out to the left of center.
Can anyone tell if there is a function that can give me the actual pixel length of a string of text when using a variable width font?
*edit*
LOL, I post a question then find the answer myself a couple minutes later:
Code:hyper:getTextSize(text)["width"]
Geändert von Merick (02-25-2007 um 04:09 PM Uhr)
-
02-25-2007, 06:02 PM #5810Look 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 added everything the only thing left is (dramatic silence) collision.
i added collision on another image and its right, however its giving me an error saying i need to add an end to close my 'while'.
i have an end at the end of the while true do loop that would end it so i dont understand whats wrong
any ideas?**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
02-25-2007, 06:05 PM #5811I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Check your entire code to make sure every IF and WHILE has an END.

-
02-25-2007, 06:16 PM #5812
-
02-25-2007, 06:30 PM #5813Look at my user title :p
- Registriert seit
- Feb 2006
- Ort
- Texas
- Beiträge
- 1.183
- Points
- 14.103
- Level
- 77
- Downloads
- 0
- Uploads
- 0
nevermind i fixed it
Geändert von %chrono trigger% (02-25-2007 um 08:42 PM Uhr)
**********, ********** :p
http://img143.imageshack.us/img143/6...boysfanij8.gif
-
02-25-2007, 06:31 PM #5814I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
Would you mind posting your code? Or PMing it?

-
02-25-2007, 06:31 PM #5815lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Here is a simple enemy code
Just edit the code to fit your game, Very simple.Code:enemy1=Image.load(....) --// enemy image Enemy= {} Enemy[1] = {x = ... , y = ...} --//X and y Position of Enemy function moveenemy() --dont forget to call the function --your enemy movement function if you move right then he moves to you end end screen:blit(enemy[1].x, enemy[1].y, enemy1)
-
02-25-2007, 06:36 PM #5816
the function part is what i am having trouble onenemy1=Image.load(....) --// enemy image
Enemy= {}
Enemy[1] = {x = ... , y = ...} --//X and y Position of Enemy
function moveenemy() --dont forget to call the function
--your enemy movement function
if you move right then
he moves to you
end
end
screen:blit(enemy[1].x, enemy[1].y, enemy1)
-
02-25-2007, 06:48 PM #5817
...
Zitat von pspaquaforce
牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-25-2007, 06:54 PM #5818
yes i thought the code you gave me would work so

-= Double Post =-
its really gay witout shake moving
shake should be kicking meatwads @$$ by now all he can do is give him that funny lookGeändert von pspaquaforce (02-25-2007 um 07:08 PM Uhr) Grund: Automerged Doublepost
-
02-25-2007, 07:21 PM #5819
I KNOW ITS SO GAY WITHOUT SHAKE MOVING!
Zitat von pspaquaforce
...
...

(man I need to stop going to this thread..)牧来栠摩琠敨映汩獥
PSN: youresamFrom Earth the Frozen Ipaqs shall rise and be silenced and all will live free.
--Mike Hollingsworth
-
02-25-2007, 07:26 PM #5820
HELP ME:Argh: didn't i send you the code but you didn't pm me back huh
youresam's thoughts " that retard pm again i thought i was done with him"
or did you think of that


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