Giter Site home page Giter Site logo

neko.lua's Introduction

Neko.lua 🐱

Neko.lua는 네코랜드의 스크립팅을 도와주는 Lua 라이브러리 입니다.

  • 네코랜드에서 고급기능을 구현하려면, 대부분 여러개 메소드와 콜백함수를 엮어서 만들어야 했습니다.
  • 이쁘고 멋진 UI를 만드려면 클라이언트 스크립트가 굉장히 더러워졌습니다.
  • 네코랜드 개발환경에 조금이라도 도움이 될까 생각하여 조금씩 만들게 되었습니다.
  • 현재 테스트 버전입니다.

구현된 함수들 💬


Server Scripts

  • callbacks
    • callbacks.onEquipItem:Add() - 아이템 장착 콜백
    • callbacks.offEquipItem:Add() - 아이템 장착 해제 콜백

Client Scripts

  • Control
    • panel:new{}
    • button:new{}
    • text:new{}

사용방법 💬


  • Scripts폴더와 ServerScripts폴더의 스크립트 파일들을 다운로드 받으셔서 파일이 폴더의 가장 위로 정렬되게 해주세요.

  • Neko.lua는 전역 메소드입니다. 일반적인 모듈과 다르게 require 를 지원하지 않습니다.

  • 전역으로 정의된 메소드들은 변수할당, 함수명으로 사용을 할 수 없습니다.


  • Control : 클라이언트 UI를 생성해주는 클래스입니다.

    • 멤버함수 new{}로 선언과 동시에 모든 프로퍼티에 대한 pre-set을 지정할수 있으며, 인스턴스를 반환합니다.

    • set함수 사용시 Control 하위 객체들의 pre-set 지정시 키 값을 명시해야합니다.

    • 모든 프로퍼티에 대한 set 함수가 존재합니다.

      local mainPanel = panel:new {} -- 프로퍼티를 명시하지 않으면 panel객체에 정의된 기본값으로 객체가 생성됩니다.
      
      local subPanel = 
        panel:new {
        width = 100, --프로퍼티는 키값을 직접 명시해야 합니다.
        height = 100,
        anchor = 0,
        pivotX = 0.5
        color = Color(0,0,0,150) 
        parent = mainPanel, -- 선언과 동시에 부모 객체를 연결할 수 있습니다.
      }
      print(subPanel:width()) -- 현재 subPanel의 width의 크기를 가져옴
      subPanel:width(200) -- subPanel의 가로크기를 200으로 설정
      
      local myBtn = 
        button:new {
        text = "닫기버튼", 
        onClick = function()  --`button` 객체의 `onClick` 이벤트 또한 함수로 첨부하여 이벤트 리스너를 생성할 수 있습니다.
          print("클릭하였습니다.") 
        end,
        parent = subPanel
      }:width(100):height(30):anchor(4) -- 프로퍼티 set/get함수는 self를 반환하기 때문에 다음과 같이 이어붙여 사용 가능합니다.
  • callbacks.onEquipItem, callbacks.offEquipItem : 아이템을 장착하고 벗을때 호출되는 이벤트입니다.

    • 호출될 함수의 인자 형식 : function(ScriptUnit unit, Titem item, number slot)

      [1] unit : 이벤트가 일어난 유닛 객체(userdata)

      [2] item : 장착 or 해제한 아이템 객체(userdata)

      [3] slot : 장착 or 해제한 아이템이 있던 캐릭터 슬롯 번호(number)

      --호출될 함수의 인자형식
      function myCallback(unit,item,slot)
        print(unit,item,slot)
      end
      callbacks.onEquipItem:Add(myCallback) -- 아이템을 장착했을 때 호출되는 이벤트를 설정합니다.
      
      --아이템을 장착 해제했을 때 호출되는 이벤트를 설정합니다.
      callbacks.offEquipItem:Add(
         function(unit, item, slot)
             print("아이템 해제 : ", unit, item, "슬롯 번호 : " .. slot, "아이템 id : " .. item.id)
         end
      )
  • RunLater : 일정 시간 후에, 정해진 함수를 실행합니다.

    • Syntax
    RunLater{
     Closure callback,
     time = number,
     parameter...
    }
    • 예제
    function foo(a,b,c)
      print(a,b,c)
    end
    RunLater{foo,1,2,3,time = 2} --2초뒤 foo함수 실행

개발자 👾


스피겔(Speigel)

Discord : SOS#1461

라이센스 ⚖️


MIT LICENSE Copyright (c) 2021 스피겔(Spiegel)

neko.lua's People

Contributors

vin-spiegel avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.