Cuberite Forum
Adding lore to a cItem - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: Adding lore to a cItem (/thread-3191.html)



Adding lore to a cItem - MGlolenstine - 08-01-2018

Hi, 

So I've been trying to set a lore to the cItem via the constructor, but I get the error "argument #2 is 'number'; '[no object' expected]" for the second line




Code:
local weapons = cItem(E_ITEM_DIAMOND_SWORD, 1, 0                 , "thorns=0", "Weapons", {"Lore1", "Lore2})
local blocks = cItem(E_BLOCK_WOOL         , 1, E_META_WOOL_ORANGE, "thorns=0", "Blocks" , {"Lore1", "Lore2})
local armour = cItem(E_ITEM_DIAMOND_HELMET, 1, 0                 , "thorns=0", "Armour" , {"Lore1", "Lore2})
The API documentation is a bit lacking in this area, somewhere it says that lore is a string, elsewhere it says that it's a Table, and now I have no idea how to set  it correctly.

Can someone give me an example or explain to me why it isn't working?

Thanks in advance


RE: Adding lore to a cItem - NiLSPACE - 08-01-2018

Perhaps the Core's give.lua can give you some insights. You can use the same datatags as in vanilla to set the lore property.


RE: Adding lore to a cItem - MGlolenstine - 08-01-2018

(08-01-2018, 09:30 PM)NiLSPACE Wrote: Perhaps the Core's give.lua can give you some insights. You can use the same datatags as in vanilla to set the lore property.
So how does one set Vanilla property to cItem via code?

Giving it Vanilla lore part doesn't seem to do the trick...

Thanks


RE: Adding lore to a cItem - tigerw - 08-02-2018

I think I see the problem, the C++ code wants an array of strings but the auto-exported bindings doesn't seem to know how to translate that into Lua.

Meanwhile, you could try weapons.m_LoreTable = {"Lore1", "Lore2"}, that should work. Also, enchantments with level 0 won't show up on the client, I believe.


RE: Adding lore to a cItem - tigerw - 08-02-2018

(delete the last argument to cItem's constructor. the error message is incorrect in saying the error is in argument 2)


RE: Adding lore to a cItem - MGlolenstine - 08-03-2018

(08-02-2018, 11:10 PM)tigerw Wrote: I think I see the problem, the C++ code wants an array of strings but the auto-exported bindings doesn't seem to know how to translate that into Lua.

Meanwhile, you could try weapons.m_LoreTable = {"Lore1", "Lore2"}, that should work. Also, enchantments with level 0 won't show up on the client, I believe.

Thanks for your help, I got it working with your TIPBig Grin

You are correct, the enchantments of level 0 won't show up on the client, but I get an error if I put just an empty string there. Also I need to have that argument, so I can set the item's name.


RE: Adding lore to a cItem - tigerw - 08-03-2018

I see. I suspect cItem's code is in need of overhaul :P