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; hey sg57 how would i do that?...would be like actually i have no clue, can you help me...il give u ...
-
01-28-2007, 12:32 AM #5341QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- 6ft. Down Underground........Oh and guess what my avatar is
- Beiträge
- 387
- Points
- 4.918
- Level
- 44
- Downloads
- 0
- Uploads
- 0
hey sg57 how would i do that?...would be like
actually i have no clue, can you help me...il give u credit if you do, lol
-
01-28-2007, 12:53 AM #5342
actually its a little harder than that, its currently slow because it loops through every pixel on the screen each frame, thats 130,560 pixels it has to deal with, per-frame.sounds like all he needs to do to speed it up is increase an integer somewhere
well thats what it used to do, he's changed it so it only loops through the section the text is in, witch is like one 20th of the screen (20x faster).
-
01-28-2007, 02:16 AM #5343QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- Middle Europe
- Beiträge
- 1.281
- Points
- 11.800
- Level
- 71
- Downloads
- 0
- Uploads
- 0
if u mean write, then probably not, i wanted to test it, but definetly can read from flash0/1
Zitat von the undead
[1 Year QJ Member]
[LUA Coder and C Learner]
[Ball Revamped Clone v0.1]
[Phil's Shooting Range v0.3]
[HideFile PRX v2]
[SSR PRX v1.1]
-
01-28-2007, 02:24 AM #5344QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- London
- Beiträge
- 165
- Points
- 5.400
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I've upgraded my pong code from ealier in this thread (if you saw it...).
Spoiler for My code:
But I'm getting this error:I think this means that you cant 'do math' on that variable, but all the other dummy variables in that function luaPlayers fine with.....Code:error: index.lua:47: attempt to perform local arithmatic on local 'w1' (a nil value)
Oh, and thanks to BlackShark whos code has been great to learn from!
(Hope thats OK.... :o )
-
01-28-2007, 02:31 AM #5345QJ 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
hehe, its cool, I just hope it helps ( and I see another great Pong game that rivals mine
)
EDIT: the reason that comes up is because you have not defined w1 yet, w1 in this case would be the width of what ever object that applies to, weather ball or paddle. I don't think you defined the X's and Y's in there either, you'll probably get an error for those soon enough to if you don't define them!NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-28-2007, 03:32 AM #5346.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Can someone help me? I've never gotten the error before, but when exiting my main game.lua file and reloading it, i get the error "Loop ingettable"
Any help please?
-
01-28-2007, 03:36 AM #5347QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- London
- Beiträge
- 165
- Points
- 5.400
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Thanks for your help BlackShark, but isnt the w1 variable a dummy var? (ie its only used in the function and arent defined, and whatever values are parsed through it through the function call change the variables.
Zitat von BlackShark
eg.
That works and the variables arent declared, so why does mine not work?Code:white = Color.new(255,255,255) function maths(x, y) -- dummy vars are x and y return x * y -- these are not declared end while true do num1 = 1 num2 = 2 test = maths(num1, num2) screen:print(0,0, "The number is: " .. test, white) screen.waitVblankStart() screen.flip() end
-
01-28-2007, 03:56 AM #5348QJ 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
technecly,
Code:function maths(x, y) -- dummy vars are x and y return x * y -- these are not declared end
IS defining the x/y variables,
the w1 is supposed to be defined as the with of object 1 or maybe like your paddle, find the width of your paddle, then up in somewhere in your code write
w1 = 10
replace 10 with the actual width of your paddle.NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-28-2007, 04:14 AM #5349QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- London
- Beiträge
- 165
- Points
- 5.400
- Level
- 47
- Downloads
- 0
- Uploads
- 0
even if i define it, i still get the same error
Zitat von BlackShark
EDIT: Does a function accept table values as arguments?
-
01-28-2007, 04:14 AM #5350words 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
Blake1 - The reason num1 and num2 arent giving you errors in your snippet, is becuase your setting them to a value, and that also means you'd be initlizing it, which means your creating it. Now, if you were comparing num1 and/or num2, than it would give you anerror as for one - there is no value in 'num1' and two, it cant find a variable named num1.
As for the motion blurr thing, yes, eyece explained it quite well. After seeing hte GIF, Im going to cut down on al ayer, so in turn that should boost it by 480*12 x faster. Think someone could test this:
Code:scene = {} scene[1] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,13)} scene[2] = {newcolor = {r=0,g=0,b=0,a=0}, finalcolor = Color.new(0,0,0), screencolor = Color.new(0,0,0), image=Image.createEmpty(480,13)} scene_num = 1 time = 0 pi = math.atan(1) * 4 i=0 y=0 x=0 screen:clear() screen.waitVblankStart() screen.flip() while true do for x=0,479 do for y=130,142 do scene[scene_num].screencolor = screen:pixel(x,y) -- get pixel color scene[scene_num].newcolor = scene[scene_num].screencolor:colors() -- give it to new table scene[scene_num].newcolor.a = 255/scene_num-40/scene_num -- edit transparency value scene[scene_num].finalcolor = Color.new(scene[scene_num].newcolor.r,scene[scene_num].newcolor.g,scene[scene_num].newcolor.b,scene[scene_num].newcolor.a) scene[scene_num].image:pixel(x,y-130,scene[scene_num].finalcolor) -- give that color to the old scene end end scene_num = scene_num + 1 if scene_num > 2 then scene_num = 1 end screen:clear() x = math.sin(pi * 2 / 360 * time) * 150 + 180.5 screen:print(x, 131, "Does this blur?", Color.new(0,255,0)) time = time + 1 if time >= 360 then time = 0 end for i=1,2 do screen:blit(0,130,scene[i].image) end screen.waitVblankStart() screen.flip() 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
-
01-28-2007, 04:15 AM #5351QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- 6ft. Down Underground........Oh and guess what my avatar is
- Beiträge
- 387
- Points
- 4.918
- Level
- 44
- Downloads
- 0
- Uploads
- 0
im sure their is a wau to do it tho, or atleast i hope so
Zitat von myschoo
-
01-28-2007, 04:26 AM #5352QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- London
- Beiträge
- 165
- Points
- 5.400
- Level
- 47
- Downloads
- 0
- Uploads
- 0
SG57 - the arguments that are going into the function are initialised, in an array/table .
-
01-28-2007, 04:40 AM #5353words 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
Uh... what? The arguments in the function in your snippet are just place holders, in a sense. The best way to learn it, is to learn C's syntax, as it will help you understand programming in general much better.
That is your maths function in C. It returns a whole number (hence the 'int' data type), and hte arguments are being initilized, so no error there. Its just, when you call that function and supply the arguments with a value, than your setting those variables to those values, than running the code within the function...Code:int maths(int x, int y) { return x*y; }
I dont quite understand what you are saying, so please elaborate before i rant some more :Argh:Code:int some_vars[2]; some_var[0] = maths(3,9) // whats happening here is... maths ( x = 3, y = 9 ) { some_vars[0] = 3*9; } some_var[1] = maths(2,13) // whats happening here is... maths ( x = 2, y = 13) { some_vars[1] = 2*13 }
...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-28-2007, 10:30 AM #5354
its doing the same thing SG57, blurring, getting darker, and still showing that clip of the lowser (wtf).
-
01-28-2007, 11:44 AM #5355QJ Gamer Green
- Registriert seit
- Aug 2006
- Ort
- London
- Beiträge
- 165
- Points
- 5.400
- Level
- 47
- Downloads
- 0
- Uploads
- 0
I know their placeholders. They dont have to be defined outside of the function, right?
But the error im getting is:
with this code:Code:error: index.lua:47: attempt to perform local arithmatic on local 'w1' (a nil value)
Spoiler for My Code:But of couse the w1 var is a nil value, if its only a placeholder.Code:
EDIT: Why am I getting that empty code block in my post?
-
01-28-2007, 12:20 PM #5356Developer

