Udun
Well-Known Member
- Joined
- Jan 5, 2012
- Messages
- 193
- Solutions
- 1
- Reaction score
- 67
Hello guys I'm trying to implement a crafting system based on mill and decay items.
TFS 1.2
I was looking on the forum if there was a post with the same problem but I didn't find anything.
I'm getting some problems:
When the item is generated via map editor the decay works fine but when is generated by code it doesn't work.
I was looking that I need "activate" the decay when the item is generated via code but I don't know how to do it right. I did some test with some functions of other posts but with no success. Probably is an easy fix.
My mill code:
The item on items.xml
Thanks in advance!
TFS 1.2
I was looking on the forum if there was a post with the same problem but I didn't find anything.
I'm getting some problems:
When the item is generated via map editor the decay works fine but when is generated by code it doesn't work.
I was looking that I need "activate" the decay when the item is generated via code but I don't know how to do it right. I did some test with some functions of other posts but with no success. Probably is an easy fix.
My mill code:
Lua:
local liquidContainers = {1775, 2005, 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015, 2023, 2031, 2032, 2033}
local millstones = {28369}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemId = item:getId()
if itemId == 28395 then --tin dust
if target.type == 1 and isInArray(liquidContainers, target.itemid) then
item:remove(1)
player:addItem(28395, 1)
target:transform(target.itemid, 0)
return true
end
elseif isInArray(millstones, target.itemid) then
item:remove(1)
player:addItem(28395, 1)
return true
end
return false
end
The item on items.xml
XML:
<item id="28395" article="a" name="tin dust">
<attribute key="weight" value="400" />
<attribute key="decayTo" value="28398" />
<attribute key="duration" value="2" />
</item>
Thanks in advance!