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; Code: layer = {} layer[1] = ImageCreateEmpty(480,272) layer[2] = ImageCreateEmpty(480,272) while true do layer[1]:blit(maspritez,0,0) layer[2]:blit(mabackgrowndz,0,0) screen.flip() screen.waitVblankStart() end Probably a ...
-
09-15-2008, 08:07 AM #9421Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Probably a few small errors, haven't used Lua for a while.Code:layer = {} layer[1] = ImageCreateEmpty(480,272) layer[2] = ImageCreateEmpty(480,272) while true do layer[1]:blit(maspritez,0,0) layer[2]:blit(mabackgrowndz,0,0) screen.flip() screen.waitVblankStart() end
Is this what you meant ?
Geändert von eldiablov (09-15-2008 um 08:28 AM Uhr)
-
09-15-2008, 08:13 AM #9422Seven Year Vet. BOW DOWN.

- Registriert seit
- Dec 2005
- Ort
- Manchester, UK
- Beiträge
- 2.240
- Points
- 14.794
- Level
- 78
- My Mood
-
- Downloads
- 1
- Uploads
- 0
-
09-15-2008, 09:22 AM #9423Lua guy
- Registriert seit
- Jan 2008
- Ort
- Wales, cardiff
- Beiträge
- 1.442
- Points
- 11.690
- Level
- 71
- My Mood
-
- Downloads
- 0
- Uploads
- 0
-
09-17-2008, 11:04 AM #9424QJ Gamer Gold
- Registriert seit
- May 2005
- Ort
- I live in a City that goes by the nickname:The Bubble. 'Nuff said.
- Beiträge
- 1.766
- Points
- 13.240
- Level
- 74
- Downloads
- 0
- Uploads
- 0
Heres my issue. at the the transition from (Pressing start to play) to (loading "intro) I dont want to use the command
"screen.waitVblankStart() "
because i dont want it to wait. I want it to stay there UNTILL I press start!!
what should I do to display "intro" (its a picture that takes up the whole screen) after I press start also.
So here is my code:
pink = Color.new(255, 0 , 153)
blue = Color.new(0 , 153, 255)
orange = Color.new(255, 102, 0)
gray = Color.new(153, 153, 153)
black = Color.new(0 , 0 , 0)
green = Color.new(0, 255, 0)
white = Color.new(225, 225, 225)
--*****LOADING SCREEN*****
screen
rint(194, 136, "Loading: 0%", blue)
screen.flip()
screen.waitVblankStart(60 )
screen:clear()
intro = Image.load("abaddonsparra ble/introscreen.png")
screen
rint(194, 136, "Loading: 20%", blue)
screen.flip()
screen.waitVblankStart(60 )
screen:clear()
lvlone = Image.load("abaddonsparra ble/levelone intro.png")
screen
rint(194, 136, "Loading: 40%", blue)
screen.flip()
screen.waitVblankStart(60 )
screen:clear()
story = Image.load("abaddonsparra ble/story.png")
screen
rint(194, 136, "Loading: 60%", blue)
screen.flip()
screen.waitVblankStart(60 )
screen:clear()
choiceone = Image.load("abaddonsparra ble/choice1.png")
screen
rint(194, 136, "Loading: 80%", blue)
screen.flip()
screen.waitVblankStart(60 )
screen:clear()
screen
rint(194, 136, "Loading: 100%", blue)
screen.flip()
screen.waitVblankStart(60 )
screen:clear()
screen
rint(194, 136, "Press START to play", white)
screen.flip()
pad = Controls.read()
if pad:start() then
screen:clear()
screen:blit(0, 0, intro)
screen.flip()
end
-
09-17-2008, 12:30 PM #9425QJ Gamer Blue
- Registriert seit
- Jul 2007
- Beiträge
- 296
- Points
- 3.795
- Level
- 38
- Downloads
- 0
- Uploads
- 0
You would need to load the images in a separate thread so that the graphics can be updated each frame. I'm not really sure if Lua (on the PSP?) has any threading support, but I would look it up if I were you.
Actually, what? Can you elaborate please?
-
09-17-2008, 02:00 PM #9426NetGameOrb Maker

- Registriert seit
- Jan 2008
- Ort
- New York
- Beiträge
- 683
- Points
- 6.138
- Level
- 50
- My Mood
-
- Downloads
- 2
- Uploads
- 0
you can do a while loop if you like for example
note*: it may have some error because i just did it so you can understandCode:inintro = 1 perc = 0 while (inintro == 1) do screen:clear() if (perc == 0) then intro = Image.load("abaddonsparra ble/introscreen.png") perc = 10 else if (perc == 10) then lvlone = Image.load("abaddonsparra ble/levelone intro.png") else if (perc == 100) then screenrint(194, 140, "Press START to play", white) pad = Controls.read() if pad:start() then inintro = 0 end end screen:print(194, 136, "Loading: "..perc.."%", blue) screen.flip() end while (1) do //start game stuff end
just keep on using else if for every perc you want to use and modifier the perc so it blit propertyGameLive name changed to NetGameOrb, Project is now online in Beta stage. Everyone encourage to register so they get news about the project and ability to play the games with NetGameOrb Support online. More info on site.
Stats Blog:http://netgameorb.blogspot.com/
Website:http://www.netgameorb.com/
-
09-17-2008, 02:52 PM #9427QJ Gamer Gold
- Registriert seit
- May 2005
- Ort
- I live in a City that goes by the nickname:The Bubble. 'Nuff said.
- Beiträge
- 1.766
- Points
- 13.240
- Level
- 74
- Downloads
- 0
- Uploads
- 0
well this whole game is just going to be like a scenario game.
for example, here is the first choice you make in the game.

It is just going to be whether you press ^, O, or X and it will load another picture with some story line, and then another choice.
I didnt think the code would be that advanced just to load a picture after pressing a button.
-
09-17-2008, 03:45 PM #9428NetGameOrb Maker

- Registriert seit
- Jan 2008
- Ort
- New York
- Beiträge
- 683
- Points
- 6.138
- Level
- 50
- My Mood
-
- Downloads
- 2
- Uploads
- 0
ok let me if i can understand you.
you want to show first a loading animation/screen first to load the images, then you want to blit a serctaine image to the screen depening on the button user press?
if so then it as easy as making 2 while loops one to load all the images and the second to ask the user to press a button and then blit that image to screen
example:
like last time note that commands are not propertly use or missing something, it just meant to give you a idea on how to do it, it simple if you understand what it doing and try it you self :) good luckCode:---Example by Thecobra--- inloading = 1 --say if we are still loading images perc = 0 --how many images we load in percentage while(inloading == 1) do ---if we are still laoding then-- screen.clear() screen:print("loading.."..perc,Color(0,0,255)) screen.flip() if (perc == 0) then intro = Image.load("abaddonsparra ble/introscreen.png") --load intro image-- perc = 10 else if (perc ==10) then image1 = Image.load("abaddonsparra ble/image1.png") --load image 1 if perc = 10-- perc = 20 else if (perc == 20) then image2 = Image.load("abaddonsparra ble/image2.png") --load image 2 if perc = 20-- perc = 30 ---so on and so on for else if-- else if (perc == 100) then --ok we loaded everything so let exit our loop of loading-- inloading = 0 end end --now let start our real program :) --- imgtodisplay = 1 while true do pad = Controls.read() screen.clear() if imgtodisplay == 1 then screen:blit(intro) end if imgtodisplay == 2 then screen:blit(image1) end if imgtodisplay == 3 then screen:blit(image2) end if imgtodisplay == 4 then screen:blit(image3) end if pad:triangle then --set current image to something else-- imgetodisplay = 2 end if pad:square then --set current image to something else-- imgetodisplay = 3 end if pad:circle then --set current image to something else-- imgetodisplay = 4 end --print out some txt-- screen:print("press triangle to display image 1") screen:print("press square to display image 2") screen:print("press circle to display image 3") screen.flip() endGameLive name changed to NetGameOrb, Project is now online in Beta stage. Everyone encourage to register so they get news about the project and ability to play the games with NetGameOrb Support online. More info on site.
Stats Blog:http://netgameorb.blogspot.com/
Website:http://www.netgameorb.com/
-
09-17-2008, 03:57 PM #9429OMFG

