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.
Array Help

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 84
I'm trying to modify the equippable? definition in Game_Actor so that it bypasses the need to select which equipment a class can equip, but instead is passed on certain skills/proficencies learnt. This is my coding I have:
Code: [Select]
module Equipment_Setup
  armtypes = {}
  armtypes[1] = "Cloth"
  armtypes[2] = "Leather"
  armtypes[3] = "Chain"
  armtypes[4] = "Plate"
  #armtypes = {"Cloth","Leather","Chain","Plate"}
  armskills = {
            1 => 98,
            2 => 99,
            3 => 100,
            4 => 101
          }
end   
       
class Game_Actor < Game_Battler
  include NOTES
  def equippables?(item, actor)
    @actor = actor
    if item.is_a?(RPG::Weapon)
      return self.class.weapon_set.include?(item.id)
    elsif item.is_a?(RPG::Armor)
      return false if two_swords_style and item.kind == 0
      for i in 1...4
        @armtype = Equipment_Setup::armtypes[i]
        if has_tag?(item.note,@armtype) and @actor.skill_learn? (Equipment_Setup::armskills[i])
          return self.class.armor_set.include?(item.id)
        end
      end 
    end
    return false
  end
end

I have tried to setup the armtypes array many ways but it still does not work. I am gettig an undefined method error for the line starting with @armtype =. I don't know what is going on because I have arrays like thsi setup elsewhere and it works no problem.

*
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
Well, if I had to take a guess, it's because armtypes is not a constant.

Also, why a hash?
Try:

Code: [Select]
  ARMTYPES = []
  ARMTYPES[1] = "Cloth"
  ARMTYPES[2] = "Leather"
  ARMTYPES[3] = "Chain"
  ARMTYPES[4] = "Plate"
  #ARMTYPES = ["Cloth","Leather","Chain","Plate"]
  ARMSKILLS = []
  ARMSKILLS[1] = 98
  ARMSKILLS[2] = 99
  ARMSKILLS[3] = 100
  ARMSKILLS[4] = 101

And get back to me. There may be other problems too, but those are what stick out to me...

Naturally, you will also have to change any lines that call them to their capitalized variants.

so Equipment_Setup::ARMTYPES, not  Equipment_Setup::armtypes

also equippables?

Where is the 's' coming from. I take it you must be calling it as a method separated from equippable? in any case.

**
Rep: +0/-0Level 84
Yes I am calling it as equippables as I don't want every other script which calls equippable to need actor info sent with it. It seems to like this way better, but I am now recieving an error in the NOTES file.
Code: [Select]
#==============================================================================
# ** Notes Field System
#------------------------------------------------------------------------------
# By Syvkal
# Version 1.6
# 05-29-08
#==============================================================================

