local function calcolateYPosition()
end
local function snap(x)
return math.ceil((x/GRID_SIZE) - 0.5)*GRID_SIZE
end
local function calculateItemPosition()
if moveByGrid then
posx = snap(mouse.Hit.X)
posy = mouse.Hit.Y
posz = snap(mouse.Hit.Z)
else
posx = mouse.Hit.X
posy = mouse.Hit.Y
posz = mouse.Hit.Z
end
end
local function translateObj()
if placedObjects and object.parent == placedObjects then
calculateItemPosition()
object:PivotTo(object.primaryPart.Cframe:Lerp(CFrame.new(posx, posy, posz), speed))
end
end
local function approvePlacement()
return true
end
function placement.new(g, objs, r, t)
local data = {}
local metaData = setmetatable(data, placement)
GRID_SIZE = g
ITEM_LOCATION = objs
ROTATE_KEY = r
TERMINATE_KEY = t
data.grid = g
data.itemlocation = ITEM_LOCATION
data.rotatekey = r
data.terminatekey = t
return data
end
function placement:activate(id, pobjs, plt, stk)
object = ITEM_LOCATION:FindFirstChild(id):Clone()
placedObjects = pobjs
plot = plt
stackable = stk
if not approvePlacement() then
return 'placement could not activate'
end
if not stk then
mouse.TargetFilter = placedObjects
else
mouse.TargetFilter = object
end
local preSpeed = 1
if interpolation then
preSpeed = math.clamp(math.abs(tonumber(1-lerpLevel)), 0, 1)
speed = 1
end
object.parent = placedObjects
wait()
speed = preSpeed
end
wait(1)
runService:BindToRenderStep('Input', Enum.RenderPriority.Input.Value, translateObj)
return placement