• HOME
  • forums
  • Tutorials
    • Lua Codes>
      • move
      • menu
    • pspLua>
      • intro
      • lesson1: helloWorld
      • lesson2: variables
      • lesson3: tables
      • lesson4: Draw images
      • Lesson5: Music
    • how to hack your psp
  • Hacks n' stuff
  • PSP APPS
  • Blogs
    • SUGGESTIONblog
    • CHATblog
    • DEVblog
  • AutoGrapher V1.00
  • PgffSP
  • GENESIS P
  • SURVEY
  • Android
  • Spacial Warfare
  • Past Times
  • TUT For Inkscape IMGS
Handheld Development

Lesson 3: tables

Tables are a lot like variables except they store more information in them. In this lesson we will make a text that will appear at a location stored in a table and will display info stored in a table.

To make a table all that you need to do is type

myTable = {}

Ok so now let me show you an example

fruits = {}
fruits[1] = "apple"
fruits[2] = "cherry"
fruits[3] = "banana"

This is easy right? Ok so lets make are program
lets make are colors, tables and start are loop.

blue = Color.new(0,0,255)
position = {}
position[1] = (x = 100, y = 200)
text = {}
text[1] = "this is in a table!!"
while true do

Ok so we created a table, position, that has the x and y position stored in it and we created a table, text, that has some text stored in it.

so lets move on to the loop.

screen:print(position[1].x,position[1].y,text[1],blue)
screen.flip()
screen.waitVblankStart()
end

So you may notice we put position[1].x and one for y. You may wonder what this is. this means that from the table position[1] get the data for X.

OK! so save as Table.lua and try out. you now know how to make a table! please continue on to the next lesson!

back                                                       next
Powered by
✕