Skip to content

Commit 222c7b9

Browse files
committed
Updated teleporters with new custom properties for rotating the player.
1 parent 8ce8995 commit 222c7b9

File tree

5 files changed

+100
-21
lines changed

5 files changed

+100
-21
lines changed

Data/Scripts/README.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ To create your own teleporters, there is a Teleporter template that can be used.
4141
- Name
4242
The name of the teleporter that will be transferred to.
4343
44+
- RotatePlayer
45+
If enabled, the player will be rotated based on the PlayerRotation value.
46+
47+
- RotateCamera
48+
If enabled, the camera will be rotated based on the PlayerRotation value.
49+
50+
- PlayerRotation
51+
The rotation of the player when spawning at this portal.
52+
4453
======================
4554
Connecting Teleporters
4655
======================

Data/Scripts/Teleporter_Server.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@ local function on_player_enter(trigger, other)
2929
other.serverUserData.teleporting = true
3030
other:SetWorldPosition(pos_obj:GetWorldPosition())
3131

32-
if(teleporter:GetWorldRotation() ~= Rotation.ZERO) then
33-
other:SetWorldRotation(teleporter:GetRotation())
34-
Events.BroadcastToPlayer(other, "Teleporter.SetLook" .. teleporter.id, teleporter:GetWorldRotation())
32+
local rotate_player = teleporter:GetCustomProperty("RotatePlayer")
33+
local rotate_camera = teleporter:GetCustomProperty("RotateCamera")
34+
local rotation = teleporter:GetCustomProperty("PlayerRotation")
35+
36+
if(row ~= nil and rotate_player) then
37+
other:SetWorldRotation(rotation)
38+
39+
if(rotate_camera) then
40+
Events.BroadcastToPlayer(other, "Teleporter.SetLook" .. teleporter.id, rotation)
41+
end
3542
end
3643

3744
other.serverUserData.teleporting = false

Data/Templates/Teleporter - Example.pbt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Assets {
8181
}
8282
Objects {
8383
Id: 15237301247470180174
84-
Name: "Teleporter"
84+
Name: "Outside Teleporter"
8585
Transform {
8686
Scale {
8787
X: 1
@@ -125,14 +125,8 @@ Assets {
125125
}
126126
Objects {
127127
Id: 14144632513562911928
128-
Name: "Teleporter"
128+
Name: "Inside Teleporter"
129129
Transform {
130-
Location {
131-
X: -13.2539368
132-
Y: 593.796387
133-
}
134-
Rotation {
135-
}
136130
Scale {
137131
X: 1
138132
Y: 1
@@ -167,14 +161,6 @@ Assets {
167161
Rotator {
168162
}
169163
}
170-
Overrides {
171-
Name: "Scale"
172-
Vector {
173-
X: 1
174-
Y: 1
175-
Z: 1
176-
}
177-
}
178164
}
179165
}
180166
TemplateAsset {

Data/Templates/Teleporter.pbt

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ Assets {
77
RootId: 3353432081574414687
88
Objects {
99
Id: 3353432081574414687
10-
Name: "Teleporter"
10+
Name: "Outside Teleporter"
1111
Transform {
1212
Scale {
1313
X: 1
1414
Y: 1
1515
Z: 1
1616
}
1717
}
18-
ParentId: 4781671109827199097
18+
ParentId: 10529402100221355922
1919
ChildIds: 11846688373023959865
2020
ChildIds: 5378724642372319002
2121
ChildIds: 629465779450443528
@@ -31,6 +31,19 @@ Assets {
3131
Name: "cs:Name"
3232
String: ""
3333
}
34+
Overrides {
35+
Name: "cs:RotatePlayer"
36+
Bool: false
37+
}
38+
Overrides {
39+
Name: "cs:RotateCamera"
40+
Bool: false
41+
}
42+
Overrides {
43+
Name: "cs:PlayerRotation"
44+
Rotator {
45+
}
46+
}
3447
Overrides {
3548
Name: "cs:ShowName:tooltip"
3649
String: "If enabled, the name of the teleporter will show up above it for players."
@@ -39,6 +52,58 @@ Assets {
3952
Name: "cs:Name:tooltip"
4053
String: "The name of the teleporter this is going to."
4154
}
55+
Overrides {
56+
Name: "cs:ShowName:isrep"
57+
Bool: false
58+
}
59+
Overrides {
60+
Name: "cs:ShowName:ml"
61+
Bool: false
62+
}
63+
Overrides {
64+
Name: "cs:Name:isrep"
65+
Bool: false
66+
}
67+
Overrides {
68+
Name: "cs:Name:ml"
69+
Bool: false
70+
}
71+
Overrides {
72+
Name: "cs:RotatePlayer:tooltip"
73+
String: "If enable, the player will be rotated based on the PlayerRotation value."
74+
}
75+
Overrides {
76+
Name: "cs:RotatePlayer:isrep"
77+
Bool: false
78+
}
79+
Overrides {
80+
Name: "cs:RotatePlayer:ml"
81+
Bool: false
82+
}
83+
Overrides {
84+
Name: "cs:RotateCamera:tooltip"
85+
String: "If enabled, the player look direction will be rotated based on the PlayerRotation value."
86+
}
87+
Overrides {
88+
Name: "cs:RotateCamera:isrep"
89+
Bool: false
90+
}
91+
Overrides {
92+
Name: "cs:RotateCamera:ml"
93+
Bool: false
94+
}
95+
Overrides {
96+
Name: "cs:PlayerRotation:tooltip"
97+
String: "The rotation of the player when spawning at this teleporter."
98+
}
99+
Overrides {
100+
Name: "cs:PlayerRotation:isrep"
101+
Bool: false
102+
}
103+
Overrides {
104+
Name: "cs:PlayerRotation:ml"
105+
Bool: false
106+
}
42107
}
43108
Collidable_v2 {
44109
Value: "mc:ecollisionsetting:inheritfromparent"

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ To create your own teleporters, there is a Teleporter template that can be used.
3535

3636
The name of the teleporter that will be transferred to.
3737

38+
- *RotatePlayer*
39+
40+
If enabled, the player will be rotated based on the PlayerRotation value.
41+
42+
- *RotateCamera*
43+
44+
If enabled, the camera will be rotated based on the PlayerRotation value.
45+
46+
- *PlayerRotation*
47+
48+
The rotation of the player when spawning at this portal.
49+
3850
## Connecting Teleporters
3951

4052
Connecting teleporters is very easy.

0 commit comments

Comments
 (0)