I was having an issue with getting a script to work properly and I found some odd behavior.
Basically, I just want to copy the effects from an item object to a skill object.
The problem is, this seems to only work once before the new value just sticks and refuses to change.
#==============================================================================
# ** Alchemy Module (WIP)
#==============================================================================
module RINOBI module Alchemy
def self.copy_item_data(skill_id, item_id)
3.times do
print "Inital Effects: #{$data_skills[skill_id].effects}\n\n"
effect_array = Array.new
$data_skills[skill_id].effects = Array.new
print "Reset Effects: #{$data_skills[skill_id].effects}\n\n"
$data_items[item_id].effects.each {|effect| effect_array.push(effect)}
effect_array.each {|effect| $data_skills[skill_id].effects.push(effect)}
print "New Effects Value: #{$data_skills[skill_id].effects}\n\n"
$data_skills[skill_id].effects[0].data_id = 102
end #--
end # copy_item_data
end # Alchemy Module
The skill I'm testing testing doesn't have any effects by default, and the data_id of the item is 100.
I would expect to see New Effects Value always print a value of 100, but this isn't the case. After the first time around, only a value of 102 is printed out, and I don't know why.
Here are the results from the console.
Inital Effects: []
Reset Effects: []
New Effects Value: [#<RPG::UsableItem::Effect:0x6b69850 @code=21, @data_id=100, @value1=1.0, @value2=0.0>]
Inital Effects: [#<RPG::UsableItem::Effect:0x6b69850 @code=21, @data_id=102, @value1=1.0, @value2=0.0>]
Reset Effects: []
New Effects Value: [#<RPG::UsableItem::Effect:0x6b69850 @code=21, @data_id=102, @value1=1.0, @value2=0.0>]
Inital Effects: [#<RPG::UsableItem::Effect:0x6b69850 @code=21, @data_id=102, @value1=1.0, @value2=0.0>]
Reset Effects: []
New Effects Value: [#<RPG::UsableItem::Effect:0x6b69850 @code=21, @data_id=102, @value1=1.0, @value2=0.0>]
It doesn't seem to matter how I go about copying the effects either, the above example was simply the latest thing I tried.
$data_skills[skill_id].effects = $data_items[item_id].effects.dup produces the same results for example.
How do I get around this?