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

[Suggestion] Lua-Generated Item Descriptions

GOOD?


  • Total voters
    33

Infernum

Senator
Joined
Feb 14, 2015
Messages
5,643
Solutions
559
Reaction score
3,948
Code: infernumx/forgottenserver (https://github.com/infernumx/forgottenserver/compare/master...infernumx:lua-item-desc)

There's still some room for improvement. I'm thinking about combining the "hasX" functions into one that returns the table with all the item type "flags" on it (boolean flags), would probably make it cleaner in the source code.

I tried to test a large chunk of items and compare them to the original description generated from Item::getDescription, I've found no discrepancies thus far between the two, it should perfectly mimic the exact same description you get from the original.

Obviously, I'll have to alter more of the code to make it like the original (support ItemType descriptions and utilize the Lua-generated description in playerOnLookInShop).

Pros:
  • Flexible for new custom attributes
  • Ability to easily alter the structure, order & layout of the text
  • Shorter code (I combined the generic attributes/abilities that were added on weapons/armor into 1 function, in C++ you had to manually edit both to add a new attribute to parse)
Cons:
  • Anybody who's added new attributes in Item::getDescription will have to re-do it (maybe make it configurable?)

What do you guys think?
 
Last edited:
Really great job :), these days having a upgrade system(or other system that influences items) is like the standard for every OT. it makes no sense to mess with item descriptions to check if item has x description to get y condition...

These days we should have these functions by default in tfs. Even if it is just the sake of expanding the possibilities of features we can provide as game developers...

No need for the poll if you ask me!

Just out of curiousity how much slower is it? and why (i'm trying to learn more about performance efficienty)? sounds more logical that it is faster as it saves a lot of string manipulations/calculations? Or just thrown some benchmarks?

Might implement some day when i have the time, it will make my codes much cleaner XD.

Animera
 
Nice release. I watched you write this code, I was thinking if you would release the code, as Animera said, with this, the upgrade systems will be much more cleaner. Thanks for sharing, your job here in Otland is great!
 
Really great job :), these days having a upgrade system(or other system that influences items) is like the standard for every OT. it makes no sense to mess with item descriptions to check if item has x description to get y condition...

These days we should have these functions by default in tfs. Even if it is just the sake of expanding the possibilities of features we can provide as game developers...

No need for the poll if you ask me!

Just out of curiousity how much slower is it? and why (i'm trying to learn more about performance efficienty)? sounds more logical that it is faster as it saves a lot of string manipulations/calculations? Or just thrown some benchmarks?

Might implement some day when i have the time, it will make my codes much cleaner XD.

Animera
It's more just basic experience being able to tell that this would be slightly slower. For example, I wrote a my own "StringStream" to make it easier to add strings to the description & build it, which is basically just a mask for string.format. Real string streams in C++ are faster and each value is manually concatenated rather than formatted using specifiers. I don't have a percentage for how much faster/slower it would be, like I said it's just that I can pretty much tell when something will be slightly more costly in terms of performance.

Nice release. I watched you write this code, I was thinking if you would release the code, as Animera said, with this, the upgrade systems will be much more cleaner. Thanks for sharing, your job here in Otland is great!
Yeah, most of it was written that day (took me 8 hours), the rest of this time I was just lazy to clean up, but eventually I did and made this thread.
 
if you manage to push needed getters into official tfs repo, I can help you doing the lua part
 
I think if we are able to move things to lua without huge hacks its always a improvement in the sense that its easier to read, fix, improve and most important customize the items descriptions. The only reason to keep it at engine/c++ was the easiness to read the item properties but then its not a excuse since the lua interface should have everything.
 
Added support for ItemType descriptions, removed the default support for onLookInShop and replaced it with the Lua-written description. The entirety of this should be finished, other than cleaning up some leftover unused C++ functions in favor of Lua, or maybe making it configurable and cleaning it up somehow to make it fitting for a PR.

Would be greatly appreciated if people could test this as well with me, I'm very skeptical that I made perfect code cause that almost never happens, I'm sure there has to be some item that has some error in formatting. All you gotta do is download the branch & compile and just look at a shit ton of different types of items to see if the description is screwed up or not.
 
Wrote a code snippet to parse every single item in items.xml and compare original + Lua-generated descriptions, every single item in the game is a confirmed match regardless of lookDistance. Updated the repo with the fixes.
 
Wrote a code snippet to parse every single item in items.xml and compare original + Lua-generated descriptions, every single item in the game is a confirmed match regardless of lookDistance. Updated the repo with the fixes.

You happy enough with it to submit PR?
 
My problem is packaging it in a way that fits TFS currently for the current lib system.
 
would be cool to use item sprites like outfits so you can make 10 different weapons that looks like spike sword with different attributes just like you can make 10000 monsters with the same face.
 
would be cool to use item sprites like outfits so you can make 10 different weapons that looks like spike sword with different attributes just like you can make 10000 monsters with the same face.
As long as they obey dat structure, it should be possible to do.
 
yea. I mean.. you have items.xml right like normal, but then there could be a folder just like Monsters and you could make a lua for each weapon OR just have one additional .lua inside weapons folder and ypu can just add all normal stats a weapon has, like weight, attack, bonus defences, name and of course which weapon it should look like.
 
I opened an issue on github regarding that.
We might see something like that in distant future because it's a lot to rework and there are other big reworks going on already.
 
Back
Top