Please Remove NoMethodError

CriticalRPG

Necromancer
Veteran
Joined
Aug 1, 2015
Messages
91
Reaction score
5
First Language
English
Primarily Uses
RMMV
NOTICE: I WAS FRUSTRATED WHILE (unsuccessfully trying to) CREATE A SCRIPT.

Please remove the "NoMethodError" in RPG Maker VX Ace. It prevents beginner programmers (like me) from creating versatile scripts in Ruby. I will show you an example.

if $game_actors[1].class.id == 1 then

  (rest of code)

end

The error message says:

undefined method '[]' for nil:NilClass

How does this make any sense? It just throws out an excuse. Fail.
 
Last edited by a moderator:

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
I am currently....laughing right now...

you asking us to remove Basic Error message because they "stop" you from programming?

I will stop you right now 

You can't remove Error logs in RM due the fact it's not RM but RUBY and no way people wills go remove that if you want so much to remove Error logs in RM 

go argues with the creator of the Ruby Language...

this example show you don't know how to code

because what you did is totally not the right thing's to do.

def method_nameif $game_party.actors[1].class_id == 1#do codeendso before arguing it's stop yourself from doing  script, LEARN HOW TO CODE IN FIRST
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.


The error is likely happening because you have your code in a spot where it will be executed before the game objects are created. So while it might be possible to "remove the error" (I don't really think it is, but let's just assume that we could), it's not going to make your script work, because there IS no $game_actors at the time that command will run. This is WHY the error is reported - it's alerting you to the fact that you've done something wrong.


So you need to look at the default scripts in more detail, figure out at what point you want this code of yours to be executed, and make sure you write your script accordingly. We can help you figure that out if you can't do it on your own, but you'll need to provide at least a description of what it is you're trying to do, maybe with a link to your code so we can see how you're going about it.
 

CriticalRPG

Necromancer
Veteran
Joined
Aug 1, 2015
Messages
91
Reaction score
5
First Language
English
Primarily Uses
RMMV
I am currently....laughing right now...

you asking us to remove Basic Error message because they "stop" you from programming?

I will stop you right now 

You can't remove Error logs in RM due the fact it's not RM but RUBY and no way people wills go remove that if you want so much to remove Error logs in RM 

go argues with the creator of the Ruby Language...

this example show you don't know how to code

because what you did is totally not the right thing's to do.

def method_nameif $game_party.actors[1].class_id == 1#do codeendso before arguing it's stop yourself from doing  script, LEARN HOW TO CODE IN FIRST
Sorry, I was getting frustrated. I am glad, however, that I made you laugh. I cannot code to save my life, lmao

I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.

The error is likely happening because you have your code in a spot where it will be executed before the game objects are created. So while it might be possible to "remove the error" (I don't really think it is, but let's just assume that we could), it's not going to make your script work, because there IS no $game_actors at the time that command will run. This is WHY the error is reported - it's alerting you to the fact that you've done something wrong.

So you need to look at the default scripts in more detail, figure out at what point you want this code of yours to be executed, and make sure you write your script accordingly. We can help you figure that out if you can't do it on your own, but you'll need to provide at least a description of what it is you're trying to do, maybe with a link to your code so we can see how you're going about it.
Ooooh, so it WAS my fault. Son of a gun...

If you want, you can get rid of this thread. In the meantime, I will take your advice, eat a bowl of ramen (or two), and watch some funny internet videos while I'm at it.
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Yeah, I think it's safe to assume, if something doesn't work, it's because you've done something wrong, rather than the engine doing something wrong - especially if you're only learning to script at this stage. In some cases, there ARE engine problems that cause things, but they're few and far between. In most cases, it's because the scripter has done something.


Let us know if you need help.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
lol yeah I kinda sound rude in this one sorry not the intention lol

yes the error catching is not here for stop you from doing script...

just stopping you from doing "errors" even if the Error catching are not alway's clear for people who don't know how to code but we are here for that

but I swear in MV it's even more worse but that's a another matter

anyway's I am unsure of what you want to do but game_actor is not "initialised" as a global variable

a global variable is like the word say it's shared everywhere

the intention of what you want to do is inside the Game_Party Class

although I really advise you to study some basic of the ruby in code academy before jumping in coding....and also after studies how works the behavior of rpg maker
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
You can't be sure what the OP wants to do needs to go into Game_Party, because no details have been provided on what the script is about.


I can think of a number of places in other scripts where this test could be useful.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Oh no no I mean for directly access ther Actor datas you can use Game_party
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
That would be more difficult.


If you want to look at actor 1, it's easier to use $game_actors[1]. If you want to use $game_party to access it, you have to first be sure that that actor is IN the party, and then know what position they're at, as $game_party.actors is ordered by formation sequence, not by actor id. So $game_party.actors[1] could give you actor 5, if that's who the leader is.
 

CriticalRPG

Necromancer
Veteran
Joined
Aug 1, 2015
Messages
91
Reaction score
5
First Language
English
Primarily Uses
RMMV
You can't be sure what the OP wants to do needs to go into Game_Party, because no details have been provided on what the script is about.

