RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Modified Skill list cloning same numbers?

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 82
We learn by living...
I was trying to create a skill level system independent to actors, but even though the actors may have different skill levels, I can't get any skill levels to display past the first listed skill, more specifically, whatever my first listed skill's level is for that actor, all their other skills display the same skill level in the menu.


player 1


player 2



Skill id in data base:
mythology: 10
pyrokinesis: 19
bird killer: 73


Quote
  # testing ------------------------------------------------------
 
  def mark
    skill = @data[index]
    m = skill.id
    @actor.skill_levels = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0,
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
    sk = @actor.skill_levels[m]
  return "MU " + sk.to_s
  end
 
Quote
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
   # self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
        self.contents.draw_text(x + 218, y, 60, 32, mark.to_s, 2)
  end


I don't understand the draw_item(index) enough to fix it.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
The problem is that you are calling the method index in your mark method. The index method returns the index of the skill that the cursor is currently over. Since all of the skills are refreshed at once, mark will return the level of the one currently selected, rather than the index of the one you are trying to draw. All you need to do to fix it is pass the index variable from draw_item to the mark method.

***
Rep:
Level 90
Skilled Scripter, Shitty Mapper, Decent Writer.
Might I suggest printing the variables via "p variable_here" to double check their contents?(Doing this will most certainly prove Modern is correct) Also, @actor.skill_levels looks like it's a static(READ:unchanging) variable. So, why are you continuously storing the same data in it on each function call of "mark"? Shouldn't that be in the initialization function of the Game_Actors class with it set as an attr_reader:??? I say Game_Actors because @actor is a common variable name that Enterbrain has associated with the class and you'll see it all through out the status, skill, and equipment windows.

It's your call where you put things but I personally find it easier to define and setup my actor variables in the init. function of Game_Actors. =)

***
Rep:
Level 82
We learn by living...
The problem is that you are calling the method index in your mark method. The index method returns the index of the skill that the cursor is currently over. Since all of the skills are refreshed at once, mark will return the level of the one currently selected, rather than the index of the one you are trying to draw. All you need to do to fix it is pass the index variable from draw_item to the mark method.

How do I pass the index variable to the mark method?


Quote from: Shinami
It's your call where you put things but I personally find it easier to define and setup my actor variables in the init. function of Game_Actors. =)
I was just testing the number displays on the fly, skill_levels is going into main once the display functions properly, and then it will be dynamic. :)



***
Rep:
Level 82
We learn by living...
I think I figured it out. MA said I needed to do was pass drawn item's index variable to the mark method. Instead I tried putting the stuff in the mark method inside the draw item index...
Quote
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
 

    m = skill.id
    sk = @actor.skill_levels[m]
  mark = "MU " + sk.to_s
   

   
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
   # self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
        self.contents.draw_text(x + 218, y, 60, 32, mark.to_s, 2)
  end