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; I got this: Code: screen:print(5,20,"You should take in "..(typingstring*2).." grams of protein each day", white) do I need to change ...
-
06-15-2008, 04:34 AM #8731QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
I got this:
do I need to change the typingstring*2?Code:screen:print(5,20,"You should take in "..(typingstring*2).." grams of protein each day", white)
go to MSN
Geändert von Moose (06-15-2008 um 04:36 AM Uhr) Grund: Added [code] tags
-
06-15-2008, 04:36 AM #8732QJ Gamer Platinum
- Registriert seit
- Feb 2006
- Ort
- National Front Disco
- Beiträge
- 13.057
- Points
- 66.627
- Level
- 100
- Downloads
- 0
- Uploads
- 0
Please remember to add the [CODE] tags where needed. ;)
-
06-15-2008, 05:07 AM #8733Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
------ 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).
-
06-15-2008, 05:16 AM #8734QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
I didn't really understand, what I want is to put this:
so the users can start writing from nothing.Code:typingstring = ""
But of course "" isn't a number, so it gives me an error.
I'm really confused now
-
06-15-2008, 08:45 AM #8735QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Code:screen:print(5,20,"You should take in "..((tonumber(typingstring) or 0)*2).." grams of protein each day", white)
-
06-15-2008, 10:03 AM #8736QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
Hey I want to make a selection between 2 values, it goes like this:
text number 1: Kilograms to Pounds
text number 2: Pounds to Kilograms
When pressing the select button, one of those lines will flash, (appear, disappear, appear, disappear).Kilograms to Pounds
Pounds to Kilograms
And it will change the wunit value each time
wunit = kglb
wunit = lbkg
Sorry if it's complicted or something
-
06-15-2008, 02:03 PM #8737QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
-
06-16-2008, 01:05 AM #8738QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
-
06-19-2008, 08:26 AM #8739
Need help...
How could I take all the binary data from a file, and paste it into a specific hex address in another file ??PSP: PSP SLIM 2001 TA-088v2Custom Firmware: 5.00 M33-6
-
06-19-2008, 11:25 AM #8740QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Assuming I understand correctly you want to go from:
file1:
binary stuff
file2:
some stuff
some other stuff
to:
file1:
binary stuff
file2:
some stuff
binary stuff
some other stuff
Just some simple IO stuff and some seeking through file2 to get to where you want. The bottom of this has stuff about seeking but I'm not sure how it would apply with hex addresses. Essentially you're trying to make an on-psp hex editor and I haven't messed with that much, mostly just plaintext io.
-
06-19-2008, 12:17 PM #8741Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
06-19-2008, 02:11 PM #8742QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Code:file1 = io.open("file1.bin",rb) file2 = io.open("file2.bin",wb) file2:seek("set",tonumber("HEXADDRESS",16)) file2:write(file1:read("*a")) file1:close() file2:close()
-
06-20-2008, 02:50 AM #8743Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Ok, for some reason i cant get this to work, Could someone help me?
For some reason the oldx, oldy isnt working??Code:--Script --Colours red = Color.new(255,0,0) black = Color.new(0,0,0) blue = Color.new(0,0,255) --Images col = Image.load("images/col.png") background = Image.load("images/lvl-1.png") --Player player = { x = 200, y = 50, img = Image.load("images/play.png") } while true do oldx = player.x oldy = player.y screen:clear() pad = Controls.read() --Blit images screen:blit(0,0,col) screen:blit(0,0,background) screen:blit(player.x, player.y, player.img) colour = col:pixel(player.x + 2, player.y + 15) if colour == red then player.y = oldy player.x = oldx end And Blah (movement ) screen.flip() screen.waitVblankStart() end
i just walk right through,
Note: the colour on the image has the same RGB so its not that
-
06-20-2008, 03:41 AM #8744QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
What does the collision image look like?
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
06-20-2008, 03:52 AM #8745QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Understand your program's flow, instead of just using examples. At the beginning of the loop, you are setting the oldx and oldy to your players position. Then, if a a colision, you are setting the players position to oldx and oldy. At that point they are already the same, so if a collision, nothing will happen.
-
06-20-2008, 03:55 AM #8746QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
EDIT: Double Post (TPG's squid proxy is screwy, so my internet is screwed up)
-
06-20-2008, 04:00 AM #8747Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
heres the image
-
06-20-2008, 04:09 AM #8748Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
06-20-2008, 07:44 AM #8749QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Do you know the purpose of oldx and oldy?
-
06-20-2008, 09:15 AM #8750QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
oldx and oldy are for storing your player's position in the previous loop and then if the player collides with something that cannot be walked through, then roll the player back to where he was before (oldx and oldy)
However, for the player's x and y to change to get him into a spot in which he might need to be rolled back, he needs to move first. Right now you are checking if he has moved into a bad spot and resetting him BEFORE HE EVEN GETS TO MOVE. You need to let him move and THEN check if he has moved into something he can't move into. If you can't figure out how to do that on your own then you need to start over learning lua and take it in smaller bits rather than trying to jump into a game.
-
06-20-2008, 10:42 AM #8751QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
I'm using denzeff osk, and I've completed modifying it, but I still need to fix this:
(What you type in the osk is the "typingstring")
Code:*if typingstring = "" you can't press delete
(that's 3 if's in total that I need for the osk)Code:*you can't press period when: typingstring = "" or, when there is already one period in the number.
here's the code of the osk if needed: (not the original one, it's the one I made)
Code:displaykeyboard = false keyboard = {x = 0, y = 0, mode = 1, key = 5, buffer = "", key_img = Image.load("danzeff/keys1.png"), key_img2 = Image.load("danzeff/keys2.png")} keyboard.key_values = { "a,bc","d.ef","g!hi", "j-kl","m\001 n","o?pq", "r(st","u:vw","x)yz", "A^BC","[email protected]","G*HI", "J_KL","M\001 N",'O"PQ', "R=ST","U;VW","X/YZ", "\0\0\0001","\0\0\0002","\0\0\0003", "\0\0\0004","\0\001.5","\0\0\0006", "\0\0\0007","\0\0\0008","\0\00009", "(,.)","<\"'>","[-_]", "{!?}","\0\001 \0","\\+=/", "@:;#","$~`%","^"..string.char(15)..string.char(22).."&" } function keyboard.process(x,y,ctrldata,oldctrldata) keyboard.mode = 5 if ctrldata:up() or ctrldata:down() then if inputtimer > 20 then inputtimer = 15 end inputtimer = inputtimer + 1 else inputtimer = 0 end local tx = math.floor((ctrldata:analogX()+128)/86) local ty = math.floor((ctrldata:analogY()+128)/86)+1 keyboard.key = ty*3-(2-tx) if keyboard.mode == 7 then screen:blit(x,y,keyboard.key_img2,0,0,150,150) else screen:blit(x,y,keyboard.key_img,((keyboard.mode+1)/2-1)*150,0,150,150) end local tx = math.mod(keyboard.key,3) if tx == 0 then tx = 2 else tx = tx - 1 end local ty = math.floor(keyboard.key/10*3) if keyboard.mode > 4 then screen:blit(x+tx*43,y+ty*43,keyboard.key_img2,tx*64 + ((keyboard.mode+1-4)/2-1)*192,ty*64+150,64,64) else screen:blit(x+tx*43,y+ty*43,keyboard.key_img,tx*64 + ((keyboard.mode+1)/2-1)*192,ty*64+150,64,64) end local t = 0 if ctrldata:square() and not oldctrldata:square() then t = 1 elseif ctrldata:triangle() and not oldctrldata:triangle() then t = 2 elseif ctrldata:cross() and not oldctrldata:cross() then t = 3 elseif ctrldata:circle() and not oldctrldata:circle() then t = 4 end if t ~= 0 then t = string.sub(keyboard.key_values[((keyboard.mode+1)/2-1)*9+keyboard.key],t,t) if t ~= "\r" then keyboard.buffer = t end end end function keyboard.typeToString(str) if not displaykeyboard then displaykeyboard = true end if keyboard.buffer == "\001" and str ~= "" then str = string.sub(str,1,-2) elseif keyboard.buffer ~= "\000" then str = str..keyboard.buffer end keyboard.buffer = "" return str end
-
06-20-2008, 10:44 AM #8752Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
ok, i understand thanks TurtlesPWN
-
06-20-2008, 11:02 AM #8753QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
YOU made that OSK but you can't figure out how to incorporate some more simple logic into it? BS
But whatever. Replace the typeToString function:
Code:function keyboard.typeToString(str) if not displaykeyboard then displaykeyboard = true end if keyboard.buffer == "\001" and str ~= "" then str = string.sub(str,1,-2) else if keyboard.buffer == "." then if str ~= "" and not string.find(str,".") then str = str..keyboard.buffer end elseif keyboard.buffer ~= "\000" then str = str..keyboard.buffer end end keyboard.buffer = "" return str end
-
06-20-2008, 11:18 AM #8754QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
-
06-20-2008, 11:20 AM #8755QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Yes, I know, but read your post:
"
here's the code of the osk if needed: (not the original one, it's the one I made)"
-
06-20-2008, 11:25 AM #8756QJ Gamer Green
- Registriert seit
- May 2008
- Beiträge
- 246
- Points
- 3.810
- Level
- 39
- Downloads
- 0
- Uploads
- 0
-
06-20-2008, 01:01 PM #8757lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
-
06-20-2008, 01:11 PM #8758Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
06-20-2008, 10:37 PM #8759
Hey,
I need some help modifying a string (containing a filename). Every space found should be replaced with a "+".
doesn't workCode:string.gsub(filename," ","+")
-
06-20-2008, 10:52 PM #8760words 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
string.gsub returns the new string with the " " replaced with "+", it doesn't modify the string passed to it. Are you assigning it to anything?
If you have been doing this then make sure original_filename does in fact contain spaces.Code:new_filename = string.gsub(original_filename, " ", "+")

...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


LinkBack URL
About LinkBacks
Mit Zitat antworten
lol

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