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


1,Randomly generate events with planted spawner events(great flexibility for customization and auto-match player's level)
2,Randomly enter roguelike dungeon
3,Player can exit dungeon or back to town or choose to challenge BOSS at the end of each dungeon
4,Dungeon maps can be randomly generated by a third-party tool
Got locked out of the house yesterday... best friends who had the spare ghosted me. Locksmith had to literally drill thru the lock bc they couldn't pick it. Whole process took 4 hours and far too much money. And they have to come back next week bc they don't have the right cylinder, cause it's an old interlocking lock. I'm livid lol
 I’m probably going to regret this, but I need kobolds for my project and I’ve decided to sprite them myself. This is Attempt #1, front view only.

KoboldFront.gif
It's a shame that Selection Control will not be ported to MZ. I found a neat way of using it to enable ways for tanks to protect squishies. lol
Lately I have been taking a break from game and resource making so I won't get burnt out. But I am also interested in the Game Jams this site periodically holds. It'd be great if I knew when the next one, if any, is planned.

Forum statistics

Threads
115,354
Messages
1,089,224
Members
150,032
Latest member
bumblecree
Top