Skip to content

Instantly share code, notes, and snippets.

@drage0
Last active April 24, 2016 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drage0/5816e189c971e89468552d1dc92294a0 to your computer and use it in GitHub Desktop.
Save drage0/5816e189c971e89468552d1dc92294a0 to your computer and use it in GitHub Desktop.
local delayAm = 1; -- Default delay amount, in seconds
local countdown = 5; -- Countdown amount
local initDotAm = 4; -- Amount of dots when initializing
local initDotAmCur = 0; -- Used in initText, DO NOT change by hand
local startTextDelay = 0.3; -- Used in slap text
local perTextDelay = 0.1; -- Delay between letters in perText*()
local waitProsSpawn = 10; -- When are we sure all the props are spawned?
local function isWhitespace(s)
return (s == ' ');
end;
-- perTextAdd() and perTextDel() writes text using 'NumberText' textEffect,
-- *Add() writes from 1st to the last letter while
-- *Del() writes from last letter to 0(empty string)
local function perTextAdd(text)
local s = string.len(text);
for i=1, s, 1 do
if (not isWhitespace(text[i])) then
worldInfo:AddTextEffectToAllPlayers(NumberText,string.sub(text, 1, i));
Wait(Delay(perTextDelay));
end;
end;
end;
local function perTextDel(text)
local s = string.len(text);
for i=s, 0, -1 do
if (not isWhitespace(text[i])) then
worldInfo:AddTextEffectToAllPlayers(NumberText,string.sub(text, 1, i));
Wait(Delay(perTextDelay));
end;
end;
end;
-- initText() writes '.' using 'NumberText' textEffect and variable 'initDotAmCur',
-- which is increased each time initText() is called.
-- Based on current value of 'initDotAmCur', it writes dots.
local function initText()
local str = '.';
initDotAmCur = initDotAmCur + 1;
for i=initDotAmCur, 1, -1 do
worldInfo:AddTextEffectToAllPlayers(NumberText, str);
str = str .. '.';
end;
end;
-- Writes 'START!' using 'StartingInText' and 'StartingInTextEnd' textEffect.
-- Delays the two text effects by 'startTextDelay', also after writing it
-- also delays by 'startTextDelay'.
local function slapStart()
worldInfo:AddTextEffectToAllPlayers(StartingInText,"START!");
Wait(Delay(startTextDelay));
worldInfo:AddTextEffectToAllPlayers(StartingInText,"");
worldInfo:AddTextEffectToAllPlayers(StartingInTextEnd,"START!");
Wait(Delay(startTextDelay));
end;
--[[
-- STAR FROM HERE
--]]
-- 'Initialization'
-- Write 'INITIALIZING' using 'StartingInText' textEffect and
-- write dots using initText()
worldInfo:AddTextEffectToAllPlayers(StartingInText,"INITIALIZING");
Wait(Delay(delayAm));
do
for i=initDotAm, 1, -1 do
initText();
Wait(Delay(delayAm));
end;
end;
-- Round start!
-- Write 'STARTING IN' using 'StartingInText' textEffect and count down from 'countdown'
-- Delay for the first iteration is skipped. 'if (not (i==countdown))'
-- There is a slight delay (0.1(for now)) that is added at start, just in case.
Wait(Delay(0.1));
worldInfo:AddTextEffectToAllPlayers(StartingInText,"STARTING IN");
for i=countdown, 1, -1 do
if (not (i==countdown)) then
Wait(Delay(delayAm));
end;
worldInfo:AddTextEffectToAllPlayers(NumberText,i);
end;
-- Delete the previously written text using 'StartingInText' and write
-- the same string using 'StartingInTextEnd' which seems to disappear after time
worldInfo:AddTextEffectToAllPlayers(StartingInText,"");
worldInfo:AddTextEffectToAllPlayers(StartingInTextEnd,"STARTING IN");
-- Writes 'GET READY' letter by letter.
-- After that it removes the text, although it should already be removed
-- as described in perText*()
Wait(Delay(delayAm));
perTextAdd("GET READY");
Wait(Delay(delayAm));
perTextDel("GET READY");
Wait(Delay(delayAm));
worldInfo:AddTextEffectToAllPlayers(NumberText,"");
-- Actually start
-- Write starting message and start music
slapStart();
slapStart();
worldInfo:ForceMusic("Continuous", Music);
-- Spawn props and start prop bouncer
Wait(Delay(delayAm));
StartBarrier:Disable();
PropsThrown:SpawnGroup();
AbyssMover:PlayAnimLoop("Default");
-- Wait for prop spawners to complete, then close doors
Wait(Delay(waitProsSpawn));
DoorMovers:PlayAnim("Close");
DoorSound:PlayOnce();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment