rules54

Proximity Pad

Jul 21st, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. s = sensor.wrap("top")
  3.  
  4. function playerRange(range, height)
  5.   local result = nil
  6.   x = s.getTargets()
  7.   for k, v in pairs(x) do
  8.     if v.Name == "Player" then
  9.       local x = math.floor(math.abs(v.Position.X))
  10.       local z = math.floor(math.abs(v.Position.Z))
  11.       local y = math.floor(v.Position.Y)
  12.       if y <= height and y >= 0 then
  13.         if (x <= range) or (z <= range) then
  14.           result = true
  15.         else local result = false
  16.         end
  17.       end
  18.     end
  19.   end
  20.   return result
  21. end
  22.  
  23.  
  24. while true do
  25.   while playerRange(5,5) do
  26.     rs.setOutput("right", true)
  27.   end
  28.   rs.setOutput("right", false)
  29. end
Advertisement
Add Comment
Please, Sign In to add comment