[XP] WEIRD RUBY BEHAVIOR

Posts

Pages: 1
I have a small piece of script that I wrote in Ruby that allows the "Show Picture" event command to use variables for more than just X and Y. I wrote this script some time ago, back in version 1.02 (when the Enterbrain products were distributed by Protexis instead of Digica).



When switch 1 is turned ON, the program uses the customized code. Otherwise, it uses the default code.

This code used to work, and it still does for when switch 1 is OFF, but now, when switch 1 is turned ON, the game will crash with a NoMethodError error.

Now, here's the strange thing... when I change that "if $game_switches{1} == false" line near the very beginning of the code to "if $game_switches{1} == true", it works, both ways.

What's going on? If possible, I'd like to keep the switch OFF by default instead of ON by default.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
What's the error say, exactly?
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Huh. Well, the $game_screen only has 100 pictures. If you're using a picture ID higher than 100 or less than 1, it'll crash with that error. I'd guess this is probably your problem.

To allow more than 100 pictures, go into the Game_Screen section of the scripts, and go down to about line 34. You'll see this:
for i in 1..100
      @pictures.push(Game_Picture.new(i))
    end

Change it to like 300 or something if you want.

However, if the game_variable you use is equal to 0 or less, the script'll crash every time. Since that's the default value for a game_variable, it's probably gonna crash a lot. You may want to code custom behavior, checking if "number" is zero, and just returning if so.
Thanks, I'll try to mess around with it, and double-check the variables I'm using.

That reminds me... is there some Ruby command I can use that will shoot some kind of text box onto the screen, to check for variable values at that precise time in the code?

----------

Found the problem. It's like you said... "number" was being sent in as "0". This is because I was turning on Switch 1 and then setting variables... and I forgot that I was also using switch 1 to modify the variable-handling interpreter in the game's engine.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
print(variable) should print the value of a variable to the screen in a textbox during gameplay. Or maybe it's write(variable) or out(variable). Something like that.
Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
p $game_variables(square bracket)id(close square bracket)
Pages: 1