TTS grid is used to make simple scripting zone grids for tabletop simulator, so you can more easily create advanced games that use grids.
Save to your atom's code folder as grid_tts.ttslua
(NOT .lua)
then put #include grid_tts
at the top of your code.
Initialize your grid with
Myvalue = Grid:new()
You can now use Myvalue to preform grid functionality. The first command you should preform is
Myvalue:spawn(grid_width, grid_height, y_offset, x_offset, z_offset, cell_width, cell_height, cell_padding, spawn_location)
This will spawn scripting zones and place the scripting zone objects into the table. Your grid is now ready for use! To save the grid, just save the variable like you normally would in TTS.
Iterates through a circular area
Variable | Usage | Type |
---|---|---|
mode | fill or line | string |
x0 | Center x value | number |
y0 | Center y value | number |
radius | Radius of circle | number |
-- Iterates through a rectangular area
Variable | Usage | Type |
---|---|---|
mode | fill or line | string |
startX | Lower left x value | number |
startY | Lower left y value | number |
width | Width of rectangle | number |
height | Height of rectangle | number |
-- Iterates through a line
Variable | Usage | Type |
---|---|---|
mode | rigid or smooth | string |
startX | Starting x | number |
startY | Starting y | number |
endX | Ending x | number |
endY | Ending y | number |
- Grid:iterate() : Iterate through the entire grid.
- Grid:clean() : Cleans any empty rows.
- Grid:get(x, y) : Get the scripting zone of a cell
Use interchangably with any iteration, it all works the same.
special_grid = Grid:new()
special_grid:spawn(6, 3, 2.3, 0.1, 0.7, 2.6, 1.5, 0.5, spawn)
for x, y, v in special_grid:circle("fill", 2, 2, 1) do print("Circle: ", x, ",", y, " ", v) end
If you want to have custom scripting zones sizes, then you can include set them into the grid (the grid is initialized as a table)