Object = Object

So I want an object in an array to equal the same values as another object.

Ex:

object1.a = 1object1.b = 3object1.c = 5object2.a = 2object2.b = 4object2.c = 6# Lets make them the same, but not in addressobject1.a = object2.aobject1.b = object2.bobject1.c = object2.c# Now...object1.a = 2object1.b = 4object1.c = 6Is there a way to say Object1 = Object2 without making it think I'm pointing, or in otherwords a short way of above in the code example.
Use .dup or .clone

Code:
object1.a = object2.a.dup
Use .dup or .clone

object1.a = object2.a.dup
For some reason when I do that I can't add weapons to my inventory afterward.. :/

Code:
$game_party.lose_item($data_weapons[1], 1) # Does Work$game_party.gain_item($data_weapons[2], 1) # Does Work#   ...$data_weapons[2] = $data_weapons[1].clone#   ...$game_party.lose_item($data_weapons[1], 1) # Does Work?$game_party.gain_item($data_weapons[2], 1) # Doesn't Work
For some reason when I do that I can't add weapons to my inventory afterward.. :/

$game_party.gain_item($data_weapons[te], 1) # Does Work$data_weapons[te] = $data_weapons[e].clone$game_party.gain_item($data_weapons[te], 1) # Doesn't Work
What do you use it for actually?
What do you use it for actually?
Ex:

1) New Weapon Spec (#2 ID Weapon) = Old Weapon Spec (#1 ID Weapon)

2) Change New Weapon stats to be better for some, but remain the same for others.

3) Remove Old Weapon and Add New Weapon to inventory

I have slots for tinkered weapons and slots for shop / special shop / drop weapons. #2 is a tinkered weapon and #1 is a drop weapon.

Sorry trying to make my posts consistent.
You have to change the new item ID that isn't used. And you also have to push the new item into item container data. Ex.

I want to make a new weapon based on weapon ID 1

Code:
weapon = $data_weapons[1].dupweapon.id = $data_weapons.size #to ensure that ID wasn't used yetweapon.atk = 500$data_weapons.push(weapon)p $data_weapons[-1].atk => 500p $data_weapons[1].atk => 15
You have to change the new item ID that isn't used. And you also have to push the new item into item container data. Ex.

I want to make a new weapon based on weapon ID 1

weapon = $data_weapons[1].dupweapon.id = $data_weapons.size #to ensure that ID wasn't used yetweapon.atk = 500$data_weapons.push(weapon)p $data_weapons[-1].atk => 500p $data_weapons[1].atk => 15
Not at all what I was asking about.

I have an object and I want all its attribute values to be the same for the other object, later I'll change values for some attributes. All objects have an index and I want them to stay that index not be created then pushed to the end of an array.

Object[0] = Object[1] but not in address.
You can't do that, since Game_Party only storing the ID of the items, not the object itself. Unless you modify how the Game_Party inventory works.
You can't do that, since Game_Party only storing the ID of the items, not the object itself. Unless you modify how the Game_Party inventory works.
I had a command to increase or decrease items in an inventory from that class nothing else.

I had a command to change $data_weapons[1] to be the same as $data_weapon[2]*, but with some changed attribute values.

They are 2 whole different things.

$data_weapons is what a weapon is.

$game_party.gain_item($data_weapons[id], amount) is how many you want to gain or "negatively gain".

.... -.-

Edit: I also have $data_weapons being partly saved in save files to keep changes.
Well, maybe it just me that being confused then. Carry on.
Need a quick way to:

Object[0].a = Object[1].a 

Object[0].b = Object[1].b

Object[0].c = Object[1].c

And so on for all attributes of both objects. Forget everything else. .dup and .clone don't do anything except make other things not work.

Nevermind did it this way since no one had a clue what I was talking about.
As DrDhoom mentioned, Weapon objects have a property named "id", which must be set to the weapons position within the  $data_weapons  array. If it is not because you copied that value from another weapon, some functions won't work as intended.

The example you gave in post #3 works fine for me after adding

$data_weapons[2].id = 2

for example.
As DrDhoom mentioned, Weapon objects have a property named "id", which must be set to the weapons position within the  $data_weapons  array. If it is not because you copied that value from another weapon, some functions won't work as intended.

The example you gave in post #3 works fine for me after adding

$data_weapons[2].id = 2

for example.
Well I keep that in mind if I need to do this again. :/
Need a quick way to:

Object[0].a = Object[1].a 

Object[0].b = Object[1].b

Object[0].c = Object[1].c

And so on for all attributes of both objects. Forget everything else. .dup and .clone don't do anything except make other things not work.

Nevermind did it this way since no one had a clue what I was talking about.
How about something like this:

[:attr_1, :attr_2, :attr_3, ..., :attr_n].each { |attr| obj_1.send🙂"#{attr}=", obj_2.send(attr))}Converting the above into a more concrete example:

Code:
[:a, :b, :c].each { |attr| Object[0].send(:"#{attr}=", Object[1].send(attr)) }
You could


Object=Marshal.load(Marshal.dump(old_object))

Original thread: https://forums.rpgmakerweb.com/threads/object-object.43153/