Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
MapDataGrid
DescriptionA map data grid that splits a map in multiple sectionsParent
DataGridFunctions
getRowColumnFromWorldPos
Description@param float worldZ world position zDefinition
getRowColumnFromWorldPos()Return Values
integer | row | row |
integer | column | column |
55 | function MapDataGrid:getRowColumnFromWorldPos(worldX, worldZ) |
56 | local mapSize = self.mapSize |
57 | local blocksPerRowColumn = self.blocksPerRowColumn |
58 | |
59 | local x = (worldX + mapSize*0.5) / mapSize |
60 | local z = (worldZ + mapSize*0.5) / mapSize |
61 | |
62 | local row = MathUtil.clamp(math.ceil(blocksPerRowColumn*z), 1, blocksPerRowColumn) |
63 | local column = MathUtil.clamp(math.ceil(blocksPerRowColumn*x), 1, blocksPerRowColumn) |
64 | |
65 | -- log(worldX, worldZ, " -> ", (worldX + self.mapSize*0.5), (worldZ + self.mapSize*0.5), z, x, row, column) |
66 | |
67 | return row, column |
68 | end |
getValueAtWorldPos
Description@param float worldZ world position zDefinition
getValueAtWorldPos()Return Values
table | value | value at the given position |
34 | function MapDataGrid:getValueAtWorldPos(worldX, worldZ) |
35 | local rowIndex, colIndex = self:getRowColumnFromWorldPos(worldX, worldZ) |
36 | return self:getValue(rowIndex, colIndex), rowIndex, colIndex |
37 | end |
new
DescriptionCreating data gridDefinition
new(integer mapSize, integer blocksPerRowColumn, table customMt)Arguments
integer | mapSize | map size |
integer | blocksPerRowColumn | blocks per row and column |
table | customMt | custom metatable |
table | instance | instance of object |
19 | function MapDataGrid.new(mapSize, blocksPerRowColumn, customMt) |
20 | local self = DataGrid.new(blocksPerRowColumn, blocksPerRowColumn, customMt or MapDataGrid_mt) |
21 | |
22 | self.blocksPerRowColumn = blocksPerRowColumn |
23 | self.mapSize = mapSize |
24 | self.blockSize = self.mapSize/self.blocksPerRowColumn |
25 | |
26 | return self |
27 | end |
setValueAtWorldPos
Description@param float worldZ world position zDefinition
setValueAtWorldPos(table value)Arguments
table | value | value at the given position |
44 | function MapDataGrid:setValueAtWorldPos(worldX, worldZ, value) |
45 | local rowIndex, colIndex = self:getRowColumnFromWorldPos(worldX, worldZ) |
46 | self:setValue(rowIndex, colIndex, value) |
47 | end |