반응형
-- 시간 설정
function setClock()
return os.clock()
end
-- 경과 시간
function getClock(clock)
return os.clock() - clock
end
-- XX연타
GO_CYCLE_TIME = 3 -- 이동키 연타를 할 사이클 설정 (단위:초)
if xx == nil then
xx = setClock()
elseif getClock(xx) > GO_CYCLE_TIME then
Keybd('<X_Release>')
Keybd('<X_Press>')
print('이동! GoGoGo! <X_Release> <X_Press>')
xx = nil
end
-- 스킬 사용
SKILL_CYCLE_TIME = 2 -- 스킬 사용후 다음 스킬 사용할 시간 설정 (단위:초)
SKILL_REST_TIME = 5 -- 스킬 모두 사용후 재시작 대시기산 (단위:초)
skill_table = {'<A>', '<S>', '<D>', '<F>'} -- 추가할 버튼 있으면 , 로 구분하고 '<누를키>' 로 추가하세요
if (skill_idx == nil) or (skill_idx == 0) or (skill_idx > #skill_table) then
if skill_start == nil then
skill_start = setClock()
elseif getClock(skill_start) > SKILL_REST_TIME then
skill_idx = 1
end
end
if skill_clock == nil then
skill_clock = setClock()
elseif getClock(skill_clock) > SKILL_CYCLE_TIME then
print(string.format('스킬을 사용합니다. %s', skill_table[skill_idx]))
Keybd(skill_table[skill_idx])
skill_idx = skill_idx + 1
skill_clock = nil
end
반응형
'코드보관소 > lua' 카테고리의 다른 글
[lua] 함수를 실행하는 함수 (0) | 2022.03.22 |
---|---|
[lua] string replace (0) | 2022.03.18 |
[lua] file (0) | 2021.07.13 |
[lua] hello, world! (0) | 2021.07.12 |