TFS 0.X Imbuements System to 0.4 (8.60)

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,098
Reaction score
2,173
Sorry was my fault.
Forgot that it isn't a standard function.
Add this into data/lib/100-shortcut
Lua:
function doSetItemSpecialDescription(uid, str)
    return doItemSetAttribute(uid, "description", str)
end
 
OP
runsicky

runsicky

Member
Joined
Apr 19, 2018
Messages
55
Reaction score
11
Sorry was my fault.
Forgot that it isn't a standard function.
Add this into data/lib/100-shortcut
Lua:
function doSetItemSpecialDescription(uid, str)
    return doItemSetAttribute(uid, "description", str)
end
I can feel the smell of imbuements system on 8.6 hahaha

Progress:
Code:
15:00 You see leather boots (Arm:3). It weighs 9.00 oz. swiftness,1560607165
How to show the mins on look?

Any idea why it is not adding speed? Not even printing a shit...
Code:
    <movevent type="Equip" event="script" value="movemment_imbuements.lua"/>
    <movevent type="DeEquip" event="script" value="movemment_imbuements.lua"/>
Code:
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

function onEquip(cid, item, slot)
   local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid
   -- bonus speed
   if getItemSpecialDescription(ibID, "swiftness") and getItemSpecialDescription(ibID, "swiftness")  > os.time() then
       if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
           doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
           setPlayerStorageValue(cid, feet_IB_storage, 1)
           print("XIKINI S2")
       end
   --elseif others
   end
   return true
end

function onDeEquip(cid, item, slot)
   if slot == CONST_SLOT_FEET then
       if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
          doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
          print("XIKINI -.-")
       end
   end
   return true
end
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,098
Reaction score
2,173
I can feel the smell of imbuements system on 8.6 hahaha

Progress:
Code:
15:00 You see leather boots (Arm:3). It weighs 9.00 oz. swiftness,1560607165
How to show the mins on look?

Any idea why it is not adding speed? Not even printing a shit...
Code:
    <movevent type="Equip" event="script" value="movemment_imbuements.lua"/>
    <movevent type="DeEquip" event="script" value="movemment_imbuements.lua"/>
Code:
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

function onEquip(cid, item, slot)
   local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid
   -- bonus speed
   if getItemSpecialDescription(ibID, "swiftness") and getItemSpecialDescription(ibID, "swiftness")  > os.time() then
       if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
           doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
           setPlayerStorageValue(cid, feet_IB_storage, 1)
           print("XIKINI S2")
       end
   --elseif others
   end
   return true
end

function onDeEquip(cid, item, slot)
   if slot == CONST_SLOT_FEET then
       if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
          doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
          print("XIKINI -.-")
       end
   end
   return true
end
----
Quoting myself from earlier in the thread.

--------------------------------------------- Quote start
#3, just set the item special description as
Lua:
"swiftness," .. (os.time() + however_many_seconds) .. ""
Then pull the information apart whenever you want to check stuff.
Lua:
local itemString = getItemSpecialDescription(item.uid)
local one, two = itemString:match("([^,]+),([^,]+)")
print(one)
print(two)
--------------------------------------------- Quote end

Code:
getItemSpecialDescription(ibID, "swiftness")
This function doesn't have a second parameter so using it like this will either not pass correctly or will simply fail to be useful.
You need to gather the information using this function, and then pull that information apart to check each of the sections individually.
You'd want to do it something like this, after pulling the information apart.
Lua:
if one == "swiftness" and two + 0 > os.time then
Since we already know that the information 'two' is a number, it's faster to use addition (+ 0) to convert the string into a number instead of using the lua function tonumber.

-- edited to construct my sentences more clearly.
 
Last edited:
OP
runsicky

runsicky

Member
Joined
Apr 19, 2018
Messages
55
Reaction score
11
----
Quoting myself from earlier in the thread.

--------------------------------------------- Quote start
#3, just set the item special description as
Lua:
"swiftness," .. (os.time() + however_many_seconds) .. ""
Then pull the information apart whenever you want to check stuff.
Lua:
local itemString = getItemSpecialDescription(item.uid)
local one, two = itemString:match("([^,]+),([^,]+)")
print(one)
print(two)
--------------------------------------------- Quote end

