Hi, Jones here from BPO.
In this post I will show you how to write a simple script and explain how it works.
There are 2 things in the script that I'm not sure of, so maybe someone can also confirm it to me.
function ItemUse_KylinChest ( role , Item )
local cha = TurnToCha ( role ) --// define [cha] as the character (?)
local cha_type = GetChaTypeID ( cha ) --// get the character's type (1 = Lance, 2 = Carsise, 3 = Phyllis, 4 = Ami) and put into definition as [cha_type]
local Item_CanGet = GetChaFreeBagGridNum ( role ) -- Define [Item_CanGet] as Free Grid space in Character's Inventory. (Free Slots)
if Item_CanGet <= 3 then -- If Free Slots in inventory EQUALS or LESS THAN 3, then
SystemNotice(role ,"Requires 4 slots in inventory to open the Kylin Chest!") -- Initiate a System Message
UseItemFailed ( role ) -- Fail to use the item.
return
end -- Close [if]
GiveItem ( cha , 0 , 825 , 1 , 0 ) -- Give Item to character, 0, 825 (Item ID), 1, 0
GiveItem ( cha , 0 , 826 , 1 , 0 ) -- Give Item to character, 0, 826 (Item ID), 1, 0
GiveItem ( cha , 0 , 827 , 1 , 0 ) -- Give Item to character, 0, 827 (Item ID), 1, 0
local cha_name = GetChaDefaultName ( role ) -- Define [cha_name] as Character's name, VALUE: [GetChaDefaultName ( role )]
local message = cha_name.." opens the the Kylin Chest and gets a Kylin Set!" -- Define [message] as the following message.
Notice ( message ) -- Do a world-announcement (Notice) for the message.
end -- Close the Function
You can put this script into ItemEffect.lua in scripts>calculate>itemeffect.lua
and make an item with XXXX id, then define the ItemUse_Function as ItemUse_KylinChest.
eg.
7694 Kylin Chest n1755 10130016 0 0 0 0 0 0 31 0 0 0 0 0 1 1 0 1 1 0 200 -1,-2,-2,-2 0 -1,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2 0 0 -1,-2,-2,-2,-2,-2,-2,-2,-2,-2 -1,-2,-2,-2,-2,-2,-2,-2,-2,-2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0,0 0 0,0 0,0 0 0 0 0 0 0 0 0 0 ItemUse_KylinChest 0 0 0 0,0 0 0 Click to obtain the Kylin Set! 0
7694 is the Item ID
Kylin Chest is the Name
n1755 is the Icon
After that, you can double click on the item and the function will play itself!