Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
DataGrid
DescriptionA datagrid datastructureFunctions
delete
DescriptionDeletes data gridDefinition
delete()Code
35 | function DataGrid:delete() |
36 | self.grid = nil |
37 | end |
getValue
DescriptionGets value at given row and columnDefinition
getValue(integer rowIndex, integer colIndex)Arguments
integer | rowIndex | index of row |
integer | colIndex | index of column |
table | value | value at the given position |
44 | function DataGrid:getValue(rowIndex, colIndex) |
45 | if rowIndex < 1 or rowIndex > self.numRows then |
46 | g_logManager:error("rowIndex out of bounds!") |
47 | printCallstack() |
48 | return nil |
49 | end |
50 | if colIndex < 1 or colIndex > self.numColumns then |
51 | g_logManager:error("colIndex out of bounds!") |
52 | printCallstack() |
53 | return nil |
54 | end |
55 | |
56 | return self.grid[rowIndex][colIndex] |
57 | end |
new
DescriptionCreating data gridDefinition
new(integer numRows, integer numColumns, table customMt)Arguments
integer | numRows | number of rows |
integer | numColumns | number of columns |
table | customMt | custom metatable |
table | instance | instance of object |
19 | function DataGrid:new(numRows, numColumns, customMt) |
20 | local self = {} |
21 | setmetatable(self, customMt or DataGrid_mt) |
22 | |
23 | self.grid = {} |
24 | self.numRows = numRows |
25 | self.numColumns = numColumns |
26 | for i=1, numRows do |
27 | table.insert(self.grid, {}) |
28 | end |
29 | |
30 | return self |
31 | end |
setValue
DescriptionSet value at given row and columnDefinition
setValue(integer rowIndex, integer colIndex, table value)Arguments
integer | rowIndex | index of row |
integer | colIndex | index of column |
table | value | value at the given position |
64 | function DataGrid:setValue(rowIndex, colIndex, value) |
65 | if rowIndex < 1 or rowIndex > self.numRows then |
66 | g_logManager:error("rowIndex out of bounds!") |
67 | printCallstack() |
68 | return false |
69 | end |
70 | if colIndex < 1 or colIndex > self.numColumns then |
71 | g_logManager:error("colIndex out of bounds!") |
72 | printCallstack() |
73 | return false |
74 | end |
75 | |
76 | self.grid[rowIndex][colIndex] = value |
77 | return true |
78 | end |