- Registriert seit
- Jul 2005
- Ort
- Toronto
- Beiträge
- 2.814
- Points
- 19.453
- Level
- 88
- Downloads
- 0
- Uploads
- 0
-
09-17-2008, 04:09 PM #9430QJ Gamer Gold
- Registriert seit
- May 2005
- Ort
- I live in a City that goes by the nickname:The Bubble. 'Nuff said.
- Beiträge
- 1.766
- Points
- 13.240
- Level
- 74
- Downloads
- 0
- Uploads
- 0
-
09-17-2008, 04:30 PM #9431QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Got bored so here is a framework in pure Lua that is easily scalable (virtually data driven). You should be able to understand the code and make it work for PSP and your needs.
Code:-- Constants DIRECTION_NORTH = 1; DIRECTION_EAST = 2; DIRECTION_SOUTH = 3; DIRECTION_WEST = 4; roomList = {}; -- Create the rooms roomList[0] = { imageFilename = "", debugText = "RoomA, exits: West and South", exitRooms = {} }; roomList[1] = { imageFilename = "", debugText = "RoomB, exits: East and South", exitRooms = {} }; roomList[2] = { imageFilename = "", debugText = "RoomC, exits: East and North", exitRooms = {} }; roomList[3] = { imageFilename = "", debugText = "RoomD, exits: West and North", exitRooms = {} }; -- Map the rooms together roomList[0].exitRooms[DIRECTION_WEST] = roomList[1]; roomList[0].exitRooms[DIRECTION_SOUTH] = roomList[3]; roomList[1].exitRooms[DIRECTION_EAST] = roomList[0]; roomList[1].exitRooms[DIRECTION_SOUTH] = roomList[2]; roomList[2].exitRooms[DIRECTION_EAST] = roomList[3]; roomList[2].exitRooms[DIRECTION_NORTH] = roomList[0]; roomList[3].exitRooms[DIRECTION_WEST] = roomList[2]; roomList[3].exitRooms[DIRECTION_NORTH] = roomList[0]; bGameFinished = false; currentRoom = roomList[0]; function ChangeRooms( direction ) newRoom = currentRoom.exitRooms[direction]; if newRoom ~= nil then currentRoom = newRoom; end end while not bGameFinished do print( currentRoom.debugText ); local sPlayerInput = io.read(); sPlayerInput = string.upper( sPlayerInput ); if "Q" == sPlayerInput then bGameFinished = true; elseif "N" == sPlayerInput then ChangeRooms( DIRECTION_NORTH ); elseif "S" == sPlayerInput then ChangeRooms( DIRECTION_SOUTH ); elseif "W" == sPlayerInput then ChangeRooms( DIRECTION_WEST ); elseif "E" == sPlayerInput then ChangeRooms( DIRECTION_EAST ); end 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]
-
09-18-2008, 04:23 AM #9432NetGameOrb Maker

