- Joined
- Jun 11, 2015
- Messages
- 18
- Reaction score
- 1
- First Language
- English
- Primarily Uses
So I've searched around and can't find a clear answer to a few questions...
My goal at the moment is to add levels to the skills in the game. I've seen a few scripts that do this, but I want to make my own and am having a lot of trouble figuring out which things to call in Ruby.
So far I've gone to Script Editor, and copied Game_Actor to the materials section so I can alter it without messing up the original Game_Actor class.
My plan is two give each skill a level by having one array listing all the skills in the game, and another array listing the level an actor has in each of those skills. Then when I need to know a skills level, I look up the position X of the skill in the first array, and find it's level in the second array simply by looking at slot X.
For example:
def SkillsArrays @Array1=[Fire,Ice,Thunder] #This would be replaced with an actual array of the skills, something I need to figure out how to do @Array2=[2,13,3] #This would be an array of the levels an actor has in the skills. So Fire is lvl 2, Ice is lvl 13, Thunder is lvl 3.enddef LookUpSkillLevel(skill_id) @Array2.at[@Array1.index{skill_id}]end^^From what I can understand, this *should* take skill_id, find it's index in Array1, then use that index number to return the level value from Array2
So assuming the above code is workable, my biggest stumbling block right now is how to make an array out of all the skills in RPGMaker.
I noticed this snippet in the Game_Actor code:
(@skills | added_skills).sort.collect {|id| $data_skills[id] }
And from what I've read in Slip Into Ruby, this is creating an array of all the skills known to the actor and then getting data for the skills. Would using just
(@skills | added_skills).sort give me a sorted array of the character's skills? And if so, should I be concerned about the actor learning more skills later and having to add more to the skill-level array?
If my assumptions are correct (which I doubt), then I think the final code would look like this:
def SkillsArrays @Array1 = (@skills | added_skills).sort @Array2 = [] @Array1.size do #Takes the size of the array and then repeats the next line of code that many times. So if there's 100 skills, it repeats the next line 100 times. I hope. @Array2.push(0) #Adds a 0 to Array 2, giving each skill a starting level of 0. end end#This *should* leave me with Array1 being filled with skill_id values, and Array2 being an array filled with as many slots as there are in Array1, and each slot is a 0.def LookUpSkillLevel(skill_id) #What I use when I want to find a skills level @Array2.at[@Array1.index{skill_id}] #This should find the index of a given skill_id in Array1, then find the value for the skill by looking at that index in Array2.endDoes this seem like it should work, or am I missing something?
Edit: Forgot to fully title thread, sorry. Got distracted trying to get all the info in here
My goal at the moment is to add levels to the skills in the game. I've seen a few scripts that do this, but I want to make my own and am having a lot of trouble figuring out which things to call in Ruby.
So far I've gone to Script Editor, and copied Game_Actor to the materials section so I can alter it without messing up the original Game_Actor class.
My plan is two give each skill a level by having one array listing all the skills in the game, and another array listing the level an actor has in each of those skills. Then when I need to know a skills level, I look up the position X of the skill in the first array, and find it's level in the second array simply by looking at slot X.
For example:
def SkillsArrays @Array1=[Fire,Ice,Thunder] #This would be replaced with an actual array of the skills, something I need to figure out how to do @Array2=[2,13,3] #This would be an array of the levels an actor has in the skills. So Fire is lvl 2, Ice is lvl 13, Thunder is lvl 3.enddef LookUpSkillLevel(skill_id) @Array2.at[@Array1.index{skill_id}]end^^From what I can understand, this *should* take skill_id, find it's index in Array1, then use that index number to return the level value from Array2
So assuming the above code is workable, my biggest stumbling block right now is how to make an array out of all the skills in RPGMaker.
I noticed this snippet in the Game_Actor code:
(@skills | added_skills).sort.collect {|id| $data_skills[id] }
And from what I've read in Slip Into Ruby, this is creating an array of all the skills known to the actor and then getting data for the skills. Would using just
(@skills | added_skills).sort give me a sorted array of the character's skills? And if so, should I be concerned about the actor learning more skills later and having to add more to the skill-level array?
If my assumptions are correct (which I doubt), then I think the final code would look like this:
def SkillsArrays @Array1 = (@skills | added_skills).sort @Array2 = [] @Array1.size do #Takes the size of the array and then repeats the next line of code that many times. So if there's 100 skills, it repeats the next line 100 times. I hope. @Array2.push(0) #Adds a 0 to Array 2, giving each skill a starting level of 0. end end#This *should* leave me with Array1 being filled with skill_id values, and Array2 being an array filled with as many slots as there are in Array1, and each slot is a 0.def LookUpSkillLevel(skill_id) #What I use when I want to find a skills level @Array2.at[@Array1.index{skill_id}] #This should find the index of a given skill_id in Array1, then find the value for the skill by looking at that index in Array2.endDoes this seem like it should work, or am I missing something?
Edit: Forgot to fully title thread, sorry. Got distracted trying to get all the info in here
Last edited by a moderator:


)