I can think of a number of places in other scripts where this test could be useful.
Oh, I have an idea. I want to make a script that, depending on the actor's class, changes the MP bar to say "SP" or something similar. It will use Syvkal's Menu Bars VXAce (http://www.rpgmakervxace.net/topic/1799-syvkals-menu-bars-vxace/) along with it, to change the color of said bar.

This is a VERY rough idea of what i want to do:

def check

if $game_actors[11].class.id == 11 then

  Vocab.mp = "EP"

end

end
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
okay, so you don't want to hard code the actor id, because it's something you want to do for "the current actor", whoever that actor is.


And if you're ONLY using that script to change the colour based on the class, I would ditch it altogether, because you're going to have to mod it anyway to look at the class, and you could just as easily do that with a new script.


Are you using default scripts for the menu and battle hud?
 

CriticalRPG

Necromancer
Veteran
Joined
Aug 1, 2015
Messages
91
Reaction score
5
First Language
English
Primarily Uses
RMMV
okay, so you don't want to hard code the actor id, because it's something you want to do for "the current actor", whoever that actor is.

And if you're ONLY using that script to change the colour based on the class, I would ditch it altogether, because you're going to have to mod it anyway to look at the class, and you could just as easily do that with a new script.

Are you using default scripts for the menu and battle hud?
Yes, I am using the default.

I think I see what you mean, though. I need the script to check for each actor in the party, right?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
No. The existing scripts already have the actor id, so you just need to check for the "current" actor. You do not want to hardcode an actor id at all.

Start with this as a base, and expand on the first 3 methods as needed.

class Window_Base < Window def actor_mp_gauge_color1(actor) case actor.class_id when 1 text_color(x) when 11 text_color(y) else mp_gauge_color1 end end def actor_mp_gauge_color2(actor) case actor.class_id when 1 text_color(a) when 11 text_color( B) else mp_gauge_color2 end end def actor_mp_vocab(actor) case actor.class_id when 1 'SP' when 11 'EP' else Vocab::mp_a end end #-------------------------------------------------------------------------- # * Draw MP #-------------------------------------------------------------------------- def draw_actor_mp(actor, x, y, width = 124) draw_gauge(x, y, width, actor.mp_rate, actor_mp_gauge_color1(actor), actor_mp_gauge_color2(actor)) change_color(system_color) draw_text(x, y, 30, line_height, actor_mp_vocab(actor)) draw_current_and_max_values(x, y, width, actor.mp, actor.mmp, mp_color(actor), normal_color) endendIf you want to use the same term and colours for several classes, you can do this:

Code:
  when 1, 11
instead of listing them separately.On the lines that have text_color(), replace a, b, x, y with the index of the colours you want to use. These come from the palette in the lower right corner of the windowskin image, and the first one has index of 0.

So what happens is every time it goes to draw an MP bar, it will check to see what colours and term it should use. It will look at the class of the current actor, and if it's one of the 'special' classes, it will return that specific colour or term. If it's none of the 'special' classes, it'll return the default values.
 
Last edited by a moderator:

CriticalRPG

Necromancer
Veteran
Joined
Aug 1, 2015
Messages
91
Reaction score
5
First Language
English
Primarily Uses
RMMV
No. The existing scripts already have the actor id, so you just need to check for the "current" actor. You do not want to hardcode an actor id at all.

Start with this as a base, and expand on the first 3 methods as needed.

class Window_Base < Window def actor_mp_gauge_color1(actor) case actor.class_id when 1 text_color(x) when 11 text_color(y) else mp_gauge_color1 end end def actor_mp_gauge_color2(actor) case actor.class_id when 1 text_color(a) when 11 text_color( else mp_gauge_color2 end end def actor_mp_vocab(actor) case actor.class_id when 1 'SP' when 'EP' else Vocab::mp_a end end #-------------------------------------------------------------------------- # * Draw MP #-------------------------------------------------------------------------- def draw_actor_mp(actor, x, y, width = 124) draw_gauge(x, y, width, actor.mp_rate, actor_mp_gauge_color1(actor), actor_mp_gauge_color2(actor)) change_color(system_color) draw_text(x, y, 30, line_height, actor_mp_vocab(actor)) draw_current_and_max_values(x, y, width, actor.mp, actor.mmp, mp_color(actor), normal_color) endendIf you want to use the same term and colours for several classes, you can do this:

Code:
  when 1, 11
instead of listing them separately.On the lines that have text_color(), replace a, b, x, y with the index of the colours you want to use. These come from the palette in the lower right corner of the windowskin image, and the first one has index of 0.

So what happens is every time it goes to draw an MP bar, it will check to see what colours and term it should use. It will look at the class of the current actor, and if it's one of the 'special' classes, it will return that specific colour or term. If it's none of the 'special' classes, it'll return the default values.
Wow, I think this might just be what I need! Thanks for your help, for putting up with this whole thing, and explaining it to me.

You're a pretty cool guy, you know?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
or girl ;)


I try.


You might have to modify some other windows to cater for EP/SP instead of MP on the skill and battle skill screens. Note in the last method above, to change the title that appears, I only modified one line. Compare it to the original method in the Window_Base class.


See if you can find the other scripts that need to be modified (do a global search - control+shift+F - for Vocab::mp) and see if you can figure out how they'd need to change. If they are Window_... scripts, you can just call the same new method above to return the correct title. You might need to duplicate that method if you want a short & long version of the title.
 
Last edited by a moderator:

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top