- Registriert seit
- Jan 2008
- Ort
- New York
- Beiträge
- 683
- Points
- 6.138
- Level
- 50
- My Mood
-
- Downloads
- 2
- Uploads
- 0
GameLive name changed to NetGameOrb, Project is now online in Beta stage. Everyone encourage to register so they get news about the project and ability to play the games with NetGameOrb Support online. More info on site.
Stats Blog:http://netgameorb.blogspot.com/
Website:http://www.netgameorb.com/
-
09-18-2008, 06:53 AM #9433QJ Gamer Gold
- Registriert seit
- May 2005
- Ort
- I live in a City that goes by the nickname:The Bubble. 'Nuff said.
- Beiträge
- 1.766
- Points
- 13.240
- Level
- 74
- Downloads
- 0
- Uploads
- 0
-
09-18-2008, 07:53 AM #9434Banned for LIFE
- Registriert seit
- Oct 2006
- Ort
- East London, England
- Beiträge
- 2
- Points
- 18.744
- Level
- 86
- Downloads
- 0
- Uploads
- 0
Have you looked at yaustars code ? :/
-
09-18-2008, 02:58 PM #9435QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
-
09-18-2008, 03:16 PM #9436QJ Gamer Gold
- Registriert seit
- May 2005
- Ort
- I live in a City that goes by the nickname:The Bubble. 'Nuff said.
- Beiträge
- 1.766
- Points
- 13.240
- Level
- 74
- Downloads
- 0
- Uploads
- 0
-
09-18-2008, 03:50 PM #9437QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
As said earlier, it is a pure Lua framework. If you want to make it work with LuaPlayer and use button input, you have to do the legwork yourself. If I just give you the exact code, you won't learn or understand anything.
If the code I have given is too complex, then work in baby steps towards it.
You first step should be switching between two images using a button press.
Brief:
- When the program loads up, it displays image A
- When the user presses SQUARE, it displays image B
- When the user presses SQUARE again, it displays image A
- When the user presses SQUARE again, it displays image B
- etc
Post your code here when you have done this.[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]
-
09-18-2008, 07:46 PM #9438QJ Gamer Gold
- Registriert seit
- May 2005
- Ort
- I live in a City that goes by the nickname:The Bubble. 'Nuff said.
- Beiträge
- 1.766
- Points
- 13.240
- Level
- 74
- Downloads
- 0
- Uploads
- 0
its probably going to take me a couple days to get it working, and thank you again for the framework.
In the meantime, could you tel me whats wrong with this code?
its for my menu.
when I run it I get the error for line 111: 'then' expected near '='
--********MENU*********
red = Color.new(255,0,0)
black = Color.new(0,0,0)
white = Color.new(255,255,255)
menustatus = 1
while true do
screen:clear(black)
pad = Controls.read()
if pad:up() then
menustatus = menustatus - 1
screen.waitVblankStart(4)
end
if pad:down() then
menustatus = menustatus + 1
screen.waitVblankStart(4)
end
color={white, white, white}
screen
rint(50, 50, "Start Game", color[1])
screen
rint(50,60,"Controls", color[2])
screen
rint(50,70,"Exit", color[3])
color[menustatus]=red
if menustatus == 1 then
if pad:cross() then
end
end
if menustatus == 2 then
if pad:cross() then
screen
rint(50,50,"Press Triangle to move North", white)
screen
rint(50,60,"Press Circle to move East", white)
screen
rint(50,70,"Press Cross To Move South", white)
screen
rint(50,80,"Press Square to move West", white)
screen:Print(380,100,"Pre ss Triangle to go back to main menu", blue)
if pad:triangle() then
menustatus = 1
end
end
end
if menustatus == 3 then
if pad:cross() then
break
end
end
if menustatus <= 0 then
menustatus = 3
end
if menustatus => 4 then
menustatus = 1
end
screen.flip()
screen.waitVblankStart()
end
-
09-18-2008, 08:00 PM #9439QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
The point was for you to take baby steps toward a framework, not for us to continue helping you hardcode it.
[size=3][url=http://luaplayer.org/forums/index.php?topic=507]Complete Lua development cycle outline[/url][/size]
-
09-18-2008, 08:58 PM #9440QJ Gamer Gold
- Registriert seit
- May 2005
- Ort
- I live in a City that goes by the nickname:The Bubble. 'Nuff said.
- Beiträge
- 1.766
- Points
- 13.240
- Level
- 74
- Downloads
- 0
- Uploads
- 0
-
09-18-2008, 09:01 PM #9441QJ Gamer Green
- Registriert seit
- Jan 2008
- Beiträge
- 612
- Points
- 3.721
- Level
- 38
- Downloads
- 0
- Uploads
- 0
-
09-18-2008, 09:30 PM #9442
- Registriert seit
- Feb 2008
- Beiträge
- 12
- Points
- 2.679
- Level
- 31
- Downloads
- 0
- Uploads
- 0
Are you an idiot? There isn't even 111 lines there, only 70.
Also, I agree with TP, this is a help thread, not a learn how to walk thread. Take a little pride in your work please, don't hard code everything, otherwise your programs will be a giant mess of crap that no one will want to look at and you will go down in history with the other thousands of PSP lua noobs.
-
09-18-2008, 10:16 PM #9443words 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
legacy check your operators..... more specifically, greater-then-equal-to... (it isn't => if you're stumped)

...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
-
09-19-2008, 01:45 AM #9444QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
[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]
-
09-23-2008, 10:17 PM #9445
I've been looking over Red Squirrels CTF unpacker src. Any way this could be done in lua ?? (attached src)
Any help I could get achieving this would be greatly appreciated.
Thanks
~shizzyPSP: PSP SLIM 2001 TA-088v2Custom Firmware: 5.00 M33-6
-
09-24-2008, 01:35 AM #9446QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
It can be done relatively easily.
This should get you started:
Code:function string.Mbyte(s) local r = {} for i=1, string.len(s) do table.insert(r, string.byte(string.sub(s, i, i))) end return r end function string.NMbyte(s) local b = string.Mbyte(s) local r = "" for i, n in ipairs(b) do r = r .. tostring(n) end return tonumber(r) end function string.stripNull(string) local r,n = string.gsub(string,"%z.*$","") if n ~= 1 then return r else return "" end end function readBits(stringa, l) stringa = string.reverse(stringa) local value = 0 for i=1, l / 8 do value = value + string.byte(string.sub(stringa,i,i)) * (256 ^ (i - 1)) end return value end function CPTFHeader(file) return { sig = file:read(4), version = string.NMbyte(file:read(4)), --? name = string.stripNull(file:read(8)), magic = file:read(4), checksum = file:read(4), --? headercount = readBits(file:read(4), 32), size = readBits(file:read(4), 32) } end function CTFPatchHeader(file) return { name = string.stripNull(file:read(64)), start = readBits(file:read(4), 32), size = readBits(file:read(4), 32) } end
Also, the basic structure of a CTF:
[PTF file with modified header] (CPTFHeader)
[Patch files]
[Patch file headers] (CTFPatchHeader)Geändert von Nielkie (09-24-2008 um 06:18 AM Uhr)
-
09-24-2008, 06:15 AM #9447
-
09-24-2008, 06:19 AM #9448QJ Gamer Bronze

- Registriert seit
- Jul 2006
- Beiträge
- 550
- Points
- 5.381
- Level
- 47
- Downloads
- 1
- Uploads
- 0
Gah, "repetitively". Damn you FF spellcheck!
-
09-29-2008, 02:08 PM #9449QJ Gamer Green
- Registriert seit
- Sep 2005
- Ort
- Texas
- Beiträge
- 146
- Points
- 5.981
- Level
- 50
- Downloads
- 0
- Uploads
- 0
I can't for the life of me figure out how to make a texture on a 3d object semi transparent, can someone help me out?
[IMG]http://img.photobucket.com/albums/v693/fchaos/koolaidsig.jpg[/IMG]
-
09-29-2008, 03:46 PM #9450QJ Gamer Gold

- Registriert seit
- Jul 2005
- Ort
- everywhere
- Beiträge
- 3.526
- Points
- 17.453
- Level
- 84
- Downloads
- 1
- Uploads
- 0
i'm not vary familiar with lua's 3D functions, however understanding openGL, and the pspgu, i'd suggest looking in the documentation for lua(which ever one your using, but i suspect pge?), for method calls which contain the word blend
1. Failed....again...
2. http://slicer.gibbocool.com/ stay updated on all my projects
3. it'll be 5 years in june, that's nearly 1/4 of my life on this planet that i've visited these forums, what a ride it has been


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