← 목록

mLua · 문서 코드 예제

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

[source] | guide_examples [title] | 메이플스토리 월드 루아 문법 확장 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1071 [code] | local num = 2 -- 0b0010 -- num의 이진수를 오른쪽으로 1만큼 이동시킴 num >>= 1 -- 0b0001 print(num) -- Output : -- 1

[source] | guide_examples [title] | 메이플스토리 월드 루아 문법 확장 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1071 [code] | local a = 10 -- 이진수 1010 local b = 7 -- 이진수 0111 local result = a & b -- 비트 AND 연산 수행 print(result) -- Output : -- 2 (이진수 0010) local result = a | b -- 비트 OR 연산 수행 print(result) -- Output : -- 15 (이진수 1111)

[source] | guide_examples [title] | 메이플스토리 월드 루아 문법 확장 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1071 [code] | local cardKeywords = { Taunt = 1 << 0, BattleCry = 1 << 1, Deathrattle = 1 << 2, Windfury = 1 << 3, Immune = 1 << 4, } local function HasKeyword(card, keyword) return (card & keyword) == keyword end local newCard = cardKeywords.Taunt | cardKeywords.BattleCry print("Taunt :

[source] | guide_examples [title] | 효과적으로 DataStorage 사용하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1073 [code] | Property: [Sync] integer meso = 0 Method: [server only] void OnBeginPlay() { if self:LoadMesoData() == false then _UserService:KickUser(self.Entity.PlayerComponent.UserId, KickReason.WorldError) -- 유저 내보내기 return end } [server only] boolean LoadMesoData() { local userD

[source] | guide_examples [title] | 효과적으로 DataStorage 사용하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1073 [code] | Property: [Sync] integer meso = 0 [Sync] boolean initialized = false Method: [server only] void OnBeginPlay() { local retryCount = 2 -- 2번 재시도하게 설정. 총 3번 저장 시도. while retryCount >= 0 do if self:LoadMesoData() == true then break end wait(1) -- 입력

[source] | guide_examples [title] | 효과적으로 DataStorage 사용하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1073 [code] | Property: [Sync] boolean initialized = false -- 이 프로퍼티를 사용해 저장 막기. [Sync] integer meso = 0 Method: [server only] void OnBeginPlay() { if self:LoadMesoData() == false then return end self.initialized = true } [server only] boolean LoadMesoData() { local userDataStorage = _

[source] | guide_examples [title] | 효과적으로 DataStorage 사용하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1073 [code] | Property: [Sync] boolean initialized = false [Sync] integer meso = 0 [Sync] integer cash = 0 [None] table items = {} -- ItemIDs Method: [server only] void OnBeginPlay() { self:LoadData() } [server only] void LoadData() { local userDataStorage = _DataStorageService:GetUserDataStorage(se

[source] | guide_examples [title] | 효과적으로 DataStorage 사용하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1073 [code] | Method: [server] void RequestBuyItemFromClient(string userId, integer buyItemId) { local userEntity = _UserService:GetUserEntityByUserId(userId) if isvalid(userEntity) == false then return end local userDataComponent = userEntity.UserDataComponent if isvali

[source] | guide_examples [title] | 효과적으로 DataStorage 사용하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1073 [code] | Property: [None] integer meso = 0 [None] integer cash = 0 Method: [server only] boolean LoadCurrency() { local userDataStorage = _DataStorageService:GetUserDataStorage(self.Entity.PlayerComponent.UserId) if userDataStorage == nil then return end local errorCode, currencySt

[source] | guide_examples [title] | 효과적으로 DataStorage 사용하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1073 [code] | Property: [None] number lastSaveTime = 0 Method: [server] void SaveData() { local cooldown = 120 -- 120초 동안 저장 불가 if _UtilLogic.ServerElapsedSeconds < self.lastSaveTime + cooldown then -- cooldown을 이용해 유저가 짧은 시간 동안 저장을 여러번 시도하는 것을 방지합니다. return end self.lastSaveTime = _UtilLogic.ServerEla

[source] | guide_examples [title] | 효과적으로 DataStorage 사용하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1073 [code] | Method: [server only] void OnBeginPlay() { local userDataStorage = _DataStorageService:GetUserDataStorage(userId) if userDataStorage == nil then return end local callBack = function() userDataStorage:SetAsync("DataKey2", "222", nil) -- 유저 재접속 전에 "222" 저장 보장 X

[source] | guide_examples [title] | 스크립트로 리메이크 월드 확장하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1098 [code] | local recoveryAmount = self.Entity.PlayerStatus.MPMax * 0.2 if recoveryAmount > (self.Entity.PlayerStatus.MPMax - self.Entity.PlayerStatus.MP) then recoveryAmount = self.Entity.PlayerStatus.MPMax - self.Entity.PlayerStatus.MP end -- 이펙트 재생 _EffectService:PlayEffectAttached("015d476c71a3403ca6b

[source] | guide_examples [title] | WorldConfig [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1101 [code] | Method: [client only] void NewFunction() { local targetEntity = nil for key, value in pairs(_UserService.UserEntities) do if key ~= _UserService.LocalPlayer.Name then targetEntity = value break end end if targetEntity ~= nil then targetEntity.PlayerCom

[source] | guide_examples [title] | WorldConfig [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1101 [code] | Method: [client only] void OnMapEnter(Entity enteredMap) { _TeleportService:TeleportToMapPosition(me, currentPosition + Vector3(0, 2, 0), currentMapName) }

[source] | guide_examples [title] | WorldConfig [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1101 [code] | [client only] void ShowChatBalloon() { local chatBalloon = self.Entity.ChatBalloonComponent chatBalloon.ChatModeEnabled = false chatBalloon.AutoShowEnabled = true chatBalloon.Message = "메이플스토리 월드" }

[source] | guide_examples [title] | 패킷 변조 대비하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1102 [code] | Method: [client only] void ClickGetRewardButton() { self:RewardProcess() } [server] void RewardProcess() { -- SendCoin() 함수를 호출하기 전, 반드시 올바른 요청이 맞는지 검증해야 합니다. self:SendCoin() } [server only] void SendCoin() { -- 실제 지급 로직 }

[source] | guide_examples [title] | 패킷 변조 대비하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1102 [code] | [server] void RequestDropItem(Entity targetItem) { if self:HasItemInInventory(targetItem) then return end }

[source] | guide_examples [title] | 패킷 변조 대비하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1102 [code] | [server] void RequestDropItem(Entity targetItem) { if senderUserId ~= self.Entity.PlayerComponent.UserId then return end if self:HasItemInInventory(targetItem) then self:RemoveItemInInventory(targetItem) end }

[source] | guide_examples [title] | 3. 인벤토리 데이터 저장 및 불러오기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1113 [code] | Property: [None] integer Meso = 10000 [None] table ItemStacks = {} Method: [server only] void OnBeginPlay() { -- 데이터 스토리지에서 인벤토리 데이터를 불러옴 local userId = self.Entity.PlayerComponent.UserId local userDataStorage = _DataStorageService:GetUserDataStorage(userId) local errorCode, loadD

[source] | guide_examples [title] | 4. 아이템을 인벤토리에 추가하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1114 [code] | Property: [None] integer Meso = 10000 [None] table ItemStacks = {} [None] integer Capacity = 16 Method: [server only] void OnBeginPlay() { -- 데이터 스토리지에서 인벤토리 데이터를 불러옴 local userId = self.Entity.PlayerComponent.UserId local userDataStorage = _DataStorageService:GetUserDataStorage(use

[source] | guide_examples [title] | 4. 아이템을 인벤토리에 추가하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1114 [code] | Property: integer SlotIndex = 0 string ItemId = "" integer ItemCount = 0

[source] | guide_examples [title] | 4. 아이템을 인벤토리에 추가하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1114 [code] | Property: integer SlotIndex = 0 string ItemId = "" integer ItemCount = 0

[source] | guide_examples [title] | 4. 아이템을 인벤토리에 추가하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1114 [code] | Property: integer SlotIndex = 0 string ItemId = ""

[source] | guide_examples [title] | 4. 아이템을 인벤토리에 추가하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1114 [code] | Property: integer Meso = 0

[source] | guide_examples [title] | TargetUserSync와 프로퍼티 동기화 최적화 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1119 [code] | Property: [Sync] integer meso = 0 Method: [server only] void IncreaseMeso() { self.meso += 1 }

[source] | guide_examples [title] | TargetUserSync와 프로퍼티 동기화 최적화 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1119 [code] | Property: [TargetUserSync] integer meso = 0 Method: [server only] void IncreaseMeso() { self.meso += 1 }

[source] | guide_examples [title] | 특정 월드 인스턴스로 워프하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1122 [code] | local result, pages = _WorldInstanceService:GetWorldInstanceInfoPagesAndWait() while true do --GetCurrentPageDatas()로 현재 페이지의 목록을 가져올 수 있습니다. local datas = pages:GetCurrentPageDatas() for _, data in pairs(datas) do log(data.Id) end --I

[source] | guide_examples [title] | 특정 월드 인스턴스로 워프하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1122 [code] | local callback = function (result, pages) while true do local datas = pages:GetCurrentPageDatas() for _, data in pairs(datas) do log(data.Id) end if pages.IsLastPage == true then break end pages:MoveToNextPageAndWait()

[source] | guide_examples [title] | 시작, 종료 구현하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1142 [code] | [client only] void CheckPosY () { if self.Entity.TransformComponent.Position.y < -15 then self:Die() end }

[source] | guide_examples [title] | 시작, 종료 구현하기 [page] | https://maplestoryworlds-creators.nexon.com/ko/docs?postId=1142 [code] | [client only] void Die() { if self.isDead then return end self.isDead = true -- 카메라 충돌 연출 추가 self.Entity.CameraComponent:ShakeCamera(1,0.2) wait(1) self.isDead = false self.Entity.CameraComponent.Position = Vector3.zero }

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