Use Variables in $gameActors.actor().isStateAffected()

Hello everybody.

I am planning to make a "Learning skill through items" common event,
the step is like:

1. use a"Fire ball scroll" to one of actors of party
2. he got a state named "Learning skill " (Id=0150)
3. common event detected "which actorID" is affected by "Learning skill " state.
4. then the actor learned "Fire ball" skill.

now ,I'm stuck at step 3
this is my script inside the common event :

IF : Script : $gameActors.actor($gameVariables.value(7)).isStateAffected(150)

It's not work and got error
upload_2017-7-13_22-24-25.png



When I use the following script :
IF : Script : $gameActors.actor(1).isStateAffected(150)

It's work fine but only for actor1 !
I want to use variable No.7 to alter actorID,for example:

Harold :$gameVariables.value(7) =1
Therese : $gameVariables.value(7) =2
Marsha : $gameVariables.value(7) =3
.... etc.

Sorry for poor english , can anyone please help me?
That means variable 7 doesn't contain a valid actor id. How did you populate that variable?

I believe you can just use a Learn Skill effect on the Fire Ball Scroll item, and whoever that item is used on will then learn the skill. No need to use a common event at all. But even if you do, there are easier ways to do what you're attempting.
I'm grateful for your reply.

I use another common event to populate variable

event content:

IF: #1 Harold is affected by "Learning skill"
Control variables : # 0007 = 1
:End

IF: #2 Therese is affected by "Learning skill"
Control variables : # 0007 = 2
:End

IF: #3 Marsha is affected by "Learning skill"
Control variables : # 0007 = 3
:End

I don't use a Learn Skill effect on the Fire Ball Scroll item because the actor will learn the skill immediately when he/she use this Fire Ball Scroll .

I want to add a success/failure checking before the actor Learned the skill, I explain as following pictures...

1. Regular method :
upload_2017-7-18_14-14-31.png


2. My idea :

upload_2017-7-18_14-14-50.png


I'm confuse why when I assign actor ID to 1 directly like the following script then it's work perfectly,but get error if I alter variable #7 instead of 1 ? Did I have a syntax mistake?

IF : Script : $gameActors.actor(1).isStateAffected(150)

IF : Script : $gameActors.actor(
$gameVariables.value(7)).isStateAffected(150)
Then you don't need to use a variable.

IF Harold is affected by Learning Skill
calculate the rate
IF rate >= 1
Change Skills: Harold - Learn Fire Ball Spell
END

repeat for each actor.
haha....,yse, you are right!
Actually, I just use the script you wrote above before starting this thread to make the "Learning skill" system work.

The only problem is my project will have 20 actors and at least 45 skill.
It means I need to set the rule one after another at least 20x45=900 times!
If I can use variable to assign actor ID, the rule can be simplified like :

Loop:
IF actor(Variable#7) is affected by Learning Skill
calculate the rate
IF rate >= 1
Change Skills: actor(Variable#7) - Learn Fire Ball Spell
END
Control variables : # 0007 += 1
IF variables : # 0007 >20
Control variables : # 0007 = 1
END
wait 2 frame
:Repeat above

then I can just copy and paste to each skill setting.

Maybe there is no pefect solution to solve my question.
Anyway,thanks a lot!

Original thread: https://forums.rpgmakerweb.com/threads/use-variables-in-gameactors-actor-isstateaffected.81245/