Shaz's Add/Remove State Commands Not Working

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
To preface, no, it is not a compatibility issue.

I'm sorely confused. Also exhausted trying to dive into this relatively small script and figure out why it isn't working. The script in reference can be found here: https://forums.rpgmakerweb.com/index.php?threads/state-add-remove-commands.18593/

It's a pretty straightforward script - it simply runs a single excerpt of code when a state is added or removed. I'm using it to remove a state (let's call it "y") when "x" state is added. This is so far ahead of where I am now, however. Right now, I can't get this script to execute a single line of code. Theoretically, you could put something as simple as this in a state's notetag:

Code:
onadd: p 'this works?'
...to print that text to the console when the state is added. But it won't even do that, in a completely new project no less (even though none of my other scripts should interfere with this...). I went as far as to put random code like "onadd: method_which_does_not_exist" and it won't return an error. So clearly the script is never being run in the first place; a considerable problem.

I sifted through Shaz's script a bit, and can't see any obvious issues with it. All it does is alias the method for adding and erasing states in an instance of Game_Battler. My only theory is that Shaz mixed up "remove_state" and "erase_state" but to be honest, I don't even understand the difference between these two methods, they seem to be used the same way. Maybe as an aside, somebody can explain that to me.

Anyways, some help here would be lovely. I'm at my wits' end and this script (or rather its functions) is pivotal to the mechanics of my game. If anyone knows of an alternate way to remove a state when another is added (no, [State Resist] doesn't do this correctly), that would also be awesome. I don't know atm of any other scripts which can do this.

Thank you!
 

vFoggy

Veteran
Veteran
Joined
Nov 3, 2012
Messages
71
Reaction score
31
Primarily Uses
Swap line 61 with line 62.
From:
Code:
shaz_state_commands_add_new_state(state_id)
state_add_command(state_id) if !state?(state_id)
to:
Code:
state_add_command(state_id) if !state?(state_id)
shaz_state_commands_add_new_state(state_id)
 

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
How about that, it worked.

Thanks! Could you explain what he did wrong here, though? Was it that he referenced the aliased method before introducing the new method?
 

vFoggy

Veteran
Veteran
Joined
Nov 3, 2012
Messages
71
Reaction score
31
Primarily Uses
How about that, it worked.

Thanks! Could you explain what he did wrong here, though? Was it that he referenced the aliased method before introducing the new method?
Yes, that was the problem.
On the first line, the method to add the state is called (and it is added) and then the state_add_command is called only when the battler does NOT have the state (if !state?(state_id), in this case never, because the state is already added on the first line.
 

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
Cool, thanks for the explanation.
 

Shaz

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

Hero_Claive

(Phoenix Ember)
Veteran
Joined
Jan 5, 2016
Messages
149
Reaction score
88
First Language
English
Primarily Uses
RMVXA
My bad, it's noted.

Very useful script by the way!
 

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,853
Messages
1,016,986
Members
137,561
Latest member
visploo100
Top