ServerScript --Workspace/Sample/Cube1/Cube2 경로에 있는 오브젝트를 Cube2 변수에 할당해요. local ChildCube = Workspace.Sample.Cube1.Cube2 --.Parent로 대상 오브젝트의 부모를 얻어서 ParentCube 변수에 할당해요. local ParentCube = ChildCube.Parent print("Child Cube Name : " .. ChildCube:GetName()) --자식 오브젝트의 이름을 로그창에 출력해요. print("Parent Cube Name : " .. ParentCube:GetName()) --부모 오브젝트의 이름을 로그창에 출력해요. 더보기 함수 string GetName() 객체의 이름을 얻을 수 ..
ServerScript --Workspace/Sample/CubeList 경로에 있는 오브젝트의 --자식 오브젝트 리스트를 GetChildList()로 얻은 다음, --CubeList 변수에 할당해요. local CubeList = Workspace.Sample.CubeList:GetChildList() --반복문을 이용해서 CubeList 변수에 할당된 오브젝트들의 이름을 print로 출력해요. --첫번째(i = 1)부터 시작해서, --CubeList의 크기(#CubeList)만큼 반복하고 --n번째 자식 오브젝트(CubeList[i])의 이름을 로그창에 출력해요. for i = 1, #CubeList do print("Child Object Name : " .. CubeList[i]:GetName()..
SeverScript --Workspace/Sample/Cube 경로에 있는 오브젝트를 Cube 변수에 할당해요. local Cube = Workspace.Sample.Cube --변경할 색상을 변수에 할당해요. local NewColor1 = Color.new(255, 0, 0, 255) local NewColor2 = Cube:GetColor() --GetColor()로 큐브의 색상을 얻은 다음 변수에 저장해요. wait(2) --2초를 기다린뒤, Cube:SetColor(NewColor1) --큐브의 색상을 NewColor1으로 변경해요. wait(2) --2초를 기다린뒤, Cube:SetColor(NewColor2) --큐브의 색상을 NewColor2으로 변경해요. Script Log
SeverScript --Workspace/Sample/Cube 경로에 있는 오브젝트를 Cube 변수에 할당해요. local Cube = Workspace.Sample.Cube print("Cube Name : " .. Cube:GetName()) --GetName()으로 큐브의 이름을 얻은 다음 로그창에 출력해요. wait(1) --1초를 기다린뒤, Cube:SetName("NewName") --큐브의 이름을 NewName으로 변경해요. print("Cube Name : " .. Cube:GetName()) --GetName()으로 큐브의 이름을 얻은 다음 로그창에 출력해요. Script Log
ServerScript print("wait 15 second") wait(15) --15초를 기다린뒤, --게임의 모든 플레이어를 Game:GetAllPlayer()로 얻은 다음, --AllPlayer 변수에 할당해요. local AllPlayer = Game:GetAllPlayer() --반복문을 이용해서 AllPlayer 변수에 할당된 플레이어들의 이름을 print로 출력해요. --첫번째(i = 1)부터 시작해서, --AllPlayer의 크기(#AllPlayer)만큼 반복하고 --n번째 자식 오브젝트(AllPlayer[i])의 이름을 로그창에 출력해요. for i = 1, #AllPlayer do print("Player Name : " .. AllPlayer[i]:GetName()) end 더보기..
ServerScript wait(2) --2초를 기다린 뒤, local Player = Game:GetAllPlayer()[1] --게임의 첫번째 플레이어를 얻어서 Player 변수에 할당해요. 더보기 예제 --게임의 모든 플레이어를 Game:GetAllPlayer()로 얻은 다음, --AllPlayer 변수에 할당해요. local AllPlayer = Game:GetAllPlayer() --반복문을 이용해서 AllPlayer 변수에 할당된 플레이어들의 이름을 print로 출력해요. --첫번째(i = 1)부터 시작해서, --AllPlayer의 크기(#AllPlayer)만큼 반복하고 --n번째 자식 오브젝트(AllPlayer[i])의 이름을 로그창에 출력해요. for i = 1, #AllPlayer do ..
SeverScript --Workspace/Sample/Cube 경로에 있는 오브젝트를 Cube 변수에 할당해요. local Cube = Workspace.Sample.Cube --Cube의 스크립트 파라미터들을 변수에 할당해요. local ChangePos = Cube.ChangePos local CubeIndex = Cube.CubeIndex local IsCoolObject = Cube.IsCoolObject local Description = Cube.Description local TargetObj = Cube.TargetObj --메시지를 로그창에 출력해요. print(ChangePos) print(CubeIndex) print(IsCoolObject) print(Description) pri..
SeverScript --Workspace/Sample/CubeList 경로에 있는 오브젝트를 CubeFolder 변수에 할당해요. local CubeFolder = Workspace.Sample.CubeList --오브젝트들을 할당할 테이블 변수를 선언해요. local CubeList = {} --CubeList 테이블에 오브젝트를 할당해요. table.insert(CubeList, CubeFolder.RedCube) table.insert(CubeList, CubeFolder.GreenCube) table.insert(CubeList, CubeFolder.BlueCube) 더보기 리스트 Lua에서 리스트는 table로 구현할 수 있습니다. 샘플 local function Sample() local o..
ClientScript --로컬 플레이어를 Player 변수에 할당해요. local Player = LocalPlayer:GetRemotePlayer() 더보기 함수 RModeRemotePlayer GetRemotePlayer(string PlayerName) 이름으로 플레이어를 얻을 수 있어요. (찾고싶은 플레이어 이름) 샘플 local player = LocalPlayer:GetRemotePlayer() --자신의 플레이어를 반환해요. print("Wait Spawn Character") --조건(Player:GetCharacter())이 true가 될때까지 repeat 다음의 동작(wait)을 반복해요. --repeat의 조건이 true가 되어야 repeat 다음줄의 동작을 수행해요. repeat ..
ServerScript1 --변수나 함수를 선언할때 local을 생략하면 전역(global)으로 선언되요. --전역으로 선언한 변수/함수는 외부 스크립트(ServerScript2)에서도 사용할 수 있어요. GlobalValue = 1 function GlobalFunction() print("I'm GlobalFunction") end -------------------------------------------------- local LocalValue = 1 local function LocalFunction() print("I'm LocalFunction") end -- Tip -- 지역(local)으로 선언한 변수/함수는 선언한 스크립트(ServerScript1) 안에서만 사용할 수 있어요. 선언..
ClientScript - 특정 플레이어에게 처리할 내용 print("Hello World! (Client Script)") --메시지를 로그창에 출력해요. ServerScript - 게임을 만들 때 서버에서 사용할 로직을 구현 print("Hello World! (Server Script)") --메시지를 로그창에 출력해요. wait(1) --1초를 기다린 뒤, local SomeNumber = 5 --SomeNumber 변수를 선언하고 값을 할당해요. --변수나 숫자도 출력할 수 있어요. print(SomeNumber) print(1) print(1.5) print(false) --실수는 math.floor로 정수로 변환해서 출력할 수 있어요. print(math.floor(6.529)) --.. 을..
" " ' ' 루아의 문자열은 큰따옴표와 작은따옴표로 둘러싸인 집합이다. print(‘Hello lua’) print(“Hi there”)--둘 다 가능하다. print(“H”)--문자가 하나여도 단문자라는 다른 자료형이 별도로 있는 것이 아니라 그냥 문자열로 간주가 된다. 작은 따옴표로 둘러쳐진 문자열에서는 큰 따옴표를 안에서 자유롭게 사용할 수 있다. print(‘He said ”Hi.”’)--큰 따옴표는 보통의 문자로 간주가 된다. print(“I’m fine.”)--반대로 큰 따옴표 안에 작은 따옴표도 일반적인 문자로 간주가 된다. local s = ‘hello world’ local x = “Hi lua” print(s)--이렇게 해도 문자를 출력할 수 있다. print(x)--프린트 함수로 넘..
print print("hello lua") 인자로 주는 문자열이나 변수 등의 값을 화면에 출력해주는 역할 식별자 변수, 함수의 이름으로 사용되는 것 영어 대소문자 숫자 언더바 ( _ ) 규칙은 C++과 같다 숫자로 시작하거나 공백 포함 불가능 and, break, do, else, elseif, end, false, for, function, if, in local, nil, not, or, repeat, return, then, true, until, while 미리 정의된 예약어 사용 불가능 지역변수, 전역변수 Lua에서 보통 local 이라는 키워드를 붙여 변수를 사용한다 local a → a 라는 변수를 사용하겠다 local을 붙이면 a라는 변수를 지역변수로 생성하여 사용하겠다고 하는 것 a =..
Clone과 Destroy * 아래와 같이 작성 시 정상적으로 작동하지 않는다. (홈페이지 https://ditoland-utplus.gitbook.io/ditoland/guide-for-developers/guide-for-roblox-developer) --Sever Script-- local cube = Workspace.Cube local createPos = Vector.new(1, 3, 2) --Clone처럼 동작합니다. local temp = Game:CreateSyncObject(cube, createPos, "Cube", Workspace) wait(2) --Destroy처럼 동작합니다. Game:DeleteObject(temp) * 정상 작동 코드, 문제 함수 수정 local temp ..