Adding lore to a cItem
#1
Game 
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
Reply
Thanks given by:
#2
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.
Reply
Thanks given by: MGlolenstine
#3
(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
Reply
Thanks given by:
#4
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.
Reply
Thanks given by:
#5
(delete the last argument to cItem's constructor. the error message is incorrect in saying the error is in argument 2)
Reply
Thanks given by:
#6
(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.
Reply
Thanks given by:
#7
I see. I suspect cItem's code is in need of overhaul :P
Reply
Thanks given by:




Users browsing this thread: 6 Guest(s)