|
1 | 1 | function Create(self)
|
2 | 2 | -- Make sure the teleporter list exists.
|
3 |
| - if teleporterlistb == nil then |
4 |
| - teleporterlistb = {}; |
| 3 | + if _G["teleporterlistb"] == nil then |
| 4 | + _G["teleporterlistb"] = {}; |
5 | 5 | end
|
| 6 | + local teleporterlistb = _G["teleporterlistb"]; |
6 | 7 |
|
7 | 8 | -- List for storing who can teleport.
|
8 |
| - if cantele == nil then |
9 |
| - cantele = {}; |
| 9 | + if _G["cantele"] == nil then |
| 10 | + _G["cantele"] = {}; |
10 | 11 | end
|
| 12 | + local cantele = _G["cantele"]; |
11 | 13 |
|
12 | 14 | -- Add self to teleporter list.
|
13 | 15 | teleporterlistb[#teleporterlistb + 1] = self;
|
@@ -39,54 +41,58 @@ function Create(self)
|
39 | 41 | end
|
40 | 42 |
|
41 | 43 | function Update(self)
|
42 |
| - -- A delay so that all teleporters will have been placed by the time the code activates. |
43 |
| - if self.creationtimer:IsPastSimMS(1000) and ActivityMan:GetActivity().ActivityState ~= Activity.EDITING then |
44 |
| - -- Check if the teleporter is linked yet. |
45 |
| - if MovableMan:IsParticle(self.partner) == false then |
46 |
| - -- If not, try to assign a partner. |
47 |
| - self.partner = teleporterlista[self.listnum]; |
48 |
| - -- Turn on spinning effect. |
49 |
| - self:EnableEmission(true); |
50 |
| - elseif cantele[self.listnum]:IsPastSimMS(self.porttime) then |
51 |
| - -- Cycle through all actors. |
52 |
| - local target = nil; |
53 |
| - for actor in MovableMan.Actors do |
54 |
| - if IsActor(actor) then |
55 |
| - local dist = SceneMan:ShortestDistance(self.Pos, actor.Pos, false); |
56 |
| - if dist:MagnitudeIsLessThan(25) and actor.PinStrength == 0 then |
57 |
| - target = actor; |
58 |
| - -- Chargeup. |
59 |
| - self.porttime = self.porttime / (1 + self.portSpeed); |
60 |
| - -- Make the actor glow for a while. |
61 |
| - actor:FlashWhite(10 + self.porttime / 10); |
62 |
| - local glow = CreateMOPixel("Teleporter Glow Short"); |
63 |
| - glow.Pos = self.Pos; |
64 |
| - MovableMan:AddParticle(glow); |
65 |
| - if self.porttime < 20 then |
66 |
| - -- Teleport the actor. |
67 |
| - actor.Pos = self.partner.Pos + dist; |
68 |
| - -- Create the teleportation effect for both teleporters in the set. |
69 |
| - local pos = {self.Pos, self.partner.Pos}; |
70 |
| - for i = 1, #pos do |
71 |
| - local fx = CreateAEmitter("Teleporter Effect A"); |
72 |
| - fx.Pos = pos[i]; |
73 |
| - MovableMan:AddParticle(fx); |
74 |
| - local glow = CreateMOPixel("Teleporter Glow"); |
75 |
| - glow.Pos = pos[i]; |
76 |
| - MovableMan:AddParticle(glow); |
| 44 | + local teleporterlista = _G["teleporterlista"]; |
| 45 | + local cantele = _G["cantele"]; |
| 46 | + if teleporterlista then |
| 47 | + -- A delay so that all teleporters will have been placed by the time the code activates. |
| 48 | + if self.creationtimer:IsPastSimMS(1000) and ActivityMan:GetActivity().ActivityState ~= Activity.EDITING then |
| 49 | + -- Check if the teleporter is linked yet. |
| 50 | + if MovableMan:IsParticle(self.partner) == false then |
| 51 | + -- If not, try to assign a partner. |
| 52 | + self.partner = teleporterlista[self.listnum]; |
| 53 | + -- Turn on spinning effect. |
| 54 | + self:EnableEmission(true); |
| 55 | + elseif cantele[self.listnum]:IsPastSimMS(self.porttime) then |
| 56 | + -- Cycle through all actors. |
| 57 | + local target = nil; |
| 58 | + for actor in MovableMan.Actors do |
| 59 | + if IsActor(actor) then |
| 60 | + local dist = SceneMan:ShortestDistance(self.Pos, actor.Pos, false); |
| 61 | + if dist:MagnitudeIsLessThan(25) and actor.PinStrength == 0 then |
| 62 | + target = actor; |
| 63 | + -- Chargeup. |
| 64 | + self.porttime = self.porttime / (1 + self.portSpeed); |
| 65 | + -- Make the actor glow for a while. |
| 66 | + actor:FlashWhite(10 + self.porttime / 10); |
| 67 | + local glow = CreateMOPixel("Teleporter Glow Short"); |
| 68 | + glow.Pos = self.Pos; |
| 69 | + MovableMan:AddParticle(glow); |
| 70 | + if self.porttime < 20 then |
| 71 | + -- Teleport the actor. |
| 72 | + actor.Pos = self.partner.Pos + dist; |
| 73 | + -- Create the teleportation effect for both teleporters in the set. |
| 74 | + local pos = {self.Pos, self.partner.Pos}; |
| 75 | + for i = 1, #pos do |
| 76 | + local fx = CreateAEmitter("Teleporter Effect A"); |
| 77 | + fx.Pos = pos[i]; |
| 78 | + MovableMan:AddParticle(fx); |
| 79 | + local glow = CreateMOPixel("Teleporter Glow"); |
| 80 | + glow.Pos = pos[i]; |
| 81 | + MovableMan:AddParticle(glow); |
| 82 | + end |
77 | 83 | end
|
| 84 | + -- Shut off teleportation on this set until the delay is up. |
| 85 | + cantele[self.listnum]:Reset(); |
78 | 86 | end
|
79 |
| - -- Shut off teleportation on this set until the delay is up. |
80 |
| - cantele[self.listnum]:Reset(); |
81 | 87 | end
|
82 | 88 | end
|
83 |
| - end |
84 |
| - if target == nil then |
85 |
| - self.porttime = self.porttimemax; |
| 89 | + if target == nil then |
| 90 | + self.porttime = self.porttimemax; |
| 91 | + end |
86 | 92 | end
|
87 | 93 | end
|
| 94 | + self.SpriteAnimDuration = self.porttime; |
88 | 95 | end
|
89 |
| - self.SpriteAnimDuration = self.porttime; |
90 | 96 | end
|
91 | 97 |
|
92 | 98 | function Destroy(self)
|
|
0 commit comments