Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Unreasonable Error with eval(script)

Hi,
I've heavily modified/rewritten most of the scripts in the game, lately while running a snippet of code out of the event editors script window I recieve the error
"No Method Error "<=>" for Nilclass"
The line the error is for is inside of the Interperter Class, it is the result=eval(script) line at the end of the
class.

I have tried rewriting my code a hundred different ways,
and to no avail.

Most oddly, when I if I add "p eval(script)" right above this line, or in place of this line,
It shows that eval is returning true.
Also, I've tried adding "p 5" after every line of code called by anything involving the snippet causing the error,
and every single line executes just fine.
Event stranger, code after the script command executes, which confuses me as to why the error
would pop on a line that was called a several commands prior...

The code in the script command window is
[rgss]$scene.fog_z(0)
$game_map.flux_setup
$game_map.pix_names
[/rgss]

The first line is not the problem and just does some stuff with the spriteset in Scene_Map.
The flux_setup and pix_names commands just set values for some data in Game_Map,
all of which is initialized with the initialize method; they, literally, do nothing else.

Thank you for any help/suggestion, I've been puling my hair out for the last several hours over this,
I even read through the entire C source code of the eval method, just to see what I might be missing...
Nothing.

*PS I'm 100% positive that even though the modification I've made are extensive, they shouldn't have had any real impact on this; most of it was overhauling the battle system and title scene; I've just started with
maps. (I'm betting the problem is something extremely simple...hoping, at least.)

**Can't believe I forgot to mention this, these commands seemed to work fine a few days prior;
The only thing I've changed is adding an "and @delay != -1" at the end of an unless inside of
Game_Picture, which shouldn't be relevant, and cleaned up a few other things; again that shouldn't be relevant.

***This is actualy starting to get interesting; Ruby is my favorite language and I can't even begin to think what could be happening now. I made a new event whose only command was to run the script

[rgss] 
$game_map.flux_setup
$game_map.pix_names
[/rgss]

Now, if I comment out either of the lines, everything works fine. However, if I combine both methods into a single method, then everything fails all over again; which is where I'm getting confused, since there is no good reasonf or this behaviour. Here is each method:
[rgss]def pix_names(arr = ["1", "2", "3", "4", "5", "6", "7"])
    @images = arr.dup()
    return true
end
 
def flux_setup
    @flux = [[[-50, 50],[-75, 35],[-125, 35]],[28,48], "Circle", "Stars"]
    return true
end
[/rgss]

As said, putting
[rgss]def names_plus_flux(arr = ["1", "2", "3", "4", "5", "6", "7"])
    @images = arr.dup()
    @flux = [[[-50, 50],[-75, 35],[-125, 35]],[28,48], "Circle", "Stars"]
    return true
end
[/rgss]

Also, calling the flux_setup command with @flux as an attr_accessor causes the same error, even if it is by itself;
but remove the accessor, and it works.

****I haven't touched anything in the interperter except the commands used to display the message window, and they aren't causing the problem.
 
Sorry to reply to my own post, but when I edit it, it just reverts back to normal.
Anyways, I fixed it, and I cried a little on the inside when I realized the problem.
Turns out that there was a problem with a block of code in Game_Pictures, however,
I expected that this would cause rmxp to raise an error pointing to that code, not the eval;
Oddly, the update method on game_map is run before it leaves eval, which I don't really understand...Actually, I'm confused as to why that would be so.

So, ultimately, the error was in code unrealted to anything being called from the event's script window, it just happened to get passed into the eval anyways, or more accurately, caused a problem that somehow rgss thought was with the eval, but wasn't (I looked at exactly what was getting passed to eval, and this problem code was not being sent to it; so either rgss has some hidden stuff going on with eval that causes it to pass a $game_map.update to it without telling you, or rgss doesn't catch errors quite right when event scripts are involved. Either way, I'm happy it's fixed:))
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top