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; Ok im trying to get my tab reader working and im trying to print all the lines of a tab ...
-
01-15-2007, 01:06 PM #5041Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Ok im trying to get my tab reader working and im trying to print all the lines of a tab to the screen from a text file named tab.txt and its not working. So far here is my code
And here is whats inside my text fileCode:--declare some colors and whatnot blue = Color.new(0,0,255) red = Color.new(255,0,0) background = Image.createEmpty(480,272) background:clear(blue) --main loop while true do screen:blit(0,0,background) --now lets read the tab y = 5 file = io.open("tab.txt","r") for line in file:lines() do y = y + 5 screen:print(0,y,line,white) end file:close screen.waitVblankStart() screen.flip() end
named tab.txt
Im trying to get scrollign to work also if someone could help me there too. and one more thing this lineCode:-3---3--------------2-0-------| -3-----3---3------3-----3---3-| -0-------0------2---------2---| -0------------0---------------| ------------------------------| -3----------------------------|
What is my tab is in a certain directory wouldnt it beCode:file = io.open("tab.txt","r")
right?Code:file = io.open("./tab/tab.txt","r")
Could use some help.
O yah adn the error im getting is like something wrong with the argument screen on line 20 or somethign
-= Double Post =-
Anyone?
Geändert von GuitarGod1134 (01-15-2007 um 01:06 PM Uhr) Grund: Automerged Doublepost
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
01-15-2007, 02:09 PM #5042words 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
For one, your asking sooo much of other people. Please - you don't learn anything asking people to write your code for you. You should simply say your error you recieved, what your trying to do and the code on that line.
I say this because you dont even have 20 lines of code in that thing you posted.. Want help - ask appropriately. And for scrolling, move the X coordinate of the text your printing to the left. Oh and one more thing, default text height in lua is 10 pixels, so y = y + 5 will have every letter cut off from the top by the other...
...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
-
01-15-2007, 02:20 PM #5043Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Ok I run it, I changed the y coordinate and I still get an error.
It thinks or from what I can tell, there is something wrong with screen.waitVblankStart()
It says
error :snake.lua:17: function arguments expected near 'screen'
-= Double Post =-
O and the 20 lines, I took some notes there for coordinates and stuff but now I removed it and it says the error is on 17. and I dont see anything wrong with screen.waitVblankStart()Geändert von GuitarGod1134 (01-15-2007 um 02:20 PM Uhr) Grund: Automerged Doublepost
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
01-15-2007, 02:24 PM #5044
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Didn't you have this question before?? And you got a answer. Plus what is line 20??
-
01-15-2007, 02:31 PM #5045Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
No, and its the 20th line of code , but its really the 17th line.
If you play WoW come find me on DOOMHAMMER (US) I am Human mage lvl 64 Atrana is the name (dont ask for runs!)
Gold donations are highly appreciated!
-
01-15-2007, 02:46 PM #5046
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
you should read some tuts. I'm no sure how to do it but i Think this is how:
Code:tab = "./tab/tab.txt" file = io.open(tab, "r") print(file)
-
01-15-2007, 03:58 PM #5047lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Sticky.
:)
-
01-15-2007, 04:53 PM #5048
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
What do you mean by sticky the Lua Help Thread??
Zitat von Anti-QJ
-
01-15-2007, 05:22 PM #5049lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
You see, When its sticky, It stays at the top of the forum, So its easier to find, So i have to pay like 700 points a week to do so, I don't know why a moderator just doesn't do it but it doesn't matter, Cause i got the points to do so.
-
01-15-2007, 06:15 PM #5050QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- In a cave according to SG57 lol
- Beiträge
- 273
- Points
- 4.917
- Level
- 44
- Downloads
- 0
- Uploads
- 0
How can I make an image move on it's own without any key commands?
-
01-15-2007, 06:36 PM #5051
well if you did have it controlled with key commands you would do:
Zitat von ZeroMega
so if you want to make it go on it's own, then in your main loop simply put theCode:if pad:left() then image.x = image.x - 2 end
Code:image.x = image.x - 2
-
01-15-2007, 06:43 PM #5052QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- In a cave according to SG57 lol
- Beiträge
- 273
- Points
- 4.917
- Level
- 44
- Downloads
- 0
- Uploads
- 0
It keeps saying loop ingettable when I try running it
Zitat von emericaska8r
Here's the code (I'm using Evil Mana's tute)
Where would I put the script so flower can move?Code:--Test grass = Image.load("grass.png") player = Image.load("player.png") flower = Image.load("flower.png") screenwidth = 480 - player:width() screenheight = 272 - player:width() Player = { } Player[1] = { x = 200, y = 50 } -- Function to check player movements function playerMovement() pad = Controls.read() 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 if pad:down() and Player[1].y < screenheight then Player[1].y = Player[1].y + 2 end end -- Function to paste images to screen function pasteImages() for a = 0, 14 do for b = 0,8 do screen:blit(32 * a, 32 * b, grass) end end screen:blit(100,100,flower) screen:blit(300,220,flower) screen:blit(Player[1].x,Player[1].y,player) end -- Main Loop while true do screen:clear() pasteImages() playerMovement() screen.waitVblankStart() screen.flip() end
-
01-15-2007, 06:51 PM #5053
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Do it like this:
-= Double Post =-Code:while true do image = Image.load("image.png") image.x = image.x-2 screen:blit(image.x,0,image,false) end
ITS THE SAME THING I DID!!??Geändert von pspfreak9 (01-15-2007 um 06:51 PM Uhr) Grund: Automerged Doublepost
-
01-15-2007, 06:54 PM #5054QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- In a cave according to SG57 lol
- Beiträge
- 273
- Points
- 4.917
- Level
- 44
- Downloads
- 0
- Uploads
- 0
I'm using this tutorial as my main example
Zitat von pspfreak9
http://evilmana.com/tutorials/lua_tutorial_08.php
btw i dont know where to put the code
-
01-15-2007, 07:15 PM #5055QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
Ok. I gotta loading bar that displays a red line. If it were 50% loaded it would be halfway filled up and if it were at 100% it would be filled completely up. Now I wanna know how I can make to where I can change the percentage each time something is loaded.
Like:
But that doesn't seem to bring it to being halfway filled up. Actually it displays an error message. Is there a way where if I load something it will raise the loading bar by however much?Code:if Image.load("something.png") then data.loaded = 50 end
-
01-15-2007, 07:22 PM #5056
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
IS data.loaded a real function??
-
01-15-2007, 07:26 PM #5057QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
No i made it before the loop. It looks like this.
Code:data {} data.loaded = 0 while true do
-
01-15-2007, 07:32 PM #5058
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
ok do this:
You know most people just make a loading bar animation when nothing is being loaded. But if you wanna do that add a random feature that changes the thime of loading each time. ;)Code:if data.loaded = 50 then Image.load("50.png") end
-
01-15-2007, 07:40 PM #5059QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
that would take a lot of different image files. :X
EDIT: and even if I decided to do that it still goes back to my question. how would I raise data.loaded everytime I loaded something.
-
01-15-2007, 07:56 PM #5060
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
I told you just make a load bar that doesnt have to do with the data. And add different ones that take different time. Then make them random thats should make it seem like it's real.
-
01-15-2007, 07:59 PM #5061QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
I don't want it to seem real.. I want it to be real.. O_o
-
01-15-2007, 08:10 PM #5062
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
Whats loading in your game??
-
01-15-2007, 08:35 PM #5063QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
Just like the maps, menus, extra data, libraries.. That stuff. But I only want it on a loading menu to look cool. ;)
-
01-15-2007, 08:42 PM #5064
- Registriert seit
- Sep 2006
- Beiträge
- 484
- Points
- 8.718
- Level
- 62
- Downloads
- 0
- Uploads
- 0
While can I see part of your code then??
-
01-15-2007, 08:50 PM #5065words 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
Cheez_Pirate. Add to a variable after each image is loaded. Print out that variable in a percent form. Or if you want a loading bar, do the same but apply it to the sourcex/sourcey of an image when blitting.

