:DitoLand
Studio ManualAPI ReferenceVideo TutorialSample
  • DitoLand Developer
  • πŸ“šGlossary
  • πŸ₯³EVENT
    • 2024 λ©”νƒ€λ²„μŠ€ 개발자 κ²½μ§„λŒ€νšŒ
    • 🎊[μ’…λ£Œ] πŸ–₯ μ „λ‚¨κ΄€κ΄‘λ©”νƒ€λ²„μŠ€ μŠ€νƒ¬ν”„ νˆ¬μ–΄ 인증 이벀트
  • Notice
    • μ•½κ΄€ κ°œμ •(2024.06.17)
    • μ•½κ΄€ κ°œμ • (2024.03.04)
    • μ•½κ΄€ κ°œμ • (2023.08.25)
    • μ•½κ΄€ κ°œμ • (2022.12.14)
  • Manual
    • Studio
    • Resources
    • Studio Workflow Tips
    • NPC
    • NavMeshVolume
    • Land Teleport
    • Enterprise Account
    • Enterprise Studio Manual
    • Coroutine
    • AddTimeEvent
    • SaveUserData
    • Set Object Parameter
    • Toolbox Upload
    • Debugging (Breakpoint)
    • Gun Toy
    • Coupon / Event Key
    • Optimization
    • AI FSM
    • SpreadSheet
    • Mod Kit
    • AddReplicateValue / ConnectChangeEventFunction
    • Event Execution Order
    • WorldTree Search Filter
    • Object
    • Coordinate
    • Inworld Product
    • Management UserData & Leaderboard
    • Channel
    • World Event
    • Matchmaking
    • Collecting Game Logs
    • External Avatar
  • Coding Style
  • API Reference
    • Global
      • Variables
    • Lua
      • Built-in
      • NotSupport
    • Enums
      • AttachPoint
      • Bone
      • CharacterType
      • ChatCategoryType
      • ChatVisibleType
      • CollisionResponse
      • ControlMode
      • DivideTeamType
      • EventKeyState
      • InputMode
      • InventoryState
      • Key
      • KeyInputType
      • LuckyDrawOrderState
      • MaterialType
      • MediaStateType
      • ModeAnimStateType
      • ObjectSelectType
      • ObjectType
      • PathFollowingStatus
      • PointSpawnType
      • ProgressFillType
      • ProjectionType
      • QuickSlotState
      • ReplicateType
      • ScrollOrientationType
      • SimulatePhysicsType
      • SpawnType
      • TeamType
      • TeleportErrorType
      • TouchType
      • TransformPlayType
      • UIDisplayType
      • UIWidgetType
      • WidgetAnchorType
    • Common
      • BindEvent
      • Character
      • Collision
      • Color
      • CouponReturnData
      • DateTime
      • Environment
      • EventKeyReturnData
      • FactorPhysics
      • FiniteState
      • FiniteStateMachine
      • Game
      • GameStatisticsData
      • HitResult
      • Item
      • LandTransferData
      • Matrix
      • MouseHitResult
      • Object
      • Physics
      • ScriptPhase
      • TimeEvent
      • Track
      • Vector
      • WorldObject
    • Client
      • AnimStateBase
      • AnimStateMachine
      • AnimStateMachineSetting
      • BlendAnimationDataSetting
      • BlendAnimState
      • BlendAnimStateSetting
      • Button
      • Camera
      • CameraClient
      • Character
      • CharacterAnimationSetting
      • CharacterAppearanceSetting
      • CharacterBaseSetting
      • CharacterClient
      • CharacterSetting
      • Collider
      • Collision
      • DPad
      • Environment
      • FiniteStateMachine
      • Frame
      • FX
      • Game
      • GridBox
      • HyperLinkButton
      • Image
      • Input
      • InputGroup
      • InventoryBox
      • Item
      • ListView
      • LocalPlayer
      • Media
      • MediaView
      • NPC
      • ObjectGroup
      • ObjectNoneClient
      • PDFView
      • Physics
      • PointLight
      • ProgressBar
      • RemotePlayer
      • ScreenButton
      • ScreenUI
      • Script
      • ScrollBox
      • SequenceAnimState
      • SequenceAnimStateSetting
      • Sound
      • SpotLight
      • StaticMesh
      • SurfaceUI
      • Text
      • TextBox
      • UIScene
      • WebBrowser
      • WebForum
      • WidgetBase
      • YouTubeView
    • Server
      • Character
      • CharacterAnimationSetting
      • CharacterAppearanceSetting
      • CharacterBaseSetting
      • CharacterServer
      • CharacterSetting
      • Collider
      • Collision
      • Environment
      • FactorPhysics
      • FiniteStateMachine
      • FX
      • Game
      • Item
      • Media
      • NPC
      • Physics
      • Player
      • PointLight
      • Script
      • ScriptObjectGroup
      • ScriptObjectNoneServer
      • Sound
      • Spawner
      • SpawnPoint
      • SpawnPointGroup
      • SpotLight
      • StaticMesh
      • Team
      • UIScene
      • Widget
  • Tutorial
    • Script Tutorial
      • 슀크립트 심화 κ°•μ’Œ
        • 1. 슀크립트의 μ’…λ₯˜, 호좜 μˆœμ„œ, 호좜, 톡신
        • 2. 동기화, νŒŒλΌλ―Έν„°, μ˜ˆμ™Έμ‚¬ν•­
        • 3. λ””ν† λžœλ“œλ‘œ 루아 ν™œμš©ν•˜κΈ°
  • Sample
    • Scripting
    • Event
    • Collision & Physics
    • Transform
    • UI
    • Camera
    • Input
    • FX
    • Sound
  • Guide for Developers
    • Guide For Unity Developer
    • Guide For Roblox Developer
  • Release Note
    • Script Changes
      • 1.5.0 Map Changes
      • 1.2.0 Map Changes
      • 1.1.0 Map Changes
      • 1.0.0 Map Changes
      • 0.9.0 Map Changes
      • 0.7.0 Map Changes
      • 0.6.0 Map Changes
      • 0.5.0 Map Changes
      • 0.4.0 Map Changes
      • 0.3.0 Map Changes
      • 0.2.0 Map Changes
    • Known Issues
Powered by GitBook
On this page

Was this helpful?

  1. API Reference
  2. Lua

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
PreviousLuaNextNotSupport

Last updated 1 year ago

Was this helpful?