Array? Extraction

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
Danny769
Posts: 55
Joined: Wed Feb 01, 2006 12:29 pm

Array? Extraction

Post by Danny769 »

Ok here it the deal im making an array for a class cits
Cits need (HP,Wood,Food,Gold,Stone,Qunity,X,Y)

Ok now my question is, what is the code to extract a single cell, and to write to a single cell in an array

The Folling Is an Example of my Array

Code: Select all

a, b, c, d, e, f, g, h = 0

Cit = {}

for a = 0, 20 do 
  Cit[a] = {} 
   for b = 0, 20 do 
    Cit[a][b] = {} 
    for c = 0, 20 do 
      Cit[a][b][c] = {}
       for d = 0, 20 do 
        Cit[a][b][c][d] = {}
         for e = 0, 20 do 
          Cit[a][b][c][d][e] = {} 
           for f = 0, 20 do 
            Cit[a][b][c][d][e][f] = {} 
             for g = 0, 20 do 
              Cit[a][b][c][d][e][f][g] = {}
               for h = 0, 20 do 
                Cit[a][b][c][d][e][f][g][h] = {}
           end
          end
         end
        end
       end
      end 
    end 
  end 
Danny769
Posts: 55
Joined: Wed Feb 01, 2006 12:29 pm

Post by Danny769 »

http://www.evilmana.com/tutorials/lua_tutorial_05.php

sorry about that but i found what i wanted

Cit = {}
Cit[1] = { HP = DefaultHP, Wood = 1, Gold = 0, Stone = 0, Food = 0, Qunity = 100}
Cit[2] = { HP = DefaultHP, Wood = 1, Gold = 0, Stone = 0, Food = 0, Qunity = 100}
Cit[3] = { HP = DefaultHP, Wood = 1, Gold = 0, Stone = 0, Food = 0, Qunity = 100}

Cit[1].HP = Cit[1].HP - 10

Ok i get it now Sorry about that
Post Reply