Forum    News    Downloads    Saved Games


Concerning Lua Coding...

<<

mice R nice

User avatar

Brewery Master
Brewery Master

Posts: 1369

Joined: June 30 2007

Location: Caught in a mouse trap... DARN

Thanks given: 0

Thanks received: 0

Post Fri Aug 08, 2008 6:53 pm

mice R nice ~(_"> wrote:BWAWHAHA, crait


Ha, I knew it!
Image
<<

crait

User avatar

Brewology Administrator
Brewology Administrator

Posts: 6488

Joined: August 11 2006

Location: Narnia!

Thanks given: 195 times

Thanks received: 51 times

Post Fri Aug 08, 2008 7:04 pm

;)
It was pretty fun.
And I never knew what the concatenation sign in LUA was.
<<

roxfox64

User avatar

Brew Guru
Brew Guru

Posts: 2287

Joined: June 12 2007

Location: Smyrna, GA Current Status: Its true... I am a fur.

Thanks given: 0

Thanks received: 2 times

Post Fri Aug 08, 2008 8:43 pm

DAMN IT...

I was gonna do that when I got free time...

:cry:
5.00M33-6
Image
Image Veemon
Image
Image
<<

crait

User avatar

Brewology Administrator
Brewology Administrator

Posts: 6488

Joined: August 11 2006

Location: Narnia!

Thanks given: 195 times

Thanks received: 51 times

Post Fri Aug 08, 2008 10:01 pm

Beat ya to it again! Muhahaha!
<<

roxfox64

User avatar

Brew Guru
Brew Guru

Posts: 2287

Joined: June 12 2007

Location: Smyrna, GA Current Status: Its true... I am a fur.

Thanks given: 0

Thanks received: 2 times

Post Fri Aug 08, 2008 10:49 pm

Well, I'll just have Manda give me a PB&J
;)
5.00M33-6
Image
Image Veemon
Image
Image
<<

crait

User avatar

Brewology Administrator
Brewology Administrator

Posts: 6488

Joined: August 11 2006

Location: Narnia!

Thanks given: 195 times

Thanks received: 51 times

Post Fri Aug 08, 2008 11:09 pm

:D
I like those. She gives very good PB&J's!!
Almost as good as Jessica. :P
<<

mice R nice

User avatar

Brewery Master
Brewery Master

Posts: 1369

Joined: June 30 2007

Location: Caught in a mouse trap... DARN

Thanks given: 0

Thanks received: 0

Post Fri Aug 08, 2008 11:19 pm

But not nearly as gewd as whitney
Image
<<

roxfox64

User avatar

Brew Guru
Brew Guru

Posts: 2287

Joined: June 12 2007

Location: Smyrna, GA Current Status: Its true... I am a fur.

Thanks given: 0

Thanks received: 2 times

Post Fri Aug 08, 2008 11:21 pm

#1 Shut up! Don't talk sh*t!

#2 Who???

#3 I need your help. PM me.
5.00M33-6
Image
Image Veemon
Image
Image
<<

Yumiko

User avatar

Mega Brewer
Mega Brewer

Posts: 892

Joined: May 25 2008

Location: California, US Firmware: 3.90M33-3

Thanks given: 2 times

Thanks received: 2 times

Post Sun Aug 10, 2008 8:28 pm

Umm...that was a little bit clearer. But thanks for the long and detailed elaboration :D
由美子
<<

crait

User avatar

Brewology Administrator
Brewology Administrator

Posts: 6488

Joined: August 11 2006

Location: Narnia!

Thanks given: 195 times

Thanks received: 51 times

Post Mon Aug 11, 2008 12:23 pm

Haha. Just read it all the way through instead of skipping around and it should be kinda like a story. :D
But no problem!
<<

Yumiko

User avatar

Mega Brewer
Mega Brewer

Posts: 892

Joined: May 25 2008

Location: California, US Firmware: 3.90M33-3

Thanks given: 2 times

Thanks received: 2 times

Post Mon Aug 11, 2008 2:39 pm

I did read it all the way :P
由美子
<<

roxfox64

User avatar

Brew Guru
Brew Guru

Posts: 2287

Joined: June 12 2007

Location: Smyrna, GA Current Status: Its true... I am a fur.

Thanks given: 0

Thanks received: 2 times

Post Mon Aug 11, 2008 8:08 pm

Re: Concerning Lua Coding...

Hellz yeah! My turn :twisted:

keys = {
{ "C", "sin", "cos", "tan" },
{ "1/x", "x^2", "sqr", "/" },
{ "7", "8", "9", "*" },
{ "4", "5", "6", "-" },
{ "1", "2", "3", "+" },
{ "0", "+/-", ".", "=" } }
This is just an array, basicly, how it will map out in the end.


