Hello,
since I "finished" the lua add-on. Im still writing some functions etc but its time to make a tutorial now.
The compiled server files with lua will be released soon.
What do you need?
You only need Lua experience.
no c++ or anything else is needed!
How do I write new functions for items?
Nothing easier than that.
Example:
role = unique char id.
XXXX <-- is the function ID from the item.
So you have to search in the item-list which I give you for "Use_Item_Tblidx" and there you'll have unique numbers (maybe some duplicate so they will share the same function)
then you just write
8001 = Use_Item_Tblidx from (id)18001 - (name)Senzu Beans
now we go forward and do this:
hp is now the current life.
now we add a easy check:
time to go further and do more checks
now the final:
g_test:SetCharaAttr(hp, role, ATTR_HP)
update the life from the player
now you finished writing a function which recovers 20 life points
Itemlist:
since I "finished" the lua add-on. Im still writing some functions etc but its time to make a tutorial now.
The compiled server files with lua will be released soon.
What do you need?
You only need Lua experience.
no c++ or anything else is needed!
How do I write new functions for items?
Nothing easier than that.
Example:
Code:
function ItemUse_XXXX ( role )
end
role = unique char id.
XXXX <-- is the function ID from the item.
So you have to search in the item-list which I give you for "Use_Item_Tblidx" and there you'll have unique numbers (maybe some duplicate so they will share the same function)
then you just write
Code:
function ItemUse_8001 ( role )
end
8001 = Use_Item_Tblidx from (id)18001 - (name)Senzu Beans
now we go forward and do this:
Code:
function ItemUse_8001 ( role )
local hp = [COLOR=#333333]g_test:[/COLOR]GetChaAttr(role, ATTR_HP)
end
hp is now the current life.
now we add a easy check:
Code:
function ItemUse_8001 ( role )
local hp = g_test:GetChaAttr(role, ATTR_HP)
if hp <= 0 then -- Check if char is dead
end
end
time to go further and do more checks
Code:
function ItemUse_8001 ( role ) local hp = g_test:GetChaAttr(role, ATTR_HP)
if hp <= 0 then -- Check if char is dead
end
hp_resume = 20 -- how many life to heal?
hp = hp + hp_resume
mxhp = g_test:GetChaAttr(role,ATTR_MXHP) -- get max life
if hp > mxhp then --Add check that player wont get more life than he has
hp = mxhp -- set life = max life
end
end
now the final:
Code:
function ItemUse_8001 ( role ) local hp = g_test:GetChaAttr(role, ATTR_HP)
if hp <= 0 then -- Check if char is dead
end
hp_resume = 20 -- how many life to heal?
hp = hp + hp_resume
mxhp = g_test:GetChaAttr(role,ATTR_MXHP) -- get max life
if hp > mxhp then --Add check that player wont get more life than he has
hp = mxhp
end
g_test:SetCharaAttr(hp, role, ATTR_HP)
end
g_test:SetCharaAttr(hp, role, ATTR_HP)
update the life from the player
now you finished writing a function which recovers 20 life points
Itemlist:
To view the content, you need to sign in or register
Last edited: