script returns a 0 from notetag

I am new to coding in rpg maker and am trying to learn some to help me with my own idea, which is in its infancy. I was learning how to efficiently use notetags, reading tutorials and all, yet my testing has returned a 0 or nil. The idea is to have skill sets (Perception, Stealth, Bluff...) attached to each character via notetags and use those numbers as the core of their custom abilities Similar to D&D, for those who have played. However, I have received a 0, when using a single number and nil when trying a array. I do have coding experience in C++, C#, .net, Basic, and many others yet have not used them in many years and am rusty.


The script I've been tinkering with:


class RPG::Actor
  def Skill_Base
    if @note =~ /<Skillset: (.*)>/i
      $game_variables[1] == $1.to_i
      return true
    else
      return false
    end
  end
end


The notetag which is with the chacter itself and not the class:


<Skillset: 9>


And here is the event used to test it:


@>Conditional Branch: Script: $data_actors[1].Skill_Base
@>Text: -, -, Normal, Bottom
: : \V[1]
@>
: Else
@>
: Branch End
@>


Any help would be appreciated. Thanks in advance.
Code:
$game_variables[1] == $1.to_i

This == is a comparison, not an assignment.


Change it to =


What's happening here is that it's finding the note tag, doing the comparison rather than setting the value of the variable, and then returning true.  You know that it found the note tag because the 'true' part of your conditional branch is being executed (the message is being displayed).  If it wasn't finding the note tag, it wouldn't show the text.


Show me the array example.  You wouldn't be able to use the same test or assignment when looking for an array.
The code is:


class RPG::Actor
def Skill_Base
if @Skill_Base.nil?
if @note =~ /<Skillset:s*(.*)>/i
ints = []
for x in $1.split(",")
$game_variables[1, x] = x.to_i
end
return true
else
return false
end
end
@Skill_Base
end
end


The notetag:


<Skillset: 9,1,10,3,3,1,1,1,1,6,3,1,6,1,9,8,10>


The Event:


error.png


I get the error:


Script 'Gamer_Interpreter' line 450: ArgumentError occurred.


wrong number of arguments (3 for 2)
Because $game_variables is a single-dimension array.  You can't do [a,b] with it.  You would need to do $game_variables[1] = [] to initialize it, then $game_variables[1][n] to refer to elements in it.


Did you check beforehand to see what is in the variable?  Is it an array?  Does it contain the values you expect to be in there?  What is ints used for?  You declare it as an empty array, but you don't do anything with it.  I think your script needs to be modified, and the Control Variables event command needs to have the script call modified as well.
I got it working, thanks. the inits[] was something I forgot to change when I was "tinkering".

Original thread: https://forums.rpgmakerweb.com/threads/script-returns-a-0-from-notetag.66742/