• 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 TFS 1.0 itemAttribute

eduardbean

Member
Joined
Nov 26, 2010
Messages
129
Solutions
2
Reaction score
16
Why thats dont work in TFS 1.0

doItemSetAttribute(item, "name", "Fire Devil")

How i can make it work ?

Anyone can help me ?​
 
I don't have a 100% certain answer, but I've been looking at this kind of thing the last couple of days. It looks like the capability you need has been implemented as a method on "item".

Functions:
http://otland.net/threads/tfs-1-0-lua-functions.197202/

Methods on objects:
http://pastebin.com/pYWXTGBc

item has:
item:setAttribute(key, value)

If I'm right,
Code:
doItemSetAttribute(item, "name", "Fire Devil")
has become
Code:
item:setAttribute("name", "Fire Devil")

FWIW this is the standard OO approach to setting object properties. The old version, with a global function to set an object instance property looks a bit strange to me. It increases the number of global functions a lot - extra complexity with no corresponding benefit.

TFS 1.0 has a script called compat.lua which is run on startup by global.lua.
There are a bunch of small scripts in there that are called with the old function signature and use the new one to get the job done.

I didn't find doItemSetAttribute() there, but if you have a huge number of calls to it you could add one yourself. Here's an example from compat.lua for doSetItemText() you could use as a template:
Code:
function doSetItemText(uid, text)
   local item = Item(uid)
   if item == nil then
     return false
   end

   if text ~= "" then
     item:setAttribute(ITEM_ATTRIBUTE_TEXT, text)
   else
     item:removeAttribute(ITEM_ATTRIBUTE_TEXT)
   end
   return true
end
 
Last edited:
Back
Top