• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua "Imbuing system" Adding attributes to items by slot

Tampek

ECHO 'Zarkonia.online';
Joined
Dec 29, 2015
Messages
478
Solutions
5
Reaction score
33
Location
Spain
Hello im working with a modal windows + slot system + crafting to build one fuction like imuing system from cip, i have otb from the new version and items so just with all otland i think we can finish this script and split for all members.

56d2a5ab4a891e3e6e6ba03664f68e33.jpg


Scripts used for here:
Action - [TFS 1.1] - Slot system
[TFS 1.2] Simple Crafting System.
Action - [TFS 1.1] Item's upgrading by jewels

Only we need working to add time + new attributes to the items crafted.

Code:
local conf = {
maxSlotCount=1,
ignoredIds={}
}
function choose(...)
  local arg = {...}
  return arg[math.random(1,#arg)]
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
  if item.uid == 0 or item.itemid == 0 then return false end
  toPosition.stackpos = 255
  if isInArray(conf.ignoredIds, itemEx.itemid) or
  isItemStackable(itemEx.uid) or
  itemEx.itemid == 0 or
  itemEx.type > 1 or
  not(isArmor(itemEx.uid) or isWeapon(itemEx.uid) or isShield(itemEx.uid)) then
  return false
  end
  if isCreature(itemEx.uid) then
  return false
  end
  local nam = Item(itemEx.uid):getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
  function getper()
  local n = 1
  for i=1,10 do
  n = n+math.random(0,10)
  if n < 8*i then
  break
  end
  end
  return n
  end
  function getSlotCount(nam)
  local c = 0
  for _ in nam:gmatch('%[(.-)%]') do
  c = c+1
  end
  return c
  end
  if getSlotCount(nam) < conf.maxSlotCount then
  local l = choose('Mana leach','Mana Steal','Life Steal','Life Leach','Critical Chance','dist')
  local p = getper()
  doSendMagicEffect(toPosition,30)
  nam = nam..' ['..l..'.+'..p..'%]'
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,l..'.+'..p..'%')
  doSetItemSpecialDescription(itemEx.uid, nam)
  else
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Slot limit reached.")
  end
  return true
end

Code:
function getItemAttribute(uid, key)
   local i = ItemType(Item(uid):getId())
   local string_attributes = {
     [ITEM_ATTRIBUTE_NAME] = i:getName(),
     [ITEM_ATTRIBUTE_ARTICLE] = i:getArticle(),
     [ITEM_ATTRIBUTE_PLURALNAME] = i:getPluralName(),
     ["name"] = i:getName(),
     ["article"] = i:getArticle(),
     ["pluralname"] = i:getPluralName()
   }
   local numeric_attributes = {
     [ITEM_ATTRIBUTE_WEIGHT] = i:getWeight(),
     [ITEM_ATTRIBUTE_ATTACK] = i:getcriticaldamage(),
     [ITEM_ATTRIBUTE_DEFENSE] = i:getDefense(),
     [ITEM_ATTRIBUTE_EXTRADEFENSE] = i:getExtraDefense(),
     [ITEM_ATTRIBUTE_ARMOR] = i:getArmor(),
     [ITEM_ATTRIBUTE_HITCHANCE] = i:getHitChance(),
     [ITEM_ATTRIBUTE_SHOOTRANGE] = i:getShootRange(),
     ["weight"] = i:getWeight(),
     ["attack"] = i:getAttack(),
     ["defense"] = i:getDefense(),
     ["extradefense"] = i:getExtraDefense(),
     ["armor"] = i:getArmor(),
     ["hitchance"] = i:getHitChance(),
     ["shootrange"] = i:getShootRange()
   }
  
   local attr = Item(uid):getAttribute(key)
   if tonumber(attr) then
     if numeric_attributes[key] then
       return attr ~= 0 and attr or numeric_attributes[key]
     end
   else
     if string_attributes[key] then
       if attr == "" then
         return string_attributes[key]
       end
     end
   end
return attr
end
function doItemSetAttribute(uid, key, value)
   return Item(uid):setAttribute(key, value)
end
function doItemEraseAttribute(uid, key)
   return Item(uid):removeAttribute(key)
end
 
Last edited:
I don't think "Support" is not the right place for your post as you really didn't post anything but an image and 3 links. Maybe Jobs is what you're looking for.
 
but the atributes from item.xml can used with lua no? we can build new one script with this fuctions or... need 100% edit sources? i think no ehh

tem:getAttribute(key)
:/
 
Back
Top