[changed] cItem constructor - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Plugins (https://forum.cuberite.org/forum-1.html) +--- Forum: Plugin Discussion (https://forum.cuberite.org/forum-8.html) +--- Thread: [changed] cItem constructor (/thread-1150.html) |
[changed] cItem constructor - xoft - 06-01-2013 I'd like to change the API a bit. Currently, if a plugin does local Item = cItem(E_ITEM_STICK);the Item is actually empty, because the cItem constructor has a second parameter, "Count", that defaults to 0. I'd like to make two constructors, one with no parameters, and a second with at least one parameter (C++ code): /// Constructs an empty cItem object: cItem(void); /// Constructs the specified item, by default 1 piece: cItem(short a_ItemType, char a_ItemCount = 1, short a_ItemDamage = 0); This would allow us to use the following in the plugins: local EmptyItem = cItem(); -- Calls the first constructor local OneStick = cItem(E_ITEM_STICK); -- Calls the second constructor local TwoSticks = cItem(E_ITEM_STICK, 2); -- Calls the second constructor local ThreeRedWool = cItem(E_BLOCK_WOOL, 3, E_META_WOOL_RED); -- Calls the second constructor The only problem is that this change *could* break code that depends on the (bad) behavior, that items created without a specified count are created empty. I quite doubt there is any such code, but who knows. What do you think, should I change the API? RE: cItem constructor - FakeTruth - 06-01-2013 Yeah, change it RE: cItem constructor - xoft - 06-01-2013 Changed in rev 1536 RE: cItem constructor - bearbin - 06-01-2013 Seems a good change |