[changed] cItem constructor
#1
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?
Reply
Thanks given by:
#2
Yeah, change it
Reply
Thanks given by:
#3
Changed in rev 1536
Reply
Thanks given by:
#4
Seems a good change Smile
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)