...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
-
01-15-2007, 08:55 PM #5066QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
I'm having a hard time understanding that SG57. I'm trying to do something like.. A GTA loading screen. It's the very first thing that comes up on GTA except the rockstar logo. It pretty much loads the bigger parts in the game such as the maps weapons and characters. And everytime something is loaded the bar will go farther.
EDIT: 300th post.
-
01-15-2007, 09:06 PM #5067QJ Gamer Gold
- Registriert seit
- Aug 2006
- Beiträge
- 1.633
- Points
- 11.629
- Level
- 70
- Downloads
- 0
- Uploads
- 0
screen:fillRect(x,y,varua ble,h,color)
Make a variable and as you load the stuff make the variable go up.
IE Image.load("img.png") loadingvariable = loadingvariable + 1
Then with screen:fillRect fill in the rectangle and where i put variable in it thats the width of the bar, the higher the number gets the wider the bar gets.
-
01-15-2007, 09:34 PM #5068
- Registriert seit
- Dec 2006
- Beiträge
- 14
- Points
- 3.536
- Level
- 37
- Downloads
- 0
- Uploads
- 0
just a quick question about sprite sheets
if your using a sprite sheet with animlibv.4 does the sprite sheet have to be 272 in hight and 480 in diamiter to work?
I am using my own sprite sheet which is about 500 by 600, though the individual images on the sprite sheet are 240 by 200. when i load the program, it gives me a cannot load image error.
If this isnt possible , is there a way to shrink my sprite sheet, then use a code to magnify each frame to the size it was intended to be?
does anyone no how to solve this ?
Thanks
-
01-15-2007, 09:47 PM #5069QJ Gamer Blue
- Registriert seit
- Aug 2006
- Ort
- Missouri
- Beiträge
- 451
- Points
- 6.041
- Level
- 50
- Downloads
- 0
- Uploads
- 0
It works. But it will reload the image everytime it loops. :o Like the orange light will blink non-stop.
Zitat von TacticalPinguin
-
01-15-2007, 10:18 PM #5070Your Fate is Grim...

- Registriert seit
- Oct 2005
- Beiträge
- 2.269
- Points
- 11.640
- Level
- 70
- Downloads
- 0
- Uploads
- 0
Zitat von yotop456
animation lib supports all sizes that are compatible with lua. you CANNOT load ANY image greater than 512x512 in lua, which you are attempting to do.--------------------------------------------------------------------------------------


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