Class: Table

Inherits:
Object show all
Defined in:
LiteRGSS.rb.yard.rb

Overview

Class that store a 3D array of value coded with 16bits (signed)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xsize, ysize = 1, zsize = 1) ⇒ Table

Note:

Never call initialize from the Ruby code other than using Table.new. It'll create memory if you call initialize from Ruby, use #resize instead.

Create a new table without pre-initialization of the contents

Parameters:

  • xsize (Integer) —

    number of row

  • ysize (Integer) (defaults to: 1) —

    number of cols

  • zsize (Integer) (defaults to: 1) —

    number of 2D table



1290
1291
1292
# File 'LiteRGSS.rb.yard.rb', line 1290

def initialize(xsize, ysize = 1, zsize = 1)

end

Instance Attribute Details

#dim ⇒ Integer (readonly)

Returns Dimension of the table (1D, 2D, 3D).

Returns:

  • (Integer) —

    Dimension of the table (1D, 2D, 3D)



1329
1330
1331
# File 'LiteRGSS.rb.yard.rb', line 1329

def dim
  @dim
end

#xsize ⇒ Integer (readonly)

Returns number of row in the table.

Returns:

  • (Integer) —

    number of row in the table



1323
1324
1325
# File 'LiteRGSS.rb.yard.rb', line 1323

def xsize
  @xsize
end

#ysize ⇒ Integer (readonly)

Returns number of cols in the table.

Returns:

  • (Integer) —

    number of cols in the table



1325
1326
1327
# File 'LiteRGSS.rb.yard.rb', line 1325

def ysize
  @ysize
end

#zsize ⇒ Integer (readonly)

Returns number of 2D table in the table.

Returns:

  • (Integer) —

    number of 2D table in the table



1327
1328
1329
# File 'LiteRGSS.rb.yard.rb', line 1327

def zsize
  @zsize
end

Instance Method Details

#[](x, y = 0, z = 0) ⇒ Integer?

Access to a value of the table

Parameters:

  • x (Integer) —

    index of the row

  • y (Integer) (defaults to: 0) —

    index of the col

  • z (Integer) (defaults to: 0) —

    index of the 2D table

Returns:

  • (Integer, nil) —

    nil if x, y or z are outside of the table.



1298
1299
1300
# File 'LiteRGSS.rb.yard.rb', line 1298

def [](x, y = 0, z = 0)

end

#[]=(x, y, z, value)

Change a value in the table

Parameters:

  • x (Integer) —

    row index of the cell to affect to the new value

  • y (Integer) —

    col index of the cell to affect to the new value

  • z (Integer) —

    index of the table containing the cell to affect to the new value

  • value (Integer) —

    new value



1304
1305
1306
# File 'LiteRGSS.rb.yard.rb', line 1304

def []=(x, value)

end

#copy(table, dest_offset_x, dest_offset_y) ⇒ Boolean

Note:

If any parameter is invalid (eg. dest_offset_coord < 0) the function does nothing.

Copy another table to this table

Parameters:

  • table (Table) —

    the other table

  • dest_offset_x (Integer) —

    index of the row that will receive the first row of the other table

  • dest_offset_y (Integer) —

    index of the col that will receive the first colum of the other table

Returns:

  • (Boolean) —

    if the operation was done



1349
1350
1351
# File 'LiteRGSS.rb.yard.rb', line 1349

def copy(table, dest_offset_x, dest_offset_y)

end

#copy_modulo(table, source_origin_x, source_origin_y, dest_offset_x, dest_offset_y, width, height)

Copy another table to a specified surface of the current table using a circular copy (dest_coord = offset + source_coord % source_size)

Parameters:

  • table (Table) —

    the other table

  • source_origin_x (Integer) —

    index of the first row to copy in the current table

  • source_origin_y (Integer) —

    index of the first col to copy in the current table

  • dest_offset_x (Integer) —

    index of the row that will receive the first row of the other table

  • dest_offset_y (Integer) —

    index of the col that will receive the first colum of the other table

  • width (Integer) —

    width of the destination surface that receive the other table values

  • height (Integer) —

    height of the destination surface that receive the other table values



1360
1361
1362
# File 'LiteRGSS.rb.yard.rb', line 1360

def copy_modulo(table, source_origin_x, source_origin_y, dest_offset_x, dest_offset_y, width, height)

end

#fill(value)

Fill the whole table with a specific value

Parameters:

  • value (Integer) —

    the value to affect to every cell of the table



1340
1341
1342
# File 'LiteRGSS.rb.yard.rb', line 1340

def fill(value)

end

#resize(xsize, ysize = 1, zsize = 1)

Note:

Some value may be undeterminated if the new size is bigger than the old size

Resize the table

Parameters:

  • xsize (Integer) —

    number of row

  • ysize (Integer) (defaults to: 1) —

    number of cols

  • zsize (Integer) (defaults to: 1) —

    number of 2D table



1335
1336
1337
# File 'LiteRGSS.rb.yard.rb', line 1335

def resize(xsize, ysize = 1, zsize = 1)

end