Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --server
- local loc = {}
- loc[1] = {1,3,-2}
- loc[2] = {1,3,0}
- loc[3] = {1,3,2}
- loc[4] = {1,3,4}
- loc[5] = {-1,3,4}
- local sens = peripheral.wrap("left")
- local modem = peripheral.wrap("top")
- for y=1,#loc do
- print("opening on "..y)
- modem.open(y)
- end
- while true do
- sleep()
- local players = sens.getPlayers()
- local id = players[1].uuid
- local player = sens.getPlayerByUUID(id)
- local info = player.basic()
- local position = info.position
- for x=1,#loc do
- local magnitude
- local dist = {loc[x][1] - position.x, loc[x][2] - position.y, loc[x][3] - position.z}
- local total = math.pow(dist[1], 2) + math.pow(dist[2], 2) + math.pow(dist[3], 2)
- magnitude = math.sqrt(total)
- if magntiude <=2 then
- modem.transmit(x,x,"on")
- else
- modem.transmit(x,x,"off")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement