메뉴 건너뛰기

창작에 관련된 질문이나 간단한 팁, 예제를 올리는 곳

다운로드

https://github.com/lunarmodules/LDoc

 

penlight 설치가 필요

luarocks install penlight

 

프로젝트가 있는 폴더에서 아래의 명령행을 실행

lua /path/to/ldoc/ldoc.lua $*

 

https://stevedonovan.github.io/ldoc/manual/doc.md.html

 

문서 코멘트라는걸 작성하면 나중에 문서로 취합해줌

모든 문서 코멘트는 세 개의 하이픈(---)으로 시작

--- 예시 문서 코멘트

-- @tag 태그1

-- @tag 태그2

 

자주 사용하는 태그의 종류로는

@module - 모듈

@script - 루아 프로그램

@author, copyright, license, release - 프로젝트 레벨 태그들에 쓰이는 태그 (예: @module)

@function - 함수

@param - 파라미터 (여러개 가능)

@return - 함수의 리턴값 (여러개 가능)

@usage - 예제 사용법

@table - 루아 테이블

@fixme, todo, warning - 안내를 위한 주석

 

모듈에 적용

--- a test module

-- @module test

local test = {}

function test.my_module_function_1()

    ...

end

...

return test

 

함수에 적용

--- foo explodes text.

-- It is a specialized splitting operation on a string.

-- @param text the string

-- @return a table of substrings

function foo (text)

....

end

 

파라미터와 리턴값

-- @param name_of_parameter the description of this parameter as verbose text

-- @return the description of the return value

 

타입을 지정하고 싶을 경우 tparam, treturn 태그를 사용하면 됨

-- @tparam string text this parameter is named 'text' and has the fixed type 'string'

-- @treturn {string,...} a table of substrings

 
param과 return 태그는 여러개 쓸 수 있다.
--- solve a quadratic equation.
-- @param a first coeff
-- @param b second coeff
-- @param c third coeff
-- @return first root, or nil
-- @return second root, or imaginary root error
function solve (a,b,c)
    local disc = b^2 - 4*a*c
    if disc < 0 then
        return nil,"imaginary roots"
    else
       disc = math.sqrt(disc)
       return (-b + disc)/2*a,
              (-b - disc)/2*a
    end
end
 
...
 
todo, fixme 태그
--- Testing annotations
-- @module annot1
...
--- first function.
-- @todo check if this works!
function annot1.first ()
    if boo then
 
    end
    --- @fixme what about else?
end
 
