CWO wrote: ↑Thu Jan 02, 2020 3:46 am
But for AddAmount(), you're already passing an item reference so you already have it and don't need a new one whereas with the Create* commands, the item didn't previously exist.
Thanks CWO for your answer! Let me introduce next situation.
Before I pass an item reference, I search it with function and add it to the variable:
Code: Select all
var existing_stack := FindObjtypeInContainer( container, objtype, FINDOBJTYPE_ROOT_ONLY );
After, I check it. If such kind of item exists in my pack, I add new one to it:
Code: Select all
var it;
if( existing_stack )
it := AddAmount( existing_stack, amount );
endif
And after, I want to return this variable "it" with it reference or return 0, if nothing was founded.
Code: Select all
if( it )
return it;
else
return 0;
endif
Yes, you are right, I don't need a new one item reference, I need only those, which I have already use, but from AddAmount().
Of course, I can use the "crutch" like:
Code: Select all
it := AddAmount( existing_stack, amount );
if( it )
it := existing_stack;
endif
But like you understand, that isn't right and looking good.