[VXAce][Victor Engine - Step Sound] The <no step sound> command on actors crashes the game.

Status
Not open for further replies.

CarlosDavilla

The Insolent One
Veteran
Joined
Jul 31, 2018
Messages
61
Reaction score
4
First Language
Portuguese
Primarily Uses
RM2k
Hello there. Good to see you guys again.

So, new problem.

I'm using the Step Sound script from Victor Sant, and it works fine, but the <no step sound> command for actors doesn't work.

You see, I've tried to put it in my followers on their Note boxes in the Database so they won't make sounds when the player is walking, but when I try out if it works in the game, it crashes to this window:


What could be causing that?
 

Ateliae

Illustrator
Veteran
Joined
Jun 4, 2016
Messages
65
Reaction score
16
First Language
English
Primarily Uses
RMVXA
Did you try using the script on a blank demo to see if there's some compatibility issues?
 

CarlosDavilla

The Insolent One
Veteran
Joined
Jul 31, 2018
Messages
61
Reaction score
4
First Language
Portuguese
Primarily Uses
RM2k
Did you try using the script on a blank demo to see if there's some compatibility issues?
I certainly did, and it resulted in the same error from my project.
Looks like it's a problem coming from the script itself.

 

Traverse

Veteran
Veteran
Joined
Jul 3, 2014
Messages
161
Reaction score
102
First Language
English
Primarily Uses
I have seen this problem with this script mentioned before. And I can offer a guess as to what the problem is. However, it would be nice if somebody more experienced with Ruby could help to confirm my guess.

My guess is this:

Because of the way the script checks for the <no step sound> notetag on the Actor, the variable used to detect it (@no_step_sound_player) stores the information as an integer.
Code:
# This is the line that checks the Actor notebox for the tag.
@no_step_sound_player = actor.note =~ /<NO STEP SOUND>/i
The "=~" operator here returns the letter position in the text data (the Actor notebox in this case) where the phrase being checked gets detected (if it exists), so it would be "0" if the <no step sound> tag was the first thing in the notebox, "1" if there was a single space or some other letter before the tag, "2" if there's 2 spaces or two letters, "10" if you had some other 10-letter notetag before the step sound one, etc, etc. And if there is no detection and the <no step sound> tag is NOT in the notebox, the value returned is "Nil".

But I digress, it doesn't really matter what the number is/how many characters down the notebox the tag is. The point is that the detection is stored as either a number or Nil.

After that, whatever the value of the variable ends up being, the script then continues to check it against any equipment and states applied on the Actor to see if any of them also has any <no step sound> tags in their noteboxes.
Code:
    actor.equips.compact.each do |equip|
       @no_step_sound_player |= equip.note =~ /<NO STEP SOUND>/i
     end
     actor.states.each do |state|
       @no_step_sound_player |= state.note =~ /<NO STEP SOUND>/i
     end
The problem is that the way he does THESE checks uses the |= operator. If I am not wrong, this operator will do different things, depending on what kind of object it is being used on. If it is used on a number, it becomes the Bitwise-or operator and flips digits on the binary value to return another number.

BUT if it is used on an object whose value is "True" or "False" or "Nil", it becomes a comparison operator that then returns true or false. True and False in Ruby is not the same thing as the numbers 0 and 1, they are actually whole objects called TrueClass and FalseClass (I think Nil is also a FalseClass) and these classes overwrite the |= operator. They make it so that if a TrueClass object calls it, it will always return True. And if a FalseClass or Nil calls it, it will check the value on the right-hand side and return False if the other value is also False or Nil, otherwise it will return True.

I suspect this true/false outputting was what Victor Sant MEANT to use it for. And it works if the value of @no_step_sound_player is either True or False or Nil when the check is performed. But if the value is a number, I suspect it attempts to apply the bitwise version of it instead. And since the value of the right-hand side, Nil, is not a number, it throws a crash when it tries to do it (I don't know what would happen if you engineered it so that all the equipment/states on the Actor actually DID have the tag and none of the checks returned Nil).

So the solution I would offer is this:
Code:
# Replace this line:
@no_step_sound_player = actor.note =~ /<NO STEP SOUND>/i
# With this line:
@no_step_sound_player |= actor.note =~ /<NO STEP SOUND>/i
Since the value of "@no_step_sound_player" is Nil by default, it will run the FalseClass version of the operator on whatever is detected by "actor.note =~ /<NO STEP SOUND>/i" and so will return True instead of directly setting the value to the number outputted by the check on the notebox, if the notetag exists (if not it will return False).

Basically, it will prevent it from becoming a number and making the following checks screw up later on by trying to run the bitwise operation.
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
283
Reaction score
106
First Language
English
Primarily Uses
RMXP
Correct, though your solution would only work once I believe. @no_step_sound_player on the second pass through could be true, meaning all the |= will always result in true forever. You need to reset @no_step_sound_player, which is probably why the first one was just a plain equals.
Code:
@no_step_sound_player = (actor.note =~ /<NO STEP SOUND>/i) != nil
would be better.
 

CarlosDavilla

The Insolent One
Veteran
Joined
Jul 31, 2018
Messages
61
Reaction score
4
First Language
Portuguese
Primarily Uses
RM2k
Well, I'll be damned, it actually worked.
Thank you guys. I was really needing a solution for this one.
The thread can now be closed.
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
7,867
Reaction score
5,240
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,447
Members
137,820
Latest member
georg09byron
Top