In games such as Miner's Haven, you have a plot of land, and you build things on it. the only thing i don't know how to do about these building things, is the grid. in the hopperbin gametool, you can move parts in a 1 stud grid, but n miners haven, and other games(i can't think of any), you can build in a different grid way. does anybody know how i could do this? I'm not asking for a script. An image of the grids in miners haven is here, i don't want advise on the gui stuffs
and i just got goon stop grids in my mind...
The grid itself is just there as a visual aid. The building tools are scripted to follow the 'grid' separately.
First, you'll need to script a tool that behaves just as the GameTool, as that one is C-sided (that is, not written in Lua) and its code cannot be changed by users. After you have some mover tool written in Lua, getting it to work with a grid will be very easy.
An easy way to do it is to simply round the coordinates of the object you're moving with math.floor
. This will allow only whole numbers as the coordinates and effectively work as a 1-stud grid.
If you'd like to change the grid scale, you can also use the module operator (%) on the coordinates.
EDIT: You can use the modulo operator to make your object follow any sort of grid:
coord - (coord % gridScale)
and some pseudocode:
obj.X = obj.X - (obj.X % 3)