Code:
getItemSpecialDescription(ibID, "swiftness")
This function doesn't have a second parameter so using it like this will either not pass correctly or will simply fail to be useful.
You need to gather the information using this function, and then pull that information apart to check each of the sections individually.
You'd want to do it something like this, after pulling the information apart.
Lua:
if one == "swiftness" and two + 0 > os.time then
Since we already know that the information 'two' is a number, it's faster to use addition (+ 0) to convert the string into a number instead of using the lua function tonumber.

-- edited to construct my sentences more clearly.
lol man, thank you so much again
now even me could understand that

but it shouldnt print something when i equip a boots?

Code:
    <!-- imbuements -->
    <movevent type="Equip" event="script" value="movemment_imbuements.lua"/>
    <movevent type="DeEquip" event="script" value="movemment_imbuements.lua"/>
Code:
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

function onEquip(cid, item, slot)
   local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid

    local itemString = getItemSpecialDescription(item.uid)
    local one, two = itemString:match("([^,]+),([^,]+)")
    print(one)
    print(two)

   -- bonus speed
   if one == "swiftness" and two + 0 > os.time then
       if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
           doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
           setPlayerStorageValue(cid, feet_IB_storage, 1)
           print("XIKINI S2")
       end
   --elseif others
   end
   return true
end

function onDeEquip(cid, item, slot)
   if slot == CONST_SLOT_FEET then
       if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
          doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
          print("XIKINI -.-")
       end
   end
   return true
end
It always should print one and two, right?
Because it is not printing anything
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,098
Reaction score
2,173
lol man, thank you so much again
now even me could understand that

but it shouldnt print something when i equip a boots?

Code:
    <!-- imbuements -->
    <movevent type="Equip" event="script" value="movemment_imbuements.lua"/>
    <movevent type="DeEquip" event="script" value="movemment_imbuements.lua"/>
Code:
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

function onEquip(cid, item, slot)
   local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid

    local itemString = getItemSpecialDescription(item.uid)
    local one, two = itemString:match("([^,]+),([^,]+)")
    print(one)
    print(two)

   -- bonus speed
   if one == "swiftness" and two + 0 > os.time then
       if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
           doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
           setPlayerStorageValue(cid, feet_IB_storage, 1)
           print("XIKINI S2")
       end
   --elseif others
   end
   return true
end

function onDeEquip(cid, item, slot)
   if slot == CONST_SLOT_FEET then
       if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
          doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
          print("XIKINI -.-")
       end
   end
   return true
end
It always should print one and two, right?
Because it is not printing anything
One and two will only print if they aren't erroring.
If you add a 'print(1)' underneath the function, that will definitely print, if the script is working at all.
If '1' doesn't print, then the boots aren't registered in movements.xml properly, or the script errored.. Probably on start-up
 
OP
runsicky

runsicky

Member
Joined
Apr 19, 2018
Messages
55
Reaction score
11
One and two will only print if they aren't erroring.
If you add a 'print(1)' underneath the function, that will definitely print, if the script is working at all.
If '1' doesn't print, then the boots aren't registered in movements.xml properly, or the script errored.. Probably on start-up
I think the problem is on register item on movemments
Code:
    <movevent type="Equip" event="script" value="movemment_imbuements.lua"/>
    <movevent type="DeEquip" event="script" value="movemment_imbuements.lua"/>
Code:
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

function onEquip(cid, item, slot)
   print("player equip an item") 
   local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid

    local itemString = getItemSpecialDescription(item.uid)
    local one, two = itemString:match("([^,]+),([^,]+)")
    print(one)
    print(two)

   -- bonus speed
   if one == "swiftness" and two + 0 > os.time then
       if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
           doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
           setPlayerStorageValue(cid, feet_IB_storage, 1)
           print("XIKINI S2")
       end
   --elseif others
   end
   return true
end

function onDeEquip(cid, item, slot)
   if slot == CONST_SLOT_FEET then
       if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
          doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
          print("XIKINI -.-")
       end
   end
   return true