todo, fixme 태그를 추출하기 위해서는 --tags 옵션을 사용
D:\dev\lua\LDoc\tests> ldoc --tags todo,fixme annot1.lua
d:\dev\lua\ldoc\tests\annot1.lua:14: first: todo check if this works!
d:\dev\lua\ldoc\tests\annot1.lua:19: first-fixme1: fixme what about else?
 
 
분류 :
조회 수 :
43241
등록일 :
2021.01.11
11:53:51 (*.47.15.90)
엮인글 :
게시글 주소 :
https://hondoom.com/zbxe/index.php?mid=study&document_srl=819158
List of Articles
번호 제목 글쓴이 조회 수sort 추천 수 날짜 최근 수정일
25 love.graphics.print 한국어 출력 노루발 432   2013-09-17 2013-09-17 08:24
Love2D 사용 시 한국어가 ㅁㅁㅁ이나 ??? 등으로 깨져 나와 해결책을 수소문하여 겨우 찾았다. 원래 중국어 등을 출력하기 위한 것이었으니 적절한 폰트를 쓴다면 한자나 히라가나등도 출력할 수 있을 것이다. function love.load() korfont = love.graphics....  
24 김프로 이미지 맵 만들기 노루발 393   2015-11-11 2015-11-11 08:05
https://docs.gimp.org/en/plug-in-imagemap.html  
23 Love2d 게임 중간에 광고 표시 [1] 노루발 378   2015-11-12 2015-11-17 00:16
http://love2d.org/forums/viewtopic.php?f=11&t=81224  
22 [Lua] Split 노루발 362   2013-09-17 2013-09-17 08:16
상황을 가정해보자. 웹 서버에 부탁해서 유희왕 덱의 리스트를 가져왔다. 원문은 대략 이렇다고 가정하자.   셰이프스내치x3 모린팬x3 트렌트x3 ...    보기엔 이렇지만 이걸 가져오면 아래와 같이 뜰 것이다. (웹 서버니까 HTML로 줌) 셰이프스내치x3<br>모...  
21 멘탈붕괴의 절정을 부르는 파일입출력 노루발 273   2013-09-17 2013-09-17 08:18
Love2D의 love.filesystem.load는 훼이크입니다. 파일을 로드하는 것 같지만 사실 lua 파일을 불러옴. love.filesystem.read도 그리 믿음직하지 못함. (고정 크기의 파일만 읽어옴) 우리가 믿을 수 있는 최후의 보루는 love.filesystem.lines 이었던 것입니다....  
20 love.update(dt) 에서 버벅이는 현상. 노루발 256   2013-09-17 2013-09-17 08:15
윈도우를 잡고 흔들거나 윈도우 사이로 잠시 전환하거나.. 등으로 원치 않는 렉이 발생할 시 dt의 값이 평소보다 크게 들어갑니다. (예를 들면, 평소에 0.25가 들어간다면 이번에는 3.1이 들어갑니다.) 이건 평소보다 더 많이 크기 때문에, dt를 가지고 타이...  
19 Love2d로 만든 로그라이크 예제 노루발 254   2020-11-30 2020-11-30 22:54
https://gitlab.com/Jalexander39/roguelikedev-does-the-complete-roguelike-tutorial 이걸 왜 여태 몰랐지...  
18 Love2d DPI 이슈 해결 [3] 노루발 98   2019-06-29 2019-07-01 06:34
이런 love 프로젝트가 있다고 하자. (conf.lua) function love.conf(t) t.window.width = 640 t.window.height = 360 end 창 크기를 640*480으로 설정한 뒤 실행하면 어떻게 보일까? 당연히 창 크기가 640*480 크기로 보여야겠지만 내 컴퓨터에서는 이렇게 보...  
17 Oracle cloud에 Nginx/MariaDB 설치하기 노루발 93   2020-12-06 2020-12-06 20:19
https://itreport.tistory.com/624  
16 Windows To Go와 R-Studio를 이용한 손실된 데이터 복구하기 노루발 90   2020-01-30 2020-01-30 19:52
하기의 복구 방법으로 모든 자료를 100% 복구할 수는 없으므로 자료의 손실 이전에 신뢰성 있고 주기적인 백업이 선행되어야 한다. 준비물: - 부팅 USB 혹은 외장 HDD/SSD - 복구한 자료를 저장할 외부 저장장치 (옵션) - R-Studio https://www.r-studio.com/ ...  
15 Lua 인수로 nil값이 들어왔을 경우 처리하기 노루발 69   2020-11-06 2020-11-06 20:29
or 연산자를 사용한다. 예제 코드: function moveplayer(direction) direction = direction or "nowhere" print("player moved to ".. direction) end moveplayer() --> "player moved to nowhere" moveplayer("north") -- "player moved to north" 이런 코드...  
14 특정좌표를 기준으로 zoom in/zoom out하기 노루발 59   2020-11-11 2020-11-11 01:22
-- x,y - 줌인/줌아웃시 기준점 (좌표 이동이나 scale에 영향받지 않는 순수한 화면 좌표) -- scale - 현재 scale(1:그대로 0.5:1/2 사이즈 2:2배 사이즈) -- scaleinc - 얼마나 scale을 변화시킬것인가 (I usually use 0.1 or -0.1) -- camx - 카메라의 x좌표...  
13 Love2d 게임 안드로이드로 패키징하기 노루발 49   2021-01-11 2021-02-21 01:45
http://hondoom.com/zbxe/index.php?mid=study&document_srl=797993 버전이 바뀌면서 빌드 방법이 바뀌었기에 다시 정리한다. 1. Android studio 설치 https://developer.android.com/studio/index.html SDK 플랫폼 - Android 11.0 [API 30] SDK 버전 - An...  
12 Love2d 이미지 하얗게 그리기 노루발 42   2020-11-23 2020-11-23 04:11
아래와 같은 코드를 사용해 이미지에 색상을 적용할 수 있다. hamster = love.graphics.newImage("hamster.png") love.graphics.setColor(1, 0, 0) -- 빨간색으로 그리기 love.graphics.draw(hamster) love.graphics.setColor(1, 1, 1) 하지만 이미지를 하얗게...  
11 이쁜 눈나가 유니티 개발 알려주는 재생목록 노루발 37   2020-11-12 2020-11-12 05:59
https://www.youtube.com/watch?v=Ur2jN6_si6c&list=PLi-ukGVOag_1lNphWV5S-xxWDe3XANpyE https://www.youtube.com/watch?v=sJClf9S7AMA&list=PLi-ukGVOag_0HR09oTs966Wt81IYYXlFH 유니티를 배우고 있는 건 아닌데 만들어진 라이브러리를 다루는게 아...  
10 루아 스타일 가이드 노루발 35   2020-11-19 2020-11-19 00:58
http://lua-users.org/wiki/LuaStyleGuide https://github.com/Olivine-Labs/lua-style-guide  
9 Lua 테이블 안에 함수 저장하기 노루발 28   2020-11-06 2020-11-06 21:07
테이블 안에 함수를 저장할 수 있다. function move(object, direction) print(object .. " moved to ".. direction) end scheduler = {} scheduler.queue = {} function scheduler.newentry(action, args) scheduler.queue[#scheduler.queue + 1] = {} schedu...  
8 Lua 클래스 만들고 활용하기 노루발 26   2020-11-06 2020-11-06 22:43
------------------------ stairs.lua ------------------------ Stairs = {} function Stairs:new(x, y, floor, direction, locked) local newStairs = {x = x, y = y, floor = floor, direction = direction, locked = locked} self.__index = self retur...  
7 Lua-love2d TCP 통신 [1] 노루발 25   2023-07-14 2023-07-22 16:19
서버: Lua 클라이언트: Love2d(Lua) 서버 구동에는 luasocket 라이브러리가 필요하며, luarocks로 설치할 수 있음. 별도 패키지 관리자가 있는 리눅스 시스템에서는 apt-get install lua-socket 등의 패키지 관리자 명령어로 설치 가능하며 Windows에서 구동시...  
6 illegal character 방지 [3] 노루발 22   2023-07-17 2023-07-19 16:14
문제점: 클라이언트 <-> 서버 통신을 하면서 다음과 같이 메세지를 주고받기로 함 패킷종류|파라미터1|파라미터2 예) MOTDREQ -> 서버에 MOTD를 요청 (파라미터 없음) MOTD|공지사항입니다 -> MOTD는 "공지사항입니다" 임 (파라미터 1개) MSG|김덕배|안녕하세...