Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do i make grids?[ignore the current answer]

Asked by 8 years ago

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...

0
Can you provide an image to show exactly how it looks in Miner's Haven? SynphonyKnight 85 — 8y
0
yes right here: http://postimg.org/image/ku3lxxybv/ ignore the gui's, focus on the grids. ScriptsAhoy 202 — 8y

1 answer

Log in to vote
2
Answered by 8 years ago

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)
0
I figured this out a while ago, thank you though! Also, I used the modulo for a 2 stud grid, but i couldn't get it to work with 3 or more. Can you provide a demo of 3 studs? ScriptsAhoy 202 — 8y
Ad

Answer this question