module NOTES
 
  def get_tag(field, tag, extra_tag = "")
    note = ""+field
    note = note.split("\r\n")
    for i in 0...note.size
      if note[i].include?(tag + extra_tag)
        tags = note[i]
        tags.slice!(tag)
        if extra_tag != ""
          tags.slice!(extra_tag)
        end
        tags = tags.split(/,\s*/)
        return tags
      end
    end
    return nil
  end
 
  def get_multiple_tag(field, tag, extra_tag = "")
    note = ""+field
    note = note.split("\r\n")
    for i in 0...note.size
      if note[i].include?(tag + extra_tag)
        tags = note[i]
        tags.slice!(tag)
        if extra_tag != ""
          tags.slice!(extra_tag)
        end
        tags = tags.split(/,\s*/)
        for i in 0...tags.size
          if tags[i].include?('&')
            tags[i] = tags[i].split(/\s*\&\s*/)
          end
        end
        return tags
      end
    end
    return nil
  end
 
  def has_tag?(field, tag, extra_tag = "")
    note = ""+field
    if note.include?(tag + extra_tag)
      return true
    end
    return false
  end
 
  def get_tag_area(field, area_tags)
    note = ""+field
    if note.include?(area_tags)
      @yes = false
      note = note.split(/#{area_tags}/)
      note = note[1]
      return note
    else
      return ""
    end
  end
 
end
 
More specifically this line:     if note.include?(tag + extra_tag)

*
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
Your sending armtype as an integer. Send it as a string.

@armtype.to_s

**
Rep: +0/-0Level 84
Awesome that solved the errors. I am not getting anymore errors, but the script isn't working.
Code: [Select]
module Equipment_Setup
  ARMTYPES = []
  ARMTYPES[1] = "Cloth"
  ARMTYPES[2] = "Leather"
  ARMTYPES[3] = "Chain"
  ARMTYPES[4] = "Plate"
  #ARMTYPES = ["Cloth","Leather","Chain","Plate"]
  ARMSKILLS = []
  ARMSKILLS[1] = 98
  ARMSKILLS[2] = 99
  ARMSKILLS[3] = 100
  ARMSKILLS[4] = 101
end   
       
class Game_Actor < Game_Battler
  include NOTES
  def equippables?(item, actor)
    @actor = actor
    if item.is_a?(RPG::Weapon)
      return self.class.weapon_set.include?(item.id)
    elsif item.is_a?(RPG::Armor)
      return false if two_swords_style and item.kind == 0
      for i in 0...3
        @armtype = Equipment_Setup::ARMTYPES[i].to_s
        if has_tag?(item.note,@armtype) and @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
          return true
        end
      end 
    end
    return false
  end
  def skills_learn?(skill_id,actor)
    @actor = actor
    return @actor.skills.include?(skill_id)
  end
end

Basically the user picks up a Chain Coif, with Chain in the notes page. and then learns the skill Chain Mail (100). But it is not being displayed in the equipment screen. Any ideas>

*
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

          return self.class.armor_set.include?(item.id)


That checks the class armor set. If the item is not in it, it will return false. Change it to: return true if you don't want that.

**
Rep: +0/-0Level 84
If you look, thats what I have, but it still doesn't seem to be working.

*
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
I did look. If you read, you'll note that I suspect the item is not showing up because he does not have the right class. You said you wanted to remove that restriction, so I am telling you - get rid of that condition and replace it with return true.

**
Rep: +0/-0Level 84
The weapon line is still there yes, but I have removed the check to see if the armor is within the class and in turn replaced it with return true. Unless I am completely missing something:S.

*
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
Alright, well right under the @armtype line, put this:
Code: [Select]
p has_tag?(item.note,@armtype), @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)

and tell me what comes out.

Also, can I see what your skills_learn? method looks like?

**
Rep: +0/-0Level 84
Do you not see the code in Reply #3? Im just curious cuz all of that is placed in there.
Basically my skills_learned method looks like this:
Code: [Select]
  def skills_learn?(skill_id,actor)
    @actor = actor
    return @actor.skills.include?(skill_id)
  end

Just want to check the skills and actor actually has. Don't know how the original skill_learned works, so I modified it like this.


EDIT: When I add the:
Code: [Select]
p has_tag?(item.note,@armtype), @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
I get an error immediately when I playtest, SyntaxError Occured

*
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
Sorry, I didn't see the skills_learn? method.

A lot of your code is confusing to me though. Why do you use the actor as an argument when the methods are in Game_Actor? Are you sending different actors into it? If so, why?

It's weird that that line gives a syntax error, since the line below it does not. Anyway, I'll look into it once I get back. I have to go for a little while.

EDIT::
Oh, and I can't believe I didn't notice this earlier, I should've the moment you got the addition error in the Notes script:

Code: [Select]
      for i in 0...3
        @armtype = Equipment_Setup::ARMTYPES[i].to_s
        if has_tag?(item.note,@armtype) and @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
          return true
        end
      end 

Should be
Code: [Select]
for i in 1...5
- because you don't define 0 as an element of your array and you actually want it to iterate through 1, 2, 3 and 4. Also, you won't need to put the .to_s anymore - I had a notion for some reason that you were sending the skill ID. Actually, there's another fairly

Here's what the equippables? method should look like. Again I don't know why you have @actor as an argument, but I will assume it is for a good reason and keep it.

Code: [Select]
def equippables?(item, actor)
    @actor = actor
    if item.is_a?(RPG::Weapon)
      return self.class.weapon_set.include?(item.id)
    elsif item.is_a?(RPG::Armor)
      return false if two_swords_style && item.kind == 0
      for i in 1...5
        @armtype = Equipment_Setup::ARMTYPES[i]
        if has_tag?(item.note,@armtype) && @actor.skills_learn? (Equipment_Setup::ARMSKILLS[i], @actor)
          return true
        end
      end 
    end
    return false
  end
« Last Edit: October 18, 2008, 04:08:20 PM by modern algebra »

**
Rep: +0/-0Level 84
I only have the @actor as an argument cuz well I am starting to play around with the scripts more and thought thats what was needed to be added. I've worked with programming languages before so I am not completely new with all this. Just unsure of how "global" the variables are within a class. So really from what you say, I don't need to include the actor argument.

EDIT: Got it to work. Had a problem with my skill_learn definition.
« Last Edit: October 19, 2008, 05:12:13 AM by Selacius »