PDA

View Full Version : I'm Learning Lua



scottyboynow
January 2nd, 2007, 13:00
Thanks to inspiration by splodger15, I'd thought that I'll try out LUA. Here Is A Little Test. It is only a script.lua file at 242 bytes Approx. I dont have news access so I posted here.

Zion
January 2nd, 2007, 13:13
what does it do?

scottyboynow
January 2nd, 2007, 13:22
Nothing, wheres Splodger15 and dejkirkby they might want to see this.

splodger15
January 2nd, 2007, 13:32
Nice work scotty.Its good to see your understanding it. I added a background for you.You may be able to see the changes in the code

scottyboynow
January 2nd, 2007, 13:34
Thanks, I'm slowly getting there.I am going to try make a simple game like Ping Pong next.
PS. I Lurve The WII

splodger15
January 2nd, 2007, 13:40
You should try some basic player controls

scottyboynow
January 2nd, 2007, 13:42
Yeah, and a select screen, two players, choose colour of bar,etc.

splodger15
January 2nd, 2007, 13:43
Let us know how you get on

scottyboynow
January 2nd, 2007, 13:44
Ok, won't be starting straight away, But I'll let you know how I get on.

scottyboynow
January 2nd, 2007, 14:07
Just started the main Files. There all blank at the moment and I will start later today.

dejkirkby
January 2nd, 2007, 14:09
Cool. Well done dude. Keep learning and you will get better.:thumbup:

jak66
January 2nd, 2007, 14:30
Splodger, would you be able to help me clear my lua script up? I'm trying to make it use up as little memory as possible, but dont know what else i would need to do (most memory is taken up by the pictures though)

P.S. Sorry for hijacking this thread scotty
P.S.S. Is there a 'frogger' port to the PSP, or would i have to play it through an emulator?

scottyboynow
January 2nd, 2007, 15:31
It's okay. I dont know About The Frogger Port Thought

splodger15
January 2nd, 2007, 16:19
Everything seems ok Jak although i might need your help for a cursor in Where's Sora.Here is the script for it

LimeGreen = Color.new(50, 205, 50)
Background = Image.load("images/MENU.PNG")
Black = Color.new(0, 0, 0)
Red = Color.new(255, 0, 0)
menu = true


pic = {}
pic[1] = Image.load("images/1.PNG")
pic1 = {}
pic1.w = 42 --width
pic1.h =27 --height
pic1.x = 230 --x val
pic1.y = 114 --y val
--pic[2] = Image.load("images/2.PNG")
pic2 ={}
pic2.w = 42
pic2.h = 14
pic2.x = 173
pic2.y = 84
--pic[3] = Image.load("images/3.PNG")
pic3 ={}
pic3.w =21
pic3.h=21
pic3.x=173
pic3.y=172
--pic[4] = Image.load("images/4.PNG")
pic4 ={}
pic4.w =24
pic4.h =41
pic4.x =153
pic4.y =94
--pic[5] = Image.load("images/5.PNG")
pic5 ={}
pic5.w= 480
pic5.h= 272
pic5.x= 0
pic5.y= 0
--pic[6] = Image.load("images/6.PNG")
pic6 ={}
pic6.w=42
pic6.h=24
pic6.x=187
pic6.y=30
--pic[7] = Image.load("images/7.PNG")
pic7 ={}
pic7.w=16
pic7.h=23
pic7.x=312
pic7.y=174


-----Loads images--------


------Loading Screen--------

screen:print(194, 136, "Loading 8%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 23%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 38%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 44%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 56%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 61%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 79%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 88%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 95%", LimeGreen)
screen:flip()

screen:clear()
screen:print(194, 136, "Loading 100%", LimeGreen)
screen:flip()

screen.waitVblankStart(240)


while true do

while menu == true do

current = 1
oldpad = Controls.read()

--while true do

pad = Controls.read()
screen:clear()

----prints to the screen-------
screen:blit(0, 0, Background)
screen:print(200, 130, "Start game", Black)
screen:print(200, 140, "Instructions", Black)
screen:print(200, 150, "Credits", Black)
screen:print(130, 230, "To exit press the Home button", Black)

-----this code is so that when you highlight an option in a menu it turns red-----
if current == 1 then
screen:print(200, 130, "Start game", Red)
end

if current == 2 then
screen:print(200, 140, "Instructions", Red)
end

if current == 3 then
screen:print(200, 150, "Credits", Red)
end


-----this makes it so that you can scroll through your menu----
if pad:up() and oldpad:up() ~= pad:up() then
current = current-1
end

if pad:down() and oldpad:down() ~= pad:down() then
current = current+1
end

if current == 4 then
current = 1
end

if current == 0 then
current = 3
end

-----this is to select your menu options------
if pad:cross() then
menu = false
end


screen.waitVblankStart()
screen:flip()
oldpad = pad
--end
end -- menu


if current == 1 then
cnt = 1
while true do
screen:clear()
Image:fillRect(x,y,5,5,Red)
screen:flip()
pad = Controls.read()
if pad~= oldpad then
-- if pad:cross() and then cnt = cnt + 1 end
if pad:start() then
menu = true
break
end
if pad:left() then x = x-1 end
if pad:right() then x = x+1 end
if pad:up() then y = y - 1 end
if pad:down() then y = y +1 end
if (x > pic..tostring(cnt).x) and (x < pic..tostring(cnt).x+pic..tostring(cnt).w) and (y > pic..tostring(cnt).y)
and (y < pictostring(cnt).y+pictostring(cnt).h) and(pad:cross()) then
cnt = cnt+1

end
oldpad = pad
end
if pic[cnt] then
pic[cnt] = Image.load("images/"..tostring(cnt)..".png")
-- screen:blit(x,y,curser)

screen:blit(0,0,pic[cnt])
screen:flip()
else
screen:print(0,0,"Compleated",red)
break
end
screen:flip()
end

end
end -- if current = 1

if current == 2 then
instructions = Image.load("images/instructions.png")
while true do

pad = Controls.read()
screen:blit(0, 0, instructions)
if pad:square() then
menu = true
break
end
screen:flip()
end
end

if current == 3 then
credits = Image.load("images/credits.png")
while true do

pad = Controls.read()
screen:blit(0, 0, credits)

if pad:square() then
menu = true
break
end
screen:flip()
end


end

jak66
January 2nd, 2007, 16:49
thats cool, just PM me if/when you need help