← 목록

mLua · 문서 코드 예제

총 794개 · 페이지 9/27
🔀 랜덤
불러오는 중…

[source] | guide_examples [title] | MSW 기본 이벤트 함수 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=163 [code] | void OnEndPlay() { log("OnEndPlay!!") -- Console Result -- OnEndPlay!! }

[source] | guide_examples [title] | MSW 기본 이벤트 함수 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=163 [code] | void OnDestroy() { log("OnDestroy!!") -- Console Result -- OnDestroy!! }

[source] | guide_examples [title] | MSW 기본 이벤트 함수 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=163 [code] | void OnMapEnter(Entity enteredMap) { --map01에 입장할 때마다 플레이어 크기가 커짐 if enteredMap.Name == "map01" then local myPlayer = self.Entity local transform = myPlayer.TransformComponent local scale = transform.Scale scale.x = scale.x + 1 scale.y = scale.y + 1

[source] | guide_examples [title] | MSW 기본 이벤트 함수 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=163 [code] | void OnMapLeave(Entity leftMap) { --map01에서 퇴장할 때마다 플레이어 크기가 작아짐 if leftMap.Name == "map01" then local myPlayer = self.Entity local transform = myPlayer.TransformComponent local scale = transform.Scale scale.x = scale.x - 1 scale.y = scale.y - 1

[source] | guide_examples [title] | MSW 기본 이벤트 함수 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=163 [code] | Property: [Sync] number HP = 100 [Sync] number MP = 100 Method: [Client Only] void OnSyncProperty(string name, any value) --name : 프로퍼티 이름, value : 변경된 프로퍼티 값 { if name == "HP" then if self.HP == value then log("동기화가 완료된 시점에 호출되므로, 이 로그가 콘솔 창에 출력됩니다.") return

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | void OnBeginPlay() { local myEntity = self.Entity log(myEntity.Name) -- 엔티티 이름 출력 }

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | void OnBeginPlay() { local myEntity = self.Entity log(myEntity.Name) -- Entity C의 이름 출력 local parentEntity = myEntity.Parent log(parentEntity.Name) -- Entity A의 이름 출력 }

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | void OnBeginPlay() { local myEntity = self.Entity log(myEntity.Name) -- Entity C의 이름 출력 local parentEntity = myEntity.Parent log(parentEntity.Name) -- Entity A의 이름 출력 local children = parentEntity.Children --Entity A의 하위 엔티티를 테이블 형태로 받아 옴 local childrenEntit

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | void OnBeginPlay() { local myEntity = self.Entity -- 자신이 포함하고 있는 EntityH를 받아 옴 local curMap = myEntity.CurrentMap -- 현재 EntityH가 속한 맵인 map01엔티티를 받아 옴 if isvalid(curMap) == false then return end log(curMap.Name) --콘솔 창에 "map01" 출력 }

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | void OnBeginPlay() { local myEntity = self.Entity -- 자신이 포함하고 있는 EntityB를 받아 옴 local world = myEntity.CurrentWorld -- 최상위 엔티티인 World 엔티티를 받아 옴 if isvalid(world) == false then return end log(world.Name) --콘솔 창에 "World" 출력 }

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | void PrintUserEntitiesName() { log(_UserService:GetUserCount()) local playerEntitiesDic = _UserService.UserEntities -- 모든 플레이어를 순회하며 콘솔 창에 "플레이어 key 값/플레이어 이름" 형식으로 출력 for key, playerEntity in pairs(playerEntitiesDic) do log(key.."/"..playerEntity.Name)

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | [client Only] void OnBeginPlay() { local myPlayerEntity = _UserService.LocalPlayer log(myPlayerEntity.Name) -- 내 플레이어 엔티티 이름 출력 } [server Only] void OnBeginPlay() { -- 서버에서는 내 플레이어라는 개념이 없으므로 nil 반환 local myPlayerEntity = _UserService.LocalPlayer log(myPlayerEntity)

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | [client only] void OnBeginPlay() { local myPlayerEntity = _UserService.LocalPlayer -- 내 플레이어 엔티티의 컴포넌트를 변수 rigidbody에 참조 local rigidbody = myPlayerEntity.RigidbodyComponent if rigidbody == nil then log("rigidbody is nil") return end log(rigidbody) }

[source] | guide_examples [title] | 엔티티와 컴포넌트 참조 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=164 [code] | [client only] void OnBeginPlay() { local myPlayerEntity = _UserService.LocalPlayer -- 내 플레이어 엔티티의 스크립트 컴포넌트를 변수 status에 참조 local status = myPlayerEntity.CharacterStatus if status == nil then return nil end log(status) }

[source] | guide_examples [title] | 함수 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=172 [code] | --개념 이해를 돕기 위한 코드로, 컴포넌트에 적용 시 정상적으로 동작하지 않을 수 있습니다. void OnBeginPlay() { local param = "MethodCallTest" self:MethodPractice(param) -- self:메소드명(매개 변수)으로 메소드 호출 } void MethodPractice(string parameter) { log(parameter) -- 콘솔 창에 "MethodCallTest" 출력 }

[source] | guide_examples [title] | 함수 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=172 [code] | --개념 이해를 돕기 위한 코드로, 컴포넌트에 적용 시 정상적으로 동작하지 않을 수 있습니다. void OnBeginPlay() { local param = "MethodCallTest" local mapEntity = _EntityService:GetEntityByPath("/maps/map01") -- 서비스의 메소드 호출 시 local componentInstance = mapEntity.TestComponent -- 다른 컴포넌트 객체 참조 componen

[source] | guide_examples [title] | 함수 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=172 [code] | --개념 이해를 돕기 위한 코드로, 컴포넌트에 적용 시 정상적으로 동작하지 않을 수 있습니다. void OnBeginPlay() { --루아 함수 사용 예시 local tmpTable = {1,2,3,4,5} table.insert(tmpTable, 6) -- :이 아닌 .으로 함수 호출 local len = string.len("Method Practice") -- :이 아닌 .으로 함수 호출 log(#tmpTable)

[source] | guide_examples [title] | Entity Event System [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=176 [code] | Property: boolean isSunrise = false

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void GetEntityByPathExample() { local entity = _EntityService:GetEntityByPath("/maps/map01/npc-320_1") local uiEntity = _EntityService:GetEntityByPath("/ui/DefaultGroup/Image_1") log(entity.Name) log(uiEntity.Name) }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void GetEntitiesByPathExample() { local entityArray = _EntityService:GetEntitiesByPath("/maps/map01/Bullet") for i, entity in pairs(entityArray) do log(entity.Name) end }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void GetEntityExample() { local bulletEntity = _EntityService:GetEntityByPath("/maps/map01/Bullet") local bulletEntityId = bulletEntity.Id local bulletEntityById = _EntityService:GetEntity(bulletEntityId) if bulletEntity == bulletEntityById then log(bulletEntity.Id)

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void GetEntitiesSpawnedByModelIdExample() { local modelId = _EntityService:GetEntityByPath("/maps/map02/npc-5396_1").Model.BaseModelId local entities = _EntityService:GetEntitiesSpawnedByModelId(modelId) for i, v in pairs(entities) do log(v.Name) end }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void GetEntitiesSpawnedByModelExample() { local model = _EntityService:GetEntityByPath("/maps/map02/npc-5396_1").Model local entities = _EntityService:GetEntitiesSpawnedByModel(model) for i, entity in pairs(entities) do log(entity.Name) end }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void GetSameModelEntitiesExample() { local templateEntity = _EntityService:GetEntityByPath("/maps/map02/npc-5396_1") local entities = _EntityService:GetSameModelEntities(templateEntity) for i, entity in pairs(entities) do log(entity.Name) end }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void GetEntityByTagExample() { local entity = _EntityService:GetEntityByTag("FlayingMonster") log(entity.Name) }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void GetEntitiesByTagExample() { local monsterEntities = _EntityService:GetEntitiesByTag("Monster") for i, monsterEntity in pairs(monsterEntities) do log(monsterEntity.Name) end }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void DestroyExample() { local entity = _EntityService:GetEntityByPath("/maps/map01/Monster1_1") _EntityService:Destroy(entity) if isvalid(entity) == false then log("Entity is destroyed") end }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void DestroyExample() { local entity = _EntityService:GetEntityByPath("/maps/map01/Monster1_1") entity:Destroy() if isvalid(entity) == false then log("Entity is destroyed") end }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void IsValidExample() { local entity = _EntityService:GetEntityByPath("/maps/map01/Monster1_1") _EntityService:Destroy(entity) if _EntityService:IsValid(entity) == false then log("Entity is destroyed") end }

[source] | guide_examples [title] | 엔티티를 탐색하는 EntityService [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=201 [code] | void IsvalidExample() { local entity = _EntityService:GetEntityByPath("/maps/map01/Monster1_1") _EntityService:Destroy(entity) if isvalid(entity) == false then log("Entity is destroyed") end }

← → 방향키로 페이지 이동 · 숫자 입력 후 Enter로 점프