Skip to content

Commit 6244965

Browse files
committed
"as long as it works" fix for teles
1 parent 622a890 commit 6244965

File tree

3 files changed

+102
-89
lines changed

3 files changed

+102
-89
lines changed

Data/Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Teleporters/TeleporterA.lua

Lines changed: 49 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
function Create(self)
22
-- Make sure the teleporter list exists.
33
if teleporterlista == nil then
4-
teleporterlista = {};
4+
_G["teleporterlista"] = {};
55
end
66

77
-- List for storing who can teleport.
8-
if cantele == nil then
9-
cantele = {};
8+
if _G["cantele"] == nil then
9+
_G["cantele"] = {};
1010
end
11+
local cantele = _G["cantele"];
1112

1213
-- Add self to teleporter list.
1314
teleporterlista[#teleporterlista + 1] = self;
@@ -39,54 +40,58 @@ function Create(self)
3940
end
4041

4142
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 = teleporterlistb[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);
43+
local teleporterlistb = _G["teleporterlistb"];
44+
local cantele = _G["cantele"];
45+
if teleporterlistb then
46+
-- A delay so that all teleporters will have been placed by the time the code activates.
47+
if self.creationtimer:IsPastSimMS(1000) and ActivityMan:GetActivity().ActivityState ~= Activity.EDITING then
48+
-- Check if the teleporter is linked yet.
49+
if MovableMan:IsParticle(self.partner) == false then
50+
-- If not, try to assign a partner.
51+
self.partner = teleporterlistb[self.listnum];
52+
-- Turn on spinning effect.
53+
self:EnableEmission(true);
54+
elseif cantele[self.listnum]:IsPastSimMS(self.porttime) then
55+
-- Cycle through all actors.
56+
local target = nil;
57+
for actor in MovableMan.Actors do
58+
if IsActor(actor) then
59+
local dist = SceneMan:ShortestDistance(self.Pos, actor.Pos, false);
60+
if dist:MagnitudeIsLessThan(25) and actor.PinStrength == 0 then
61+
target = actor;
62+
-- Chargeup.
63+
self.porttime = self.porttime / (1 + self.portSpeed);
64+
-- Make the actor glow for a while.
65+
actor:FlashWhite(10 + self.porttime / 10);
66+
local glow = CreateMOPixel("Teleporter Glow Short");
67+
glow.Pos = self.Pos;
68+
MovableMan:AddParticle(glow);
69+
if self.porttime < 20 then
70+
-- Teleport the actor.
71+
actor.Pos = self.partner.Pos + dist;
72+
-- Create the teleportation effect for both teleporters in the set.
73+
local pos = {self.Pos, self.partner.Pos};
74+
for i = 1, #pos do
75+
local fx = CreateAEmitter("Teleporter Effect A");
76+
fx.Pos = pos[i];
77+
MovableMan:AddParticle(fx);
78+
local glow = CreateMOPixel("Teleporter Glow");
79+
glow.Pos = pos[i];
80+
MovableMan:AddParticle(glow);
81+
end
7782
end
83+
-- Shut off teleportation on this set until the delay is up.
84+
cantele[self.listnum]:Reset();
7885
end
79-
-- Shut off teleportation on this set until the delay is up.
80-
cantele[self.listnum]:Reset();
8186
end
8287
end
83-
end
84-
if target == nil then
85-
self.porttime = self.porttimemax;
88+
if target == nil then
89+
self.porttime = self.porttimemax;
90+
end
8691
end
8792
end
93+
self.SpriteAnimDuration = self.porttime;
8894
end
89-
self.SpriteAnimDuration = self.porttime;
9095
end
9196

9297
function Destroy(self)

Data/Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Teleporters/TeleporterB.lua

Lines changed: 51 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
function Create(self)
22
-- Make sure the teleporter list exists.
3-
if teleporterlistb == nil then
4-
teleporterlistb = {};
3+
if _G["teleporterlistb"] == nil then
4+
_G["teleporterlistb"] = {};
55
end
6+
local teleporterlistb = _G["teleporterlistb"];
67

78
-- List for storing who can teleport.
8-
if cantele == nil then
9-
cantele = {};
9+
if _G["cantele"] == nil then
10+
_G["cantele"] = {};
1011
end
12+
local cantele = _G["cantele"];
1113

1214
-- Add self to teleporter list.
1315
teleporterlistb[#teleporterlistb + 1] = self;
@@ -39,54 +41,58 @@ function Create(self)
3941
end
4042

4143
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
7783
end
84+
-- Shut off teleportation on this set until the delay is up.
85+
cantele[self.listnum]:Reset();
7886
end
79-
-- Shut off teleportation on this set until the delay is up.
80-
cantele[self.listnum]:Reset();
8187
end
8288
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
8692
end
8793
end
94+
self.SpriteAnimDuration = self.porttime;
8895
end
89-
self.SpriteAnimDuration = self.porttime;
9096
end
9197

9298
function Destroy(self)

Data/Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Teleporters/Teleporters.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ AddActor = AEmitter
8585
RestThreshold = 0
8686
HitsMOs = 0
8787
GetsHitByMOs = 0
88+
ForceIntoMasterLuaState = 1
8889
ScriptPath = Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Teleporters/TeleporterA.lua
8990
SpriteFile = ContentFile
9091
FilePath = Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Teleporters/TeleporterA.png
@@ -119,6 +120,7 @@ AddActor = AEmitter
119120
RestThreshold = 0
120121
HitsMOs = 0
121122
GetsHitByMOs = 0
123+
ForceIntoMasterLuaState = 1
122124
ScriptPath = Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Teleporters/TeleporterB.lua
123125
SpriteFile = ContentFile
124126
FilePath = Base.rte/Scenes/Objects/Bunkers/BunkerSystems/Teleporters/TeleporterB.png

0 commit comments

Comments
 (0)