end
don't print "player equip an item" or anything...
there is other way to declare all items in movemment?
i can't declare one by one, cause others items have others attributes, vocation options...
 

Xikini

I whore myself out for likes
Premium User
Joined
Nov 17, 2010
Messages
4,098
Reaction score
2,173
I think the problem is on register item on movemments
Code:
    <movevent type="Equip" event="script" value="movemment_imbuements.lua"/>
    <movevent type="DeEquip" event="script" value="movemment_imbuements.lua"/>
Code:
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

function onEquip(cid, item, slot)
   print("player equip an item")
   local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid

    local itemString = getItemSpecialDescription(item.uid)
    local one, two = itemString:match("([^,]+),([^,]+)")
    print(one)
    print(two)

   -- bonus speed
   if one == "swiftness" and two + 0 > os.time then
       if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
           doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
           setPlayerStorageValue(cid, feet_IB_storage, 1)
           print("XIKINI S2")
       end
   --elseif others
   end
   return true
end

function onDeEquip(cid, item, slot)
   if slot == CONST_SLOT_FEET then
       if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
          doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
          print("XIKINI -.-")
       end
   end
   return true
end
don't print "player equip an item" or anything...
there is other way to declare all items in movemment?
i can't declare one by one, cause others items have others attributes, vocation options...
Someone can correct me if I'm wrong, but I think it's on a per itemid basis. There isn't a way to do all items in 1 line in XML.

You'll basically need to incorporate those other items into one script
 
OP
runsicky

runsicky

Member
Joined
Apr 19, 2018
Messages
55
Reaction score
11
what are u mean?
i'll have to define one by one like this:
Code:
    <movevent type="Equip" itemid="2645" slot="feet" event="script" value="movemment_imbuements.lua">
        <vocation id="4"/>
        <vocation id="8" showInDescription="0"/>
        <vocation id="12" showInDescription="0"/>
    </movevent>
    <movevent type="DeEquip" itemid="2645" slot="feet" event="script" value="movemment_imbuements.lua"/>
It would not broke the defaul atributes, right?
I mean <attribute key="speed" value="40" />
from boh
Code:
    <item id="2195" name="boots of haste">
        <attribute key="weight" value="750" />
        <attribute key="slotType" value="feet" />
        <attribute key="speed" value="40" />
        <attribute key="showattributes" value="1" />
        <attribute key="armor" value="1" />
    </item>
---

Code:
local feet_IB_storage = 700
local legs_IB_storage = 701
local armour_IB_storage = 702
local head_IB_storage = 703
local boots_IB_storage = 704
local atkweapon_IB_storage = 705
local defweapon_IB_storage = 706

function onEquip(cid, item, slot)
   print("player equip an item") 
   local ibID = getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid

    local itemString = getItemSpecialDescription(item.uid)
    local one, two = itemString:match("([^,]+),([^,]+)")
    print(one)
    print(two)

   -- bonus speed
   if one == "swiftness" and two + 0 > os.time then
       if getPlayerStorageValue(cid, feet_IB_storage) < 1 then
           doChangeSpeed(cid, getCreatureSpeed(cid) + 500)
           setPlayerStorageValue(cid, feet_IB_storage, 1)
           print("XIKINI S2")
       end
   --elseif others
   end
   return true
end

function onDeEquip(cid, item, slot)
   if slot == CONST_SLOT_FEET then
       if getPlayerStorageValue(cid, feet_IB_storage) > 0 then
          doChangeSpeed(cid, getCreatureSpeed(cid) - 500)
          print("XIKINI -.-")
       end
   end
   return true
end
Is giving error:
Code:
player equip an item
swiftness
1561206837

[11:49:42.487] [Error - MoveEvents Interface] 
[11:49:42.487] data/movements/scripts/movemment_imbuements.lua:onEquip
[11:49:42.487] Description: 
[11:49:42.487] data/movements/scripts/movemment_imbuements.lua:19: attempt to compare function with number
[11:49:42.487] stack traceback:
[11:49:42.487]     data/movements/scripts/movemment_imbuements.lua:19: in function <data/movements/scripts/movemment_imbuements.lua:9>
 
Top