Built-in
๋ํ ๋๋์์ ์ง์ํ๋ ๋ฃจ์ ๊ธฐ๋ฅ์ด์์.
ํจ์
void print(string Text)
๋ก๊ทธ์ฐฝ์ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํด์. (์ถ๋ ฅํ ๋ด์ฉ)
-- ์ํ --
--๋ฌธ์์ด(๋ฉ์์ง)์ ๋ก๊ทธ์ฐฝ์ ์ถ๋ ฅํด์.
print("Hello World!")
--.. ์ ์ด์ฉํด์ ๊ฐ๊ฐ์ ๋ฌธ์์ด์ ํฉ์ณ์ ๋ฉ์์ง๋ฅผ ๋ก๊ทธ์ฐฝ์ ์ถ๋ ฅํด์.
print("Hello " .. "Dito" .. "Land!")
--์ซ์๋ bool ๋ฑ์ ์๋ฃํ๋ ์ถ๋ ฅํ ์ ์์ด์.
print(1)
print(1.5)
print(false)
print(Vector.new(50, 0, 5))
print(Color.new(255, 255, 255, 255))
--์ค์๋ math.floor๋ก ์ ์๋ก ๋ณํํด์ ์ถ๋ ฅํ ์ ์์ด์.
print(math.floor(6.529))
--๋ณ์์ ์ ์ฅํ ๊ฐ๋ ์ถ๋ ฅํ ์ ์์ด์.
local SomeNumber = 5
local FloorTransform = Workspace.Floor.Transform
print(SomeNumber)
print(FloorTransform)
--์ผํ๋ฅผ ์ด์ฉํด์ ์ฌ๋ฌ ๊ฐ์ ์ถ๋ ฅํ ์ ์์ด์.
print(1, " / ", 50.2, " / ", "Hello", " / ", true, " / ", Vector.new(50, 0, 10))
void Log(string Text)
๋ก๊ทธ์ฐฝ์ ์ผ๋ฐ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํด์. (์ถ๋ ฅํ ๋ด์ฉ)
-- ์ํ --
Log("Log")
void LogWarning(string Text)
๋ก๊ทธ์ฐฝ์ ์๋ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํด์. (์ถ๋ ฅํ ๋ด์ฉ)
-- ์ํ --
LogWarning("Warning")
void LogError(string Text)
๋ก๊ทธ์ฐฝ์ ์๋ฌ ๋ฉ์์ง๋ฅผ ์ถ๋ ฅํด์. (์ถ๋ ฅํ ๋ด์ฉ)
-- ์ํ --
LogError("Error")
number time()
๊ฒ์์ ๊ฒฝ๊ณผ ์๊ฐ์ ์ป์ ์ ์์ด์.
-- ์ํ --
local startTime = time()
print("wait 3s")
wait(3)
local passTime = time() - startTime
print(passTime)
number ostime()
OS ์๊ฐ์ ์ป์ ์ ์์ด์. 1970๋ 1์ 1์ผ 0์ 0๋ถ 0์ด๋ฅผ ๊ธฐ์ ์ผ๋ก ํ์ฌ๊น์ง ํ๋ฅธ ์๊ฐ์ ์ด๋จ์๋ก ๋๋ ค์ค๋๋ค.
-- ์ํ --
local getTime = ostime()
print(getTime)
DateTime nowtime()
ํ์ฌ ์๊ฐ์ ์ป์ ์ ์์ด์.
-- ์ํ --
local getTime = nowtime()
print(getTime)
DateTime ToDateTime()
OsTime์ผ๋ก ๋ถํฐ DateTime๋ฅผ ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local getOsTime = ostime()
local Date = ToDateTime(getOsTime)
number ToOsTime()
Date์ผ๋ก ๋ถํฐ OsTime๋ฅผ ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local getDate = nowtime()
local getOsTime = ToOsTime(getDate)
number GetDayOfYear()
Date์ผ๋ก ๋ถํฐ ์ฌํด ๊ธฐ์ค ๊ฒฝ๊ณผ์ผ์ ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local getDate = nowtime()
local DayOfYear = GetDayOfYear(getDate)
number GetWeekOfYear()
Date์ผ๋ก ๋ถํฐ ์ฌํด ๊ธฐ์ค ์ฃผ์ฐจ๋ฅผ ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local getDate = nowtime()
local WeekOfYear = GetWeekOfYear(getDate)
number GetNumberOfWeek()
Date์ผ๋ก ๋ถํฐ ์ด๋ฒ ์ฃผ ๊ธฐ์ค์ผ๋ก ์์ผ ๋ฒํธ ๋ฐํ์ ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local getDate = nowtime()
local NumberOfWeek = GetNumberOfWeek(getDate)
bool IsChangedYear()
๋น๊ตํ๋ Date๊ฐ ๋ค์ ํด์ธ์ง ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local ChangedYear = IsChangedYear(T1,T2)
bool IsChangedMonth()
๋น๊ตํ๋ Date๊ฐ ๋ค์ ์์ธ์ง ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local ChangedMonth = IsChangedMonth(T1,T2)
bool IsChangedDay()
๋น๊ตํ๋ Date๊ฐ ๋ค์ ๋ ์ธ์ง ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local ChangedDay = IsChangedDay(T1,T2)
bool IsChangedWeek()
๋น๊ตํ๋ Date๊ฐ ๋ค์ ์ฃผ์ธ์ง ์ป์ด ์ฌ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local ChangedWeek = IsChangedWeek(T1,T2)
number GetCompareYear()
๋ ๋ ์ง์ ์ฐจ์ด ๋ ์ ์ป์ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local CompareYear = GetCompareYear(T1,T2)
number GetCompareMonth()
๋ ๋ ์ง์ ์ฐจ์ด ๋ฌ์ ์ป์ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local CompareMonth = GetCompareMonth(T1,T2)
number GetCompareDay()
๋ ๋ ์ง์ ์ฐจ์ด ์ผ์ ์ป์ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local CompareDay = GetCompareDay(T1,T2)
number GetCompareHour()
๋ ๋ ์ง์ ์ฐจ์ด ์๊ฐ์ ์ป์ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local CompareHour = GetCompareHour(T1,T2)
number GetCompareMinute()
๋ ๋ ์ง์ ์ฐจ์ด ๋ถ์ ์ป์ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local CompareMinute = GetCompareMinute(T1,T2)
number GetCompareSec()
๋ ๋ ์ง์ ์ฐจ์ด ์ด๋ฅผ ์ป์ ์ ์์ด์.
-- ์ํ --
local T1 = DateTime.new(2022, 12, 31, 11, 20, 34)
local T2 = DateTime.new(2023, 01, 01, 11, 20, 34)
local CompareSec = GetCompareSec(T1,T2)
ModuleObject require(ObjectScript ModuleScript)
๋ชจ๋ ๊ธฐ๋ฅ์ ์ฌ์ฉํ ์ ์๊ฒ ๋ก๋ํด์. (๋ชจ๋์คํฌ๋ฆฝํธ) (์คํฌ๋ฆฝํธ ์ฒ์ ๋ถ๋ถ์์ ํ๋ฒ๋ง ์์ฑํ๋ ๊ฒ์ ๊ถ์ฅํฉ๋๋ค.)
-- ์ํ --
local Utility = require(ScriptModule.DefaultModules.Utility)
void assert(bool condition)
condition ๊ฐ์ด false์ด๋ฉด ์๋ฌ๋ฅผ ์ถ๋ ฅํด์. (์กฐ๊ฑด ๊ฐ)
-- ์ํ --
local MakeError = false
print("a")
assert(MakeError) --์ธ์๊ฐ true๊ฐ ์๋๋ฉด ์๋ฌ๋ฅผ ์ถ๋ ฅํ๊ณ , ๋ค์ ์ค์ ์ฒ๋ฆฌํด์.
assert(MakeError, "Some Error!!") --๋๋ฒ์งธ ์ธ์์ ์๋ฌ์ ์ถ๋ ฅํ ๋ด์ฉ์ ๋ฃ์ ์ ์์ด์.
print("b")
void wait(number Time)
์ง์ ํ ์๊ฐ๋งํผ ๊ธฐ๋ค๋ ค์. (๋๊ธฐ์๊ฐ)
-- ์ํ --
print("wait 3s")
wait(3)
print("end wait!")
void waitbool(function TargetFunction)
ํจ์์ ๋ฐํ๊ฐ์ด true๊ฐ ๋ ๋๊น์ง ํจ์๋ฅผ ๊ณ์ ํธ์ถํด์. (ํธ์ถํ ํจ์)
-- ์ํ --
local hour = 1
local function IsMorning()
if hour < 20 then
print("It's Morning!")
hour = hour + 1
return false
else
print("It's Night!")
return true
end
end
waitbool(IsMorning) --ํจ์์ ๋ฐํ๊ฐ์ด true๊ฐ ๋ ๋๊น์ง ํจ์๋ฅผ ๊ณ์ ํธ์ถํด์
void waitfunction(function TargetFunction)
ํจ์๋ฅผ ํธ์ถํ ๋ค,ํจ์๊ฐ ์ข ๋ฃ๋ ๋๊น์ง ๊ธฐ๋ค๋ ค์. (ํธ์ถํ ํจ์)
-- ์ํ --
print("Call WaitMessage Function")
local function WaitMessage()
print("wait 3s")
wait(3)
print("Hello DitoLand!")
end
waitfunction(WaitMessage) --ํจ์๋ฅผ ํธ์ถํ ๋ค, ํจ์๊ฐ ์ข
๋ฃ๋ ๋๊น์ง ๊ธฐ๋ค๋ ค์
print("End WaitMessage Function")
coroutine create(function TargetFunction)
์ฝ๋ฃจํด์ ์์ฑํด์.
-- ์ํ --
local co = coroutine.create(function()
print("Hello!")
end)
void resume(coroutine coroutine)
์ฝ๋ฃจํด์ ์คํํด์.
-- ์ํ --
local co = coroutine.create(function()
print("Hello!")
end)
coroutine.resume(co)
void yield()
์คํ์ค์ธ ์ฝ๋ฃจํด์ ์ผ์์ ์งํด์. (์ฝ๋ฃจํด ์์์ ์ฌ์ฉํด์ผ ํด์.)
-- ์ํ --
local co = coroutine.create(function()
for i = 1, 3 do
print("num : " .. i)
coroutine.yield()
end
end)
coroutine.resume(co) -- num : 1
coroutine.resume(co) -- num : 2
coroutine.resume(co) -- num : 3
void wrap(function TargetFunction)
ํจ์์ฒ๋ผ ๋ฐ๋ก ํธ์ถํ ์ ์๋ ์ฝ๋ฃจํด์ ์์ฑํด์.
-- ์ํ --
local co = coroutine.wrap(function()
print("Hello!")
end)
co()
string status(coroutine coroutine)
์ฝ๋ฃจํด์ ์ํ๋ฅผ ๋ฐํํด์.
-- ์ํ --
local co = coroutine.create(function()
print("Hello!")
end)
print(coroutine.status(co)) -- suspend
coroutine.resume(co)
print(coroutine.status(co)) -- dead
Last updated
Was this helpful?