I'm having some difficulties with the parameters as they seem to be a bit weird, not exactly as shown in the script call sheet. When viewing the parameters you need to use parenthesis like so.
$gameMessage.add(String($gameActors.actor(1).param(2)))
However when I try to edit the value using parenthesis I get an error. So I tried to use the brackets as shown in the script call sheet, like so
$gameActors.actor(1).param[2] = 1
I no longer get an error but the value doesn't change either. How do I set the value of the parameter?
Changing Parameter Values Via Script
● ARCHIVED · READ-ONLY
-
-
When you wanna add to a parameter you need to use
Code:$gameActors.actor(x).addParam(paramId, value); -
Is there a way to simply set a value rather than add/subtract?
-
No wonder $gameActors.actor(1).param(2) = 1; throws you an error.
$gameActors.actor(1).param(2) is a function. And functions are immutable, so they cannot be assigned a value. You can only call a function.
However, the number in params is equivalent to this:
0 - mhp
1 - mmp
2 - atk
3 - def
4 - mat
5 - mdf
6 - spd
7 - luk
So since now we know that param 2 is attack, which is a property and not a function, we can change it like this:
$gameActors.actor(1).atk = 1;
I'm not going to go in too many confusing details, this is object oriented programming and I'm not sure what's your skill in Javascript. I don't want to confuse you too much as well. -
@Poryg
$gameActors.actor(1).atk = 1;
Would not work, because "atk" is only read-only (it's only a getter, not a setter). The only way to change parameters is what I posted. -
I'll be damned, I completely forgot that you can change only hp, mp and tp.
So, if we simplify it to an unified command, in order to set the param to value x, you need to subtract value - x:
$gameActors.actor(1).addParam(paramId, Math.abs ($gameActors.actor(1).param(paramId) - number) * -1)
Well, that doesn't look too beautiful xD
EDIT: No, that's not correct... Doesn't work for number greater than parameter... So it's equivalent to
$gameActors.actor(1).addParam (paramId, $gameActors.actor(1).param(paramId) - number) -
Is there a way to simply set a value rather than add/subtract?
Find the difference between the current value and the value you want to set, then use the addParam method to add the difference (which may be negative).
I'm not 100% sure but I think this would be the correct form:
cur_par = $gameActors.actor(x1).param(x2);
set_par = x3;
diff_par = set_par - cur_par;
$gameActors.actor(x1).addParam(x2, diff_par);
where x1 is the actor ID you want to do it for, x2 is the index of the Parameter you want to work with (like 2 for ATK), and x3 is the value you want to set that Parameter to.
You could also shorten it to this if you're looking to do it all on one line:
$gameActors.actor(x1).addParam(x2, (x3 - ($gameActors.actor(x1).param(x2)))); -
You could also shorten it to this if you're looking to do it all on one line:
$gameActors.actor(x1).addParam(x2, (x3 - ($gameActors.actor(x1).param(x2))));
Thanks! I actually was realizing that I could do this as I was eating lunch. I originally had tried to simply use the event process to subtract 9999 from the parameter to reset it to 1, but then I found out that the game would return 1, but the parameter would actually store the negative number. -
First off I love that you threw down with this in the face of "can't be done". It's one of my favorite things that happens on established forums.You could also shorten it to this if you're looking to do it all on one line:
$gameActors.actor(x1).addParam(x2, (x3 - ($gameActors.actor(x1).param(x2))));
Though I admittedly also find it odd that we can't just get to that base parameter ("cur_par" if you will) and tweak it directly.
Now my question. Your exact solution here, but for Ex and Sp parameters. Possible? -
[necro]Guanto[/necro]
It is also hi-jacking. Please start your own thread.
[mod]Closing[/mod]