• 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!

TFS 1.X+ Delete description of an item, partially

Ramirow

Veteran OT User
Joined
Aug 22, 2009
Messages
584
Solutions
15
Reaction score
301
Location
Argentina
YouTube
ramirogrant
I don't know if this is possible or how it's done on Lua syntax. I have some items with this descriptions, added after item creation. Example:
Code:
You see a sword. Created by PlayerName. [HP+15]
Is there a way to only remove the brackets part, right now if I erase ITEM_ATTRIBUTE_DESCRIPTION it deletes all description.

Thanks!
 
Solution
You should post the code bruh, but here's how you should do it, I guess you can figure out the rest
Lua:
str = "You see a sword. Created by PlayerName. [HP+15]" --this should be item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)

str = str:gsub('%b[]', '')

print(str) --this should be item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, str)
You should post the code bruh, but here's how you should do it, I guess you can figure out the rest
Lua:
str = "You see a sword. Created by PlayerName. [HP+15]" --this should be item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)

str = str:gsub('%b[]', '')

print(str) --this should be item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, str)
 
Solution
You should post the code bruh, but here's how you should do it, I guess you can figure out the rest
Lua:
str = "You see a sword. Created by PlayerName. [HP+15]" --this should be item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)

str = str:gsub('%b[]', '')

print(str) --this should be item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, str)

I will try this out once I get home, just to know, what does %b means? I guess it's some kind of string operation, but I can't get my head around it just by looking at it
 
Another item in a pattern is the '%b', that matches balanced strings. Such item is written as '%bxy', where x and y are any two distinct characters; the x acts as an opening character and the y as the closing one. For instance, the pattern '%b()' matches parts of the string that start with a `(´ and finish at the respective `)´:

print(string.gsub("a (enclosed (in) parentheses) line",
"%b()", ""))
--> a line

Typically, this pattern is used as '%b()', '%b[]', '%b%{%}', or '%b<>', but you can use any characters as delimiters.
Programming in Lua : 20.2
TL;DR: %b[] will match the part of the string that starts with '[' and ends with ']'.
 
Just remove the brackets from the part egere it sets a description.
Or post the script if you're not sure.
 
Just remove the brackets from the part egere it sets a description.
Or post the script if you're not sure.

I will post them later, the item receives different descriptions, when crafted trough an Smithing skill, it creates the "Created by "..player:getName().. "."
After that, those effects in brackets are added trough an Enchanting skill.
I made it so that players could remove different options as an item can contain two boosts, for example, [Ml. +1] [Regen HP +5]
The removing part is already done, but I needed a way to check the string so it doesn't remove the Created By part.
 
Back
Top