log("Hello World!")
//변수 선언
local number = 1
local sum = 0
log(sum)
//함수
void Sum()
{
//반복문 선언
for count = 1, 10, 1 do //1부터 10까지 1씩 증가
//조건문
if count%2 == 0 then
sum = sum + count
end
end
}
기능을 모아둔 것
본인이 원하는 함수를 추가하여 사용할 수 있다.
void OnBeginPlay()
{
local myEntity = self.Entity //자기 자신이 적용된 엔티티 참조 가능.
log(myEntity.Name.."HelloMOD") //콘솔 창에 myEntity의 이름과 "HelloMOD!" 출력
--OnInitialize와는 달리 아래와 같이 다른 엔티티, 다른 컴포넌트의 참조가 보장됩니다.
local otherComponent = myEntity.컴포넌트이름
local otherEntity = _EntityService:GetEntityByPath("엔티티 경로")
local otherEntityComponent = otherEntity :GetComponent("컴포넌트이름")
}
ComponentA{
Property :
[Sync]
string B = ""
Function :
[server only]
void OnInitialize() //바뀐 부분
{
self.B = "Hello"
log(self.B)
}
}
ComponentC{
Property :
Function :
[Server Only]
void OnBeginPlay()
{
local myEntity = self.Entity
local componentA = myEntity.componentA
log(componentA.B) //ComponentA에서 OnInitialize를 통해 값을 할당했으므로, 콘솔 창에 "Hello"가 출력되게 됩니다.
}
}