legacy:grid:api
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| legacy:grid:api [2025/01/13 16:14] – removed - external edit (Unknown date) 127.0.0.1 | legacy:grid:api [2025/01/13 16:14] (current) – ↷ Links adapted because of a move operation superadmin | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Grid API ====== | ||
| + | This section explains the basic grid interaction and the building block of function you can use. | ||
| + | ===== Battler Position ===== | ||
| + | Battler position is represented as an index in a __one-dimension__ [[https:// | ||
| + | |||
| + | {{https:// | ||
| + | |||
| + | ==== Grid dimension ==== | ||
| + | To determine the dimension the grid, set it in the API section of then script. | ||
| + | <code ruby> | ||
| + | MaxRow = 3 # Determine the maximum row | ||
| + | MaxCol = 8 # Determine the maximum column | ||
| + | </ | ||
| + | When you decide the dimension of the grid, the maximum index is changed accordingly. i.e, if you put the dimension as '' | ||
| + | |||
| + | Because the position is stored in a one-dimension array, so does the battler position. To determine the position, you have to make a nested array that represents the screen position of that said index. For example, this is the position setting in the 640x360 screen in [[legacy: | ||
| + | <code ruby> | ||
| + | Position = | ||
| + | [ | ||
| + | [134, | ||
| + | [124, | ||
| + | [105, | ||
| + | ] | ||
| + | </ | ||
| + | The first index represents 134 for the x-axis position and 158 as the y-axis position. Do note that __the script will NOT care about how you actually put the screen position__. Make sure that the grid position correctly represents the position. You can always the '' | ||
| + | |||
| + | Remember when setting the position, the script will always treat the first index (which is index 0) to be always on the top left of the screen. You can not change this behavior unless you internally change how the module works. Fortunately, | ||
| + | |||
| + | ===== Getting Position ===== | ||
| + | Getting the position is largely used in the [[legacy: | ||
| + | |||
| + | ==== Neighbor direction ==== | ||
| + | <code ruby> | ||
| + | |||
| + | This function gets the neighbor/ | ||
| + | * Index = Represents which index you want to get its neighbor position | ||
| + | * Direction = Represents which direction you want to check in a [[https:// | ||
| + | * Times = Optional parameter that can be omitted. The parameter function as to how far you want to check into that direction (The default value is 1). | ||
| + | |||
| + | Here is a list of examples. The orange cell represents the center grid you want to check its neighbor | ||
| + | <code ruby> | ||
| + | Grid.neighbor(13, | ||
| + | </ | ||
| + | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | ||
| + | | 8 | 9 | 10 | 11 | @lightgreen: | ||
| + | | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | | ||
| + | <code ruby> | ||
| + | Grid.neighbor(13, | ||
| + | </ | ||
| + | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | ||
| + | | 8 | 9 | 10 | @lightgreen: | ||
| + | | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | | ||
| + | <code ruby> | ||
| + | Grid.neighbor(5, | ||
| + | </ | ||
| + | | 0 | 1 | 2 | 3 | 4 | @orange:5 | 6 | 7 | | ||
| + | | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | | ||
| + | | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | | ||
| + | Because the direction up does not have a grid position, it will return '' | ||
| + | |||
| + | ==== Linear direction ==== | ||
| + | <code ruby> | ||
| + | Grid.linear(index, | ||
| + | </ | ||
| + | This function is to get an array that represents a linear direction. | ||
| + | * Index = Represents which index you want to get its neighbor position | ||
| + | * Direction = Represents which direction you want to check in a Numeric keypad. Unlike checking the neighbor position, the direction parameter here must be inputted as an array. i.e, it looks like this '' | ||
| + | * Times = Optional parameter, it checks how far you want it to be. If omitted, it will have the default value is 1. But why would you omit it? | ||
| + | |||
| + | Here is a list of examples. The orange cell represents the center grid you want to check its linear path. | ||
| + | <code ruby> | ||
| + | |||
| + | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | | ||
| + | | 8 | @lightgreen: | ||
| + | | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | | ||
| + | <code ruby> | ||
| + | Grid.linear(22, | ||
| + | </ | ||
| + | | 0 | 1 | 2 | 3 | 4 | 5 | @lightgreen: | ||
| + | | 8 | 9 | 10 | 11 | 12 | 13 | @lightgreen: | ||
| + | | 16 | 17 | 18 | @lightgreen: | ||
| + | <code ruby> | ||
| + | Grid.linear(22, | ||
| + | </ | ||
| + | | 0 | 1 | 2 | 3 | @lightgreen: | ||
| + | | 8 | 9 | 10 | 11 | 12 | @lightgreen: | ||
| + | | 16 | 17 | 18 | @lightgreen: | ||
| + | |||
| + | ==== Surrounding direction ==== | ||
| + | <code ruby> | ||
| + | This function is to get an array that represents the adjacent grid. This is basically like the '' | ||
| + | <code ruby> | ||
| + | |||
| + | | 0 | 1 | 2 | 3 | @lightgreen: | ||
| + | | 8 | 9 | 10 | 11 | @lightgreen: | ||
| + | | 16 | 17 | 18 | 19 | @lightgreen: | ||
| + | <code ruby> | ||
| + | Grid.surrounding(13, | ||
| + | </ | ||
| + | | 0 | 1 | 2 | 3 | 4 | @lightgreen: | ||
| + | | 8 | 9 | 10 | 11 | @lightgreen: | ||
| + | | 16 | 17 | 18 | 19 | 20 | @lightgreen: | ||
| + | <code ruby> | ||
| + | Grid.surrounding(7, | ||
| + | </ | ||
| + | | 0 | 1 | 2 | 3 | 4 | 5 | @lightgreen: | ||
| + | | 8 | 9 | 10 | 11 | 12 | 13 | @lightgreen: | ||
| + | | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | | ||
| + | |||
| + | ==== Combining the direction ==== | ||
| + | Combining the functions is an essential part of the system. The targeting and area of effect are largely depending on how creative you're to combine these functions. | ||
| + | |||
| + | {{https:// | ||
| + | |||
| + | Supposed that we're going to replicate this. With red being the initial index, orange being the epicenter, then light green as the area of effect (plus the epicenter). | ||
| + | |||
| + | | 0 | @lightgreen: | ||
| + | | @lightgreen: | ||
| + | | 16 | @lightgreen: | ||
| + | |||
| + | The code can go like this. | ||
| + | <code ruby> | ||
| + | epicenter = Grid.neighbor(14, | ||
| + | result = [epicenter] + Grid.linear(epicenter, | ||
| + | result += Grid.surrounding(epicenter, | ||
| + | return result | ||
| + | </ | ||
| + | It will yield an array with the value as '' | ||
| + | |||
| + | ===== Other Functions ===== | ||
| + | |||
| + | This section is under construction and may be completed later | ||
| + | once the system is released | ||
| + | |||
| + | {{tag> | ||
