Issues using script call

Hi, I'm trying to use this command below to set the variable 508 to the value of an actors attack.

$gameVariables.setValue(508, $gameActors.actor($gameVariables.value(524)).param[2])

Variable 524 is an index of a loop that goes through all of the actors and if they are in the party sets their attack and other variables to allow them to perform in the tactical battle system I am making.

However, when I try and set the variable to the attack parameter, it returns as 0. The attack power of the first actor is 31.

This same result happens with all parameters but HP.

Is there a problem with my code? Is there another way I can find the attack of actor(x)?
Use:
$gameVariables.setValue(508, $gameActors.actor($gameVariables.value(524)).atk)

Max HP = mhp
Current HP = hp
Max MP = mmp
Current MP = mp
Attack = atk
Defense = def
Magic Attack = mat
Magic Defense = mdf
Luck = luk
Agility = agi

Replace "atk" in the fixed code I gave, witj any of theese parameters ie to do Defense:
$gameVariables.setValue(508, $gameActors.actor($gameVariables.value(524)).def)
Thanks a lot. That is what I needed.

Why is it listed as param[n] in the master spreadsheet instead of the stuff you showed me?



Line 145
@Ham5terman That's either for an older version of MV (seems unlikely to me, but it's possible), or it's a typo. It should be $gameActors.actor(actorId).param(n)
Yeah. When I used that in my code, it didn't work, but when I used the .atk and .agi that Zarsla mentioned it worked. Do I have an earlier version of MV?
I think you're missing what I said. It's not param[n], it's param(n). Difference between brackets and parentheses.
Oh. Ok. So you can either use param(n) or .atk .agi etc?
It is exactly the same.

Programatically behind the scenes, ".atk" calls "param(2)", ".def" calls "param(3)", etc.
Only if you're checking all params then better to loop through param(X).

Otherwise if you're checking one then better to use ".atk" etc. because then you can easily see what you're checking for when you look at your event a week later and forget what it's supposed to do.

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.

Original thread: https://forums.rpgmakerweb.com/threads/issues-using-script-call.89774/