script returns a 0 from notetag

maddhatter724

Villager
Member
Joined
Feb 9, 2016
Messages
6
Reaction score
0
First Language
English
Primarily Uses
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 
Last edited by a moderator:

maddhatter724

Villager
Member
Joined
Feb 9, 2016
Messages
6
Reaction score
0
First Language
English
Primarily Uses
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)
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

maddhatter724

Villager
Member
Joined
Feb 9, 2016
Messages
6
Reaction score
0
First Language
English
Primarily Uses
I got it working, thanks. the inits[] was something I forgot to change when I was "tinkering".
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:
To whom ever person or persons who re-did the DS/DS+ asset packs for MV (as in, they are all 48x48, and not just x2 the pixel scale) .... THANK-YOU!!!!!!!!! XwwwwX

Forum statistics

Threads
105,847
Messages
1,016,972
Members
137,561
Latest member
JaCrispy85
Top