Status
Not open for further replies.

Kaza

Villager
Member
Joined
Jan 12, 2016
Messages
22
Reaction score
2
First Language
English
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?
 

waynee95

Inactive
Veteran
Joined
Jul 2, 2016
Messages
697
Reaction score
623
First Language
German
Primarily Uses
RMMV
When you wanna add to a parameter you need to use
Code:
$gameActors.actor(x).addParam(paramId, value);
 

Kaza

Villager
Member
Joined
Jan 12, 2016
Messages
22
Reaction score
2
First Language
English
Is there a way to simply set a value rather than add/subtract?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,147
Reaction score
10,708
First Language
Czech
Primarily Uses
RMMV
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.
 

waynee95

Inactive
Veteran
Joined
Jul 2, 2016
Messages
697
Reaction score
623
First Language
German
Primarily Uses
RMMV
@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.
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,147
Reaction score
10,708
First Language
Czech
Primarily Uses
RMMV
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)
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,115
Reaction score
5,816
First Language
English
Primarily Uses
RMVXA
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))));
 

Kaza

Villager
Member
Joined
Jan 12, 2016
Messages
22
Reaction score
2
First Language
English
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.
 

Guanto

Auteur
Veteran
Joined
Jul 18, 2018
Messages
111
Reaction score
10
First Language
English
Primarily Uses
RMMV
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))));
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.

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?
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,512
Reaction score
11,998
First Language
English
Primarily Uses
RMVXA
[necro]Guanto[/necro]
It is also hi-jacking. Please start your own thread.

[mod]Closing[/mod]
 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Doing RPG Maker News for 26th September 2021

Well... it's been a while since I was last here :kaoswt: I don't want to say I'm officially 'back' yet, but I've recently started working with RM again, so I might become active here again :kaohi:
Mmmm I love Coca Cola candy! :kaoluv:
aaaand my power is out. I sometimes think that I'm cursed.

Forum statistics

Threads
115,386
Messages
1,089,502
Members
150,121
Latest member
Crossboi
Top