PDA

View Full Version : variable stating code



gunntims0103
December 17th, 2006, 04:10
i was just wondering if it is possible in LUA to state a code as a variable then using the variable in a function for example


Background = Image.load("image/screen")

3d = screen:blit
3donscreen = screen:flip
3dloop = screen.waitVblankStart()

3d(0, 0, Background)
3donscreen
3dloop
end

is this code valid and can this be done. I tried this when i was implamenting a map for splonger15 in psp turismo and i just wanted to find out if i could state code as a variable. I tried it but i got errors.

gunntims0103
December 17th, 2006, 19:27
does no one no the anwser to this?

Im just wondering so when i code i dont have to keep using the code instead i can use the variable that the code is defined as...

Jeremysr
December 17th, 2006, 21:16
No I don't think that's possible in lua. Maybe you should use functions instead?

function Background()
return Image.load("image/screen")
end

function 3d()
screen:blit
end

function 3donscreen()
screen:flip
end

function 3dloop()
screen.waitVblankStart()
end

3d(0, 0, Background())
3donscreen()
3dloop()
end

Something like that...I couldn't really understand your code because there weren't any line breaks and I don't use PSP lua I use DSLua.