Object = Object

Shabbur

Veteran
Veteran
Joined
Feb 4, 2015
Messages
44
Reaction score
0
Primarily Uses
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.
 

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
Use .dup or .clone

Code:
object1.a = object2.a.dup
 

Shabbur

Veteran
Veteran
Joined
Feb 4, 2015
Messages
44
Reaction score
0
Primarily Uses
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
 
Last edited by a moderator:

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
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?
 

Shabbur

Veteran
Veteran
Joined
Feb 4, 2015
Messages
44
Reaction score
0
Primarily Uses
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.
 
Last edited by a moderator:

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
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
 

Shabbur

Veteran
Veteran
Joined
Feb 4, 2015
Messages
44
Reaction score
0
Primarily Uses
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.
 

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
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.
 

Shabbur

Veteran
Veteran
Joined
Feb 4, 2015
Messages
44
Reaction score
0
Primarily Uses
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.
 
Last edited by a moderator:

DrDhoom

Monkey Needs a Hug
Veteran
Joined
Mar 16, 2012
Messages
154
Reaction score
157
First Language
Indonesian
Primarily Uses
N/A
Well, maybe it just me that being confused then. Carry on.
 

Shabbur

Veteran
Veteran
Joined
Feb 4, 2015
Messages
44
Reaction score
0
Primarily Uses
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.
 
Last edited by a moderator:

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
565
Reaction score
276
First Language
German
Primarily Uses
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.
 
Last edited by a moderator:

Shabbur

Veteran
Veteran
Joined
Feb 4, 2015
Messages
44
Reaction score
0
Primarily Uses
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. :/
 

DoubleX

Just a nameless weakling
Veteran
Joined
Jan 2, 2014
Messages
1,790
Reaction score
943
First Language
Chinese
Primarily Uses
N/A
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)) }
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
You could


Object=Marshal.load(Marshal.dump(old_object))
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,357
Members
137,803
Latest member
andrewcole
Top