Advertisement
HugePinball

Grid snapping & orientation within zone

Mar 21st, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. function onObjectEnterScriptingZone(zone, obj)
  2.     -- turn on object grid snapping
  3.     if zone.getName() == "Map Grid Zone" then
  4.         obj.use_grid = true
  5.         -- if obj.getName() == "Space Bunny" then
  6.             -- obj.use_gravity = false
  7.         -- end
  8.     end
  9. end
  10.  
  11. function onObjectLeaveScriptingZone(zone, obj)
  12.     -- log(obj.getName() .. " entered zone " .. zone.getName())
  13.     -- turn off object grid snapping
  14.     if zone.getName() == "Map Grid Zone" then
  15.         obj.use_grid = false
  16.         -- if obj.getName() == "Space Bunny" then
  17.             -- obj.use_gravity = true
  18.         -- end
  19.     end
  20.     -- countGrid(self, "update")
  21. end
  22.  
  23.  -- orient selected objects properly
  24. function onObjectDrop(colorName, obj)
  25.     local y = 0
  26.     for _, o in pairs(grid_zone.getObjects()) do
  27.         if o == obj then
  28.             local desc = obj.getDescription()
  29.             if string.find(desc, "Bunny") or string.find(desc, "City") or string.find(desc, "Token") then
  30.                 obj.setRotationSmooth({0,y,0})
  31.                 -- Wait.condition(
  32.                     -- function() countGrid(self, "update") end,
  33.                     -- function() return isResting(obj) end
  34.                 -- )
  35.             end
  36.             break
  37.         end
  38.     end
  39. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement