Date: 2017/02/14 16:50:03 UTC-08:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
setFacing:
type: task
debug: minimal
script:
- echo <entity[<def[entity]>].location>
- define vector <procedure[script:getDirectionVector|from:<entity[<def[entity]>].location>|to:<def[target]>].vector>
- echo "vector <def[vector]>"
- define pitch <procedure[script:getFacingPitch|y:<def[vector].y>].pitch>
- echo "pitch <def[pitch]>"
- define yaw <procedure[script:getFacingYaw|x:<def[vector].x>|z:<def[vector].z>].yaw>
- echo "yaw <def[yaw]>"
- editentity <entity[<def[entity]>]> rotation:<def[pitch]>,<def[yaw]>,0
getDirectionVector:
# Usage: <procedure[script:getDirectionVector|from:x,y,z|to:x,y,z].vector>
# <procedure[script:getDirectionVector|from:<player.location>|to:<player.location.world.entities[armor_stand].get[1].location>].vector>
type: procedure
debug: false
script:
- determine vector <location[<context.from>].subtract[<context.to>].normalized>
getFacingPitch:
# Usage: <procedure[script:getFacingPitch|y:y].pitch>
type: procedure
debug: false
script:
# PI 3.14159265359
# 180 / PI == 57.295779513
- determine pitch <number[<context.y>].multiply[57.295779513]>
getFacingYaw:
# Usage: <procedure[script:getFacingYaw|x:x|z:z].yaw>
type: procedure
debug: false
script:
# PI 3.14159265359
# 180 / PI == 57.295779513
- define radians <number[<context.x>].atan2[<context.z>]>
- define degrees <def[radians].multiply[57.295779513]>
- if <def[degrees]> < 0:
- define degrees <def[degrees].add[360]>
- determine yaw <def[degrees]>