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; Just throwing it out there, if you are using an old version of luaplayer (<0.20), the "%" operator is not ...
-
05-22-2008, 06:50 PM #8641QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Just throwing it out there, if you are using an old version of luaplayer (<0.20), the "%" operator is not available (they are based on older versions of lua). Use math.mod instead.
e.g. math.mod(step + 1,6)
-
05-27-2008, 02:53 AM #8642Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I have two questions :
1) if i want an enemy to change direction when it reaches an certain space would i do this;
Would something like that work?Code:if Enemy[1].x > 200 then Enemy[1].x = Enemy[1].x + 2 end elseif Enemy[1].x < 100 then Enemy[1].x = Enemy[1].x - 2 end
2) This is general but concerns lua.
How do you become an better Lua programmer? What books, online tuts to read to become better?
-
05-27-2008, 03:17 AM #8643Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
1) yes that would work
Zitat von dan369
2) you dont become a better lua programmer by reading books or online tutorials, the books and online tutorials just teach you the knowledge, you yoursef have to apply that knowledge to become better
over time with your programming you will look at sections of your code and think im sure that can be made smaller, so you make a backup copy and test different methods out, if you dont mange to do it in one day then dont just replace it with the old code, leave it but either work on it again a short time later or come back to it after a while, by which stage you will have probably solved the problem for a different project or peice of code, meaning that you should be able to fix it.
all in all becomming a better programmer is all about coding and trying new things out, when you try new things out you will understand more full where and where not to use certain peices of code, and the method that they are coded in
basically dan practice makes perfect, keep at it and you will get better.
i didnt become as skilled as i am now in a month or two.------ 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).
-
05-27-2008, 03:34 AM #8644Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Ok, then Thanks Fat :)
-
05-27-2008, 04:32 AM #8645QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
@dan
Wow, Quadruple Post.
@Fatboy
Stop being so conceited, you have a long way to go before you are regarded as "skilled". I've seen you act in such a way a number of times recently, and it really make you come across as immature.Geändert von Nielkie (05-27-2008 um 04:52 AM Uhr)
-
05-27-2008, 04:40 AM #8646Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
My bad the computer froze for a bit so i kept clicking post quick reply sorry
-
05-27-2008, 05:09 AM #8647Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
and that affects my programming skills how ?
Zitat von Nielkie
i may be imature at times but what the hey thats just the way i am people need to learn to deal with it or shut up, the people who do deal with it find that i am quite a nice person, the people who dont have outstanding grudges against me which to be honest im not that bothered about.------ 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).
-
05-27-2008, 05:22 AM #8648Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Fat IS an skilled programmer, just look at this thread Or the Lua examples/snippets Thread. That one might as well be his
lol
He's helped me and most people in the forum
-= Double Post =-
Ok, I'm trying to do 3 selectable difficulties But am having trouble I got 3 drifferent .cfg files with the info but don't know how to do it?
I was thinking about having it after you press X on start in the menu then having it print: Easy, Medium, Hard changing colour on each one. Then you press X on anyone of them But i don't really want 3 drifferent files holding the difficultly So could someone maybe tell me how to do it?Geändert von dan369 (05-27-2008 um 11:36 AM Uhr) Grund: Automerged Doublepost
-
05-27-2008, 12:22 PM #8649QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You become a better Lua programmer by becoming a better programmer. You don't become better overnight, it takes constant learning and practise to accumulate experience over a period of time.
Zitat von dan369
A good book to read would be Code Complete 2nd Edition.
http://cc2e.com/[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]
-
05-27-2008, 12:43 PM #8650Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Ok, thanks I'm also reading an book about lua itself, then after understanding lua really well i'll try C/C++
-
05-27-2008, 01:19 PM #8651Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
as i said you need the functions that i have made for the saving and loading of a config file, when i have made it a proper function and made it as small as it can be ill post it on my site and tell you so you can take a look
Zitat von dan369
------ 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).
-
05-27-2008, 01:44 PM #8652Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I got the Menu part Set up moving left and right Simply But the loading is quiet hard because i'm not strong with reading/writing to files i know the basics but not advanced stuff
-
05-27-2008, 01:59 PM #8653Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
hey dan those examples are up on my site, you know which ones to click on
------ 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).
-
05-27-2008, 02:03 PM #8654Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Wow that was quick Thanks Fat will help me and loads off people

