Date: 2017/02/14 15:39:15 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
setFacing:
type: task
debug: minimal
script:
- define vector <procedure[script:getDirectionVector|from:<entity[<def[entity]>].location>|to:<def[target]>].vector>
- define pitch <procedure[script:getFacingPitch|y:<def[vector].y>].pitch>
- define yaw <procedure[script:getDirectionVector|x:<def[vector].x>|z:<def[vector].z>].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>
getFacingYaw:
# Usage: <procedure[script:getDirectionVector|x:x|z:z].yaw>
type: procedure
debug: false
script:
# PI 3.14159265359
# 180 / PI == 57.295779513
- define radians <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]>
getFacingPitch:
# Usage: <procedure[script:getFacingPitch|y:y].pitch>
type: procedure
debug: false
script:
# PI 3.14159265359
# 180 / PI == 57.295779513
- determine pitch <context.y.multiply[57.295779513]>