RPG Maker Forums

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?

Latest Threads

Latest Profile Posts

Frostorm wrote on Featherbrain's profile.
Hey, so what species are your raptors? Any of these?
... so here's my main characters running around inside "Headspace", a place people use as a safe place away from anxious/panic related thinking.
Stream will be live shortly! I will be doing some music tonight! Feel free to drop by!
Made transition effects for going inside or outside using zoom, pixi filter, and a shutter effect
I have gathered enough feedback from a few selected people. But it is still available if you want to sign up https://forums.rpgmakerweb.com/index.php?threads/looking-for-testers-a-closed-tech-demo.130774/

Forum statistics

Threads
105,992
Messages
1,018,189
Members
137,771
Latest member
evoque
Top