Off topic: Fat is it possible for your site to have an mini-forum? that would be cool i'd register :)
-
05-27-2008, 02:20 PM #8655Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
yeah i know how to do it i just couldnt be bothered to code it earlier when i mentioned it
Zitat von dan369
probably but im not quite sure that i need one, if you make a petition and get 50 + people to sign it that will use the forums if i put some up then ill make some
Zitat von dan369
------ 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).
-
05-27-2008, 02:38 PM #8656Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
How do you make an petition? Does my name count?
-
05-27-2008, 03:10 PM #8657QJ Gamer Platinum
- Registriert seit
- Feb 2006
- Ort
- National Front Disco
- Beiträge
- 13.057
- Points
- 66.627
- Level
- 100
- Downloads
- 0
- Uploads
- 0
We don't allow petitions on this forum, so it would have to be private.
Zitat von dan369
-
05-27-2008, 03:37 PM #8658QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
Hey, how would I code bliting only a section of a sprite sheet so I don't have to make 54 seperate images?? thanx
-
05-27-2008, 03:42 PM #8659Developer 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 i dont know if these are any good but i just found them in one of my folders entitled "sprite crap"
Zitat von PSProgramer
Code:white = Color.new(255, 255, 255) number = 0 tile_width = 32 tile_height = 32 tile_image = Image.load("tiles.png") tiles = { } oldpad = Controls.read() while true do pad = Controls.read() screen:clear() -- insert your main code here if pad:left() and not oldpad:left() then number = number + 1 end if number >= 9 then number = 0 end screen:blit(10, 10, tile_image, 32 * number, 0, 32, 32) -- insert your main code here if Controls.read():start() then break end oldpad = pad screen.flip() screen.waitVblankStart() endCode:white = Color.new(255, 255, 255) number = 0 tile_width = 32 tile_height = 32 tile_image = Image.load("tiles.png") tiles = { } oldpad = Controls.read() while true do pad = Controls.read() screen:clear() -- insert your main code here number = number + 1 if number >= 9 then number = 0 end screen:blit(10, 10, tile_image, 32 * number, 0, 32, 32) screen.waitVblankStart(60) -- insert your main code here if Controls.read():start() then break end oldpad = pad screen.flip() screen.waitVblankStart() endCode:white = Color.new(255, 255, 255) collumn = 0 row = 0 tile_width = 32 tile_height = 32 tile_image = Image.load("tilesb.png") tiles = { } oldpad = Controls.read() while true do pad = Controls.read() screen:clear() -- insert your main code here if pad:left() and not oldpad:left() then collumn = collumn + 1 end if collumn >= 3 then collumn = 0 row = row + 1 end if row >= 3 then row = 0 end screen:blit(10, 10, tile_image, 32 * collumn, 32 * row, 32, 32) -- insert your main code here if Controls.read():start() then break end oldpad = pad screen.flip() screen.waitVblankStart() end------ 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).
-
05-27-2008, 03:43 PM #8660QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
thanx, glad to put use to your "sprite crap"
by the way did you get my P.M.??
-
05-27-2008, 03:50 PM #8661QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
screen:blit(x,y,spriteshe etimage,topleftcornerofse ctionofspritesheetyouwant toblitx, topleftcornerofsectionofs pritesheetyouwanttoblity, bottomrightcornerofsectio nofspritesheetyouwanttobl itx, bottomrightcornerofsectio nofspritesheetyouwanttobl ity)
-
05-27-2008, 04:08 PM #8662Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
yeah ill take a look when i get time im busy doing a few things this week
Zitat von PSProgramer
and put simply
tile is another word for spriteCode:screen:blit(xpos to blit, ypos to blit, full image to use, x start position for tile, y start position for tile, width of tile, height of tile)
------ 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).
-
05-28-2008, 01:59 AM #8663QJ Gamer Blue
- Registriert seit
- Apr 2008
- Beiträge
- 497
- Points
- 4.268
- Level
- 41
- Downloads
- 0
- Uploads
- 0
thank you very much, that helps alot. Makes it way easier, and way more efficient!!! thank you!!
-
05-28-2008, 03:08 PM #8664Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
I want to do some type of online highscore system, But don't have a clue how to do this? would i have do make an webpage or sumthing?
My Plan: Have an system that loads your score using "r" (reading&writing functions) Then connecting to somewhere then you enter an name and it Places you in the right place? Is that possible????
-
05-28-2008, 04:07 PM #8665Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
with your own server and sql databse to manage it yes
Zitat von dan369
------ 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).
-
05-28-2008, 05:46 PM #8666QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
You don't need an SQL DB for a list of scores, but yes, you need some server side scripting and a webserver as well as some good lua online backend stuff.
-
05-28-2008, 07:58 PM #8667
Achievements:
- Registriert seit
- May 2008
- Beiträge
- 1
- Points
- 2.480
- Level
- 30
- Downloads
- 0
- Uploads
- 0
a little help from my friends
Hi everyone!
this is my first post here at qj and i wondered if someone can help me im having some trouble making my game which is tile based, so far i have been using this code as a base for mine i got it from http://wiki.ps2dev.org/psp:lua_player:tutorial
-- load graphics
tiles = Image.load("tiles.png")
figure = Image.load("figure.png")
-- the map
mapSource = {
"mmmmmmmmmmmmmmmmmmmmmmmm mmmmmm",
"mmmmmmmmmmmmmmmmmmmmmmmm mmmmmm",
"mmeaaaaaaaaaaaaaaaaaaaaa aaafmm",
"mmdpnnnnnnnnnnnnnnnnnnnn nnpbmm",
"mmdokcccccclnkcccccccccc clnbmm",
"mmdojaaaaafdnbmmmmmmmmmm mdnbmm",
"mmdooooooobdnbmmmmmmmmmm mdnbmm",
"mmdokccclobdnbmmmmmmmmmm mdnbmm",
"mmdobmmmdobdnbmmmmmmmmmm mdnbmm",
"mmdobmmmdobdnjaaaaaaaaaa fdnbmm",
"mmdobmmmdpbdnnnnnnnnnnnn bdnbmm",
"mmdobmmmhcghccccccccccln bdnbmm",
"mmdojaaaaaaaaaaaaaaaaain jinbmm",
"mmdpnnnnnnnnnnnnnnnnnnnn nnpbmm",
"mmhccccccccccccccccccccc cccgmm",
"mmmmmmmmmmmmmmmmmmmmmmmm mmmmmm",
"mmmmmmmmmmmmmmmmmmmmmmmm mmmmmm"
}
-- offsreen image, where the map will be drawn
board = Image.createEmpty(480, 272)
-- draw one tile on the map
function drawTile(tile, x, y)
tile = string.byte(tile, 1) - string.byte("a")
local tileX = math.mod(tile, 4)
local tileY = math.floor(tile / 4)
board:blit(16 * x, 16 * y, tiles, 17 * tileX + 1, 17 * tileY + 1, 16, 16, false)
end
-- copy the map source to an array for easier access and draw the offscreen board
map = {}
for y = 1, 17 do
line = mapSource[y]
map[y] = {}
for x = 1, 30 do
tile = string.sub(line, x, x)
map[y][x] = tile
drawTile(tile, x - 1, y - 1)
end
end
Now i want to use a tileset that it has a total of 64 tiles each tile of 16px by 16px in 8 colums and 8 rows now i cant figure how to number the tiles i have been planning using "aa ab ac ad af" ("aa" beign one tile) etc but i cant figure how to make this code
tile = string.sub(line, x, x)
so it can read the first two characters and then the next two and so on and so forth of each row and then adjust this so it works with the one above
tile = string.byte(tile, 1) - string.byte("a")
well in general how to change the code so it work with the tileset i would like to use
Or if you have a better sugestion on how to do this please i would really appreciate your help
-
05-29-2008, 04:47 AM #8668Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
So how do i start to do this?
Zitat von TurtlesPwn
-
05-29-2008, 05:12 AM #8669Developer and Tutor.
- Registriert seit
- Jul 2007
- Ort
- Widnes, England
- Beiträge
- 1.649
- Points
- 8.736
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
get your own website
Zitat von dan369
------ 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).
-
05-29-2008, 05:31 AM #8670Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Any suggestions? Though will it be free? If so any good free website places? Then i get the website What do you do after that?
Zitat von FaT3oYCG


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