- Registriert seit
- Jul 2006
- Beiträge
- 205
- Points
- 4.318
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Blake, look at your third input argument the first time you use the collision function.
-
01-28-2007, 12:49 PM #5357QJ 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
ya, you still haven't defined it, you need to, put "w1 = 10" or something like that above your function. you can change "10" to what ever the actual width of your paddle is.
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-28-2007, 12:56 PM #5358QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- 6ft. Down Underground........Oh and guess what my avatar is
- Beiträge
- 387
- Points
- 4.918
- Level
- 44
- Downloads
- 0
- Uploads
- 0
any one know how to write to the flash(0 and 1) ive been looking all over the place
-
01-28-2007, 12:57 PM #5359QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
LMelior nailed it
Notice the typo? What the heck is ball[1].w?Code:if collision(ball[1].x, ball[1].y, ball[1].w, ball[1].img:height(), paddle[1].x, paddle[1].y, paddle[1].img:width(), paddle[1].img:height()) then direction = "right" end
[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]
-
01-28-2007, 02:12 PM #5360QJ 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
Does anyone know how to make .xm files play smoothly?
I put in Music.playFile("moise.xm" , true) and it works, but it plays a note every second and lags my game like crazy.
-
01-28-2007, 02:45 PM #5361Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
then exchange true with false. and it will play once.
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-28-2007, 02:50 PM #5362QJ Gamer Blue
- Registriert seit
- Jul 2006
- Beiträge
- 72
- Points
- 4.209
- Level
- 41
- Downloads
- 0
- Uploads
- 0
No, that wont make a difference. The problem is probably due to the psp running out of processing power, or the memory stick constantly being accessed. Try to optimise your code
-
01-28-2007, 02:53 PM #5363QJ Gamer Green
- Registriert seit
- Nov 2005
- Ort
- NoWhere . . . .
- Beiträge
- 1.266
- Points
- 7.598
- Level
- 58
- Downloads
- 0
- Uploads
- 0
theres no writing to flash 0/1 only read access
Zitat von the undead
-
01-28-2007, 03:01 PM #5364QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- 6ft. Down Underground........Oh and guess what my avatar is
- Beiträge
- 387
- Points
- 4.918
- Level
- 44
- Downloads
- 0
- Uploads
- 0
kthanks now i need to learn c and make a lua player mod, lol
Zitat von zmathue
know any good tuts?
-edit
actuallyy ill just learn c and make an eboot, so know any good tuts?...lol
-
01-28-2007, 03:16 PM #5365lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
Just have someone edit the LUA Player so we can get flash 0 write, But keep in mind LUA was meant for the beginning coders so thats why LUA is easy to learn.
-
01-28-2007, 03:23 PM #5366QJ 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
if ever a mod was to come out like that, id make a mod flasher like xflash :), but who knows if that would ever be implemented.
NEWMy New BLOG!NEWThe Wentire Worls in two Sectors....When did I get dev statz?
Spoiler for my PSP homebrewReleases:Spoiler for Great Quotes:
-
01-28-2007, 03:25 PM #5367lol

- Registriert seit
- Aug 2006
- Ort
- Whittier, CA
- Beiträge
- 5.791
- Points
- 20.859
- Level
- 91
- Downloads
- 0
- Uploads
- 0
I hope it doesn't happen, Too many newb LUA coders will start making stuff related to flash and i can see all the bricks already.
-
01-28-2007, 03:33 PM #5368Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
If you talking about my post (because I think you are) yes actually it will make a difference. Changing that last variable to false will play the song once or once everytime it is called. Trust me I made a app with a tuner in it.
Zitat von PSPhakkor
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-28-2007, 03:39 PM #5369.info

- Registriert seit
- Jun 2006
- Ort
- ACT, Australia
- Beiträge
- 1.674
- Points
- 15.395
- Level
- 80
- Downloads
- 0
- Uploads
- 0
Can someone help me? I have an error when using dofile() and then loading the same file again...Loop ingettable?
-
01-28-2007, 03:40 PM #5370Ponies and Unicorns
- Registriert seit
- Aug 2006
- Ort
- Pelennor Fields
- Beiträge
- 547
- Points
- 5.778
- Level
- 49
- Downloads
- 0
- Uploads
- 0
Need some code.
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!


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