Not sure if this is a "I don't understand Javascript enough" problem or a "I don't fully understand how MZ handles these things" problem. I'm wanting to copy a database object, then have the new object have absolutely no connection to the original object, so that changes to the copy aren't made to the original as well(this kind of thing is both a blessing and a curse compared to VisualBasic. I'm so used to a different kind of programming language).
Basically I'm attempting to make unique versions of database equipment on the fly, and each item in the database is the base that I'm starting with.
I THOUGHT I had succeeded using
and afterward changing the id and pushing the new version to the $dataWeapons object(quick and dirty, probably, but I'm trying to get the thing running first), I was able to modify the name and have unique entries in the item screen and everything. Then I tried to modify the new item's stats, specifically params for the first test. Apparently there is still some connection SOMEWHERE to the original database object the new one spawned from, because any change to param on the new item is made to the original as well, and thus any copy made from that base afterward, causing ALL versions, base and new, to have the same params.
I know that pretty much any identifier on an item refers to the $data object, which is why I changed the copy's id and pushed the new version. But the only identifiers I can find on the object that seem to point to it's $data is the id, as well as the existence of wtypeId or atypeId to identify it as a weapon or armor. For reference, this copy is spawned from the item object in the Game_Party gainItem command. And up to this point, my changes seemed to have made the copy a completely independent item. So... what am I missing?
Thanks in advance!
Basically I'm attempting to make unique versions of database equipment on the fly, and each item in the database is the base that I'm starting with.
I THOUGHT I had succeeded using
JavaScript:
newItem = Object.assign({}, item)
I know that pretty much any identifier on an item refers to the $data object, which is why I changed the copy's id and pushed the new version. But the only identifiers I can find on the object that seem to point to it's $data is the id, as well as the existence of wtypeId or atypeId to identify it as a weapon or armor. For reference, this copy is spawned from the item object in the Game_Party gainItem command. And up to this point, my changes seemed to have made the copy a completely independent item. So... what am I missing?
Thanks in advance!