-
Notifications
You must be signed in to change notification settings - Fork 0
Procedure
Artie Choi edited this page Apr 17, 2014
·
67 revisions
#Procedure
Procedure는 v3에서의 Item Conversion을 일반화한 개념으로, 서버에 스크립트를 등록하여, 필요한 경우 호출할 수 있다. Item Conversion은 condition과 changes로 구성됐는데, 조건과 필드 변경만 정의하여 제한된 형태였으나, v4에서는 Procedure정의를 Lua 스크립트로 사용하여 조건이나 반복, 산술연산, 임시 변수, 시스템 제공 함수 등을 사용할 수 있다.
##Procedure의 정의 Lua의 function 정의 형식을 따른다. REST Api에서 procedure를 호출할 때 Object형식의 parameter를 넘길 수 있기 때문에 parameter를 1개 가질 수 있다.
- Procedure 정의 Example:
function levelup_item(params)
local sword = ObjectMgr.load("weapon_sword", param.sword_id)
local ring = ObjectMgr.load("ring", param.ring_id)
if (sword and sword.level<sword.max_level and ring) then
-- ring 아이템은 삭제하고,
ObjectMgr.destroy(ring)
-- sword는 레벨 증가
sword.level = sword.level + 1
ObjectMgr.save(sword) -- sword의 속성이 변화됐으므로, 명시적으로 save를 해야 한다.
end
end##Hive5 Library
###ObjectManager ###TableManager ###Time
- before_load
- after_load
- before_save
- after_save
함수의 prototype은 다음과 같다.
function procedure_name(this)this 파라미터는 handler가 정의된 클래스의 Object가 넘겨진다.
POST procedures .. 링크를 ? 여기서?
##제한
math, string 만 가능
스택사이즈, 시간