color = Color.new(0, 255, 0)
Just your average varible

function drawRect(x0, y0, w, h)
screen:drawLine(x0, y0, x0+w, y0, color)
screen:drawLine(x0, y0, x0, y0+h, color)
screen:drawLine(x0+w, y0, x0+w, y0+h, color)
screen:drawLine(x0+w, y0+h, x0, y0+h, color)
end
This is a userdefined function. It draws a rectangle.

oldPad = Controls.read()
x = 1
y = 1
text = "0"
lastNumber = 0
deleteOnKey = true
lastOperation = ""
value = ""
number = 0
[color=red]More varibles. All for various reasons.


while true do
"While" starts the main loop. It will continue to run until the loop is broken.

pad = Controls.read()
if pad ~= oldPad then
if pad:triangle() then
screen:save("calculator.tga")
end A screenshot function

if pad:left() then
x = x - 1
if x == 0 then
x = 4
end
end
if pad:right() then
x = x + 1
if x == 5 then
x = 1
end
end
if pad:up() then
y = y - 1
if y == 0 then
y = 6
end
end
if pad:down() then
y = y + 1
if y == 7 then
y = 1
end
endThe directional if statements. They correspond with the draw rect function above. Also, if the max space has been reached it makes it "warp" to the other side.

if pad:cross() then
value = keys[y][x]
number = tonumber(text)
if value == "C" then
The functions part :P
text = "0"
lastNumber = 0
lastOperation = ""
deleteOnKey = true
elseif value == "1/x" then
text = tostring(1/number)
elseif value == "sin" then
text = tostring(math.sin(number))
elseif value == "cos" then
text = tostring(math.cos(number))
elseif value == "tan" then
text = tostring(math.tan(number))
elseif value == "x^2" then
text = tostring(number*number)
elseif value == "sqr" then
text = tostring(math.sqrt(number))
elseif value == "/" or value == "*" or value == "-" or value == "+" or value == "=" then
if lastOperation == "/" then
text = tostring(lastNumber / number)
elseif lastOperation == "*" then
text = tostring(lastNumber * number)
elseif lastOperation == "-" then
text = tostring(lastNumber - number)
elseif lastOperation == "+" then
text = tostring(lastNumber + number)
end
number = tonumber(text)
if value == "=" then
text = tostring(number)
lastOperation = ""
else
lastNumber = number
lastOperation = value
end
deleteOnKey = true
elseif value == "+/-" then
text = tostring(-number)
else
if deleteOnKey then
text = value
deleteOnKey = false
else
text = text .. value
end
end
end
if pad:start() then
break
end
oldPad = pad
end
I'm kinda lazy, so if you want this part explained just ask.


screen:clear()
yk = 0
w = 40
h = 30
drawRect(w, 0, w * 4, h-2)
screen:print(w+4, 4, text, color)
for yindex,line in ipairs(keys) do
for xindex,key in ipairs(line) do
x0 = xindex * w
y0 = yindex * h
drawRect(x0, y0, w, h)
if xindex == x and yindex == y then
screen:fillRect(x0, y0, w, h, color)
foreground = Color.new(0, 0, 0)
else
foreground = color
end
screen:print(x0 + 5, y0 + 5, key, foreground)
end
end
screen.waitVblankStart()
screen.flip()
The code that displays everything.
end
The end of the script.
5.00M33-6
Image
Image Veemon
Image
Image
<<

Yumiko

User avatar

Mega Brewer
Mega Brewer

Posts: 892

Joined: May 25 2008

Location: California, US Firmware: 3.90M33-3

Thanks given: 2 times

Thanks received: 2 times

Post Mon Aug 11, 2008 8:38 pm

Sorry Rox, Crait's was more clearer :P
由美子
<<

roxfox64

User avatar

Brew Guru
Brew Guru

Posts: 2287

Joined: June 12 2007

Location: Smyrna, GA Current Status: Its true... I am a fur.

Thanks given: 0

Thanks received: 2 times

Post Mon Aug 11, 2008 8:41 pm

Duh!

What don't you understand from mine and crait's?
5.00M33-6
Image
Image Veemon
Image
Image
<<

Yumiko

User avatar

Mega Brewer
Mega Brewer

Posts: 892

Joined: May 25 2008

Location: California, US Firmware: 3.90M33-3

Thanks given: 2 times

Thanks received: 2 times

Post Mon Aug 11, 2008 8:42 pm

All of it. I don't know, the way you say it doesn't make sense to me at all. I think I'm being ot much of a bother :S
由美子
PreviousNext

Return to PSP Help

Who is online

Users browsing this forum: No registered users and 101 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for blacklist.org.