CellId
is an unused non-functional datatype that was introduced into Roblox’s codebase around early 2011, when the original version of the Terrain feature was under development.
Its supposed to be constructed something like this:
CellId.new(isNil: boolean, x: number, y: number, z: number, terrainPart: Terrain?): CellId
When you try to use its constructor, it does not function as expected.
This happens because the Lua C API is not used correctly in the handler for the constructor.
Won’t dive too much into the details, but essentially it comes down to the calls using 0-based indexing instead of 1-based indexing to process the function arguments.
If you pass in 4 values, the xyz parameters are correctly aligned:
This seems to imply the first argument is processed as lua_toboolean(L, 0)
, so its trying to read the 0th value passed to the function. This is… evidently going to give incorrect results. The CellId.TerrainPart
field is also never set, and always returns nil when accessing it.
My best guess is that this datatype was once intended to be used for querying terrain cells, and whether they were occupied or not (at the time, only the grass terrain cell existed!)
Overall, I think this datatype is worth nuking:
- It has no documentation or uses in top games and usable code.
- The old terrain engine has been gone for almost 3 years.
- It isn’t (and never has been) used in any Roblox APIs.
- It does not process arguments correctly.