boulops1

Veteran
Veteran
Joined
Dec 6, 2020
Messages
64
Reaction score
1
First Language
english
Primarily Uses
RMMV
Hey, I would like to know how to select the receiver of an item using script calls.

what im trying to do is if an item is used on a specific party member it immediate opens a menu for that party member.


my current script looks like this;


$gameParty.setMenuActor($gameActors._data[1]);

SceneManager.push(Scene_StatAllocation);


instead of "data[1])" is there something I can put to push the scene on whoever the item is used on? right now it will only work with the first party member.


Using RPG Maker MV,
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
913
Reaction score
576
First Language
English
Primarily Uses
RMMV
Scene_Item has a function this.user() which returns the party member an item has been used on. If you're using the item in battle, I'm not sure that'll work, but you should be able to use $gameParty.setMenuActor(SceneManager._scene.user()) from the item menu and it should work.
 

boulops1

Veteran
Veteran
Joined
Dec 6, 2020
Messages
64
Reaction score
1
First Language
english
Primarily Uses
RMMV
@ramza
oh very interesting..

1614105969412.png


this is what i currently have and then i repeat it with every potential character only changing "(@gameActors._data[1]);

changing the 1 to whatever the corresponding hero number is.. let me tell you its a lot of conditional branches when you have 15 characters haha.

to add yes this item is for use only outside of battle

are you saying that code could be used to simplify it so i dont have to keep creating conditional branches for each hero?

if yes id just then replace the first top portion of the script to what you have

"$gameParty.setMenuActor(SceneManager._scene.user())"

and it should work for any character its used on?


thanks a lot by the way!!!
 
Last edited:

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
913
Reaction score
576
First Language
English
Primarily Uses
RMMV
@ramza
oh very interesting..

View attachment 180535


this is what i currently have and then i repeat it with every potential character only changing "(@gameActors._data[1]);

changing the 1 to whatever the corresponding hero number is.. let me tell you its a lot of conditional branches when you have 15 characters haha.

to add yes this item is for use only outside of battle

are you saying that code could be used to simplify it so i dont have to keep creating conditional branches for each hero?

if yes id just then replace the first top portion of the script to what you have

"$gameParty.setMenuActor(SceneManager._scene.user())"

and it should work for any character its used on?


thanks a lot by the way!!!
I believe that should work, yes.
An interesting thing to note is that this doesn't work in RMMZ the same way. The 'user' in RMMZ is determined by finding the party member with the highest pharmacological sparam (user.pha), and if they all have the same it will default to the first actor it checks, generally the party leader.

While you state in the topic title that this is for MV, and it should work as is, if you changed it to SceneManager._scene.itemTargetActors()[0] instead, it would be compatible with MZ. The above function actually returns an array of all the targets of an item, so with this one item it should only be one target, so we only want element 0 in the array, [0].
 

boulops1

Veteran
Veteran
Joined
Dec 6, 2020
Messages
64
Reaction score
1
First Language
english
Primarily Uses
RMMV
@ramza

alright so i tried it and for some reason it doesnt push to the characters attribute menu it just leaves and starts the message loop. here's what i have.

1614280682717.png

let me know where im going wrong with this.



thanks
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
913
Reaction score
576
First Language
English
Primarily Uses
RMMV
Since you're calling the script from a common event, the script I gave won't work at all. The current scene at that point is no longer the item menu, so the SceneManager._scene.user() code wouldn't have anything so it'd be undefined.

You'd need to have some sort of use eval that could be called as soon as the item is used and set the user into a variable or something so the common event could reuse it later.

You could set it as an hp recovery item, and in the formula do something like $gameVariables.setValue(x, SceneManager._scene.user()) to store the user in variable x, and then use that variable in the common event using $gameParty.setMenuActor($gameVariables.value(x))
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

TeamEdel.png

Realized halfway through drawing this that the female protagonist's party is growing bigger. :guffaw:
oddly enough, at this point... 3 major things have kept me from porting my project to MZ... animations, and that's mainly because they don't match the artstyle of my game. and two... I NEED a YED Sideview Battler like plugin and I have yet to see one. 3rd, I don't have the money for all the stuff I need plugin wise. and I already have it on MV... lol
Generally speaking, would there be interest in some form of tutorial regarding general project management? I see there are a lot of indie/self-taught devs around here, and looking back i feel like there was a lack of resources on how to properly manage a project that might take several years to finish
I've been working on some ABS team A.I. for 'A New Suburbia', and thought I'd share.

I'm generally quite please although the AI is a little grenade heavy right now :rolleyes: - Sneaking and stalking next! Please excuse the terrible map... it was just for ease of viewing!
Voting for the second round of the Map Madness Tournament is now live! Vote for your favorite in each matchup! https://forums.rpgmakerweb.com/index.php?forums/map-madness-2021-polls.187/

Forum statistics

Threads
110,581
Messages
1,054,398
Members
143,699
Latest member
BigChungus21
Top