RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[VX] Any way to check for current # of party members and activate switch?

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 69
RMRK Junior
Basically, I'd like to know if there's any way to run a check and see if there are four/certain number of members currently in the party, and then throw a switch/fiddle with a variable.

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
You could either use a nested conditional branch that would look something like this :

Conditional Branch : Ralph is in the party
-Conditional Branch : Ulrika is in the party
--Conditional Branch : Bennett is in the party
---Conditional Branch : Ylva is in the party
----Control Switches : [0001] = On

Or use a script like this :

AcN = $game_actors[1]
A = $game_party.members.include?(AcN)
AcN = $game_actors[2]
B = $game_party.members.include?(AcN)
AcN = $game_actors[3]
C = $game_party.members.include?(AcN)
AcN = $game_actors[4]
D = $game_party.members.include?(AcN)
if A && B && C && D then
$game_switches[1] = true
end

Where the numbers displayed within '$game_actors[1], $game_actors[2], etc' are the index numbers of the actors you want to check for. As in, the number displayed on the Database window under the Actors tab. The script could probably be made better, but that's the basic idea and it should work.


EDIT : Oh, you're only wanting to check for a certain number of members? Oop, I guess your question came across wrong to me. You can try this for determining if you have four people in the party currently :

if $game_party.members.size == 4
(Do Stuff)
end
« Last Edit: June 08, 2011, 06:47:09 PM by Exhydra »

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

********
Furry Philosopher
Rep:
Level 94
Rawr?
2013 Best RPG Maker User (Creativity)Gold - GIAW 11 (Hard)Randomizer - GIAW 11Secret Santa 2013 ParticipantFor frequently finding and reporting spam and spam bots2012 Best RPG Maker User (Mapping)2012 Best RPG Maker User (Programming)Secret Santa 2012 ParticipantGold - GIAW 9Project of the Month winner for September 2008For taking a crack at the RMRK Wiki2011 Best RPG Maker User (Programming)2011 Best Veteran2011 Kindest Member2010 Best RPG Maker User (Story)2010 Best RPG Maker User (Technical)
It's as Exhydra says. Use a conditional branch and use the script command to check the $game_party.members.size.




**
Rep: +0/-0Level 69
RMRK Junior
I hate to look foolish here, but I've never messed around or learned how to use the scripting in VX or XP, so I've got no idea what I'm doing, really.

When I put

Code: [Select]
if $game_party.members.size == 4

in the script section of a conditional branch and then try it out, I get a SyntaxError. I'm sure I'm missing something simple, or just doing something wrong?
« Last Edit: June 09, 2011, 05:35:10 AM by Aviziel »

*
Rep:
Level 82
GIAW 14: 1st Place (Easy Mode)2013 Project of the Year2013 Best RPG Maker User (Programming)2013 Most Promising ProjectParticipant - GIAW 11Bronze - GIAW 10
Ah, not a problem. Use the Script button on the third tab of the Event Commands window. Now, if you wanted to turn the 5th Switch in your list on, you would put this into the Script window :

if $game_party.members.size == 4
  $game_switches[5] = true
end

Now if you wanted to set the 5th variable in your list, you would do the same thing but with a slightly different middle section :

if $game_party.members.size == 4
  $game_variables[5] = (Whatever Number or Data You Want)
end

Just change the [5] to whatever index of Switch or Variable that you want.

UPDATED 05-29-14


IS YOUR PROJECT OPTIMIZED?
UPDATED 07/04/15 - v2.5

RPG MAKER TOOLBOX
UPDATED 07/04/15 - v1.5

**
Rep: +0/-0Level 69
RMRK Junior
Thanks so much, Exhydra. Exactly what I needed. :D

*
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Alternatively, you could simply make a variable equal to the number of members in the party. It's in no way better, just something I realised. Also that way you could simply check the variable itself rather than the global.
Code: [Select]
$game_variables[VARIABLE_ID] = $game_party.members.size
Will make variable VARIABLE_ID equal to the number of members in the party.
it's like a metaphor or something i don't know

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Best RPG Maker User (Scripting)2010 Best Use Of Avatar And Signature Space
Zylos was also right in that you could use the script option of Conditional Branch as well. You would need to remove the if though and just put:

Code: [Select]
$game_members.size == 4

It might be useful in the future so you won't have to get the code for every event command. Pacman's way would be good for that as well.

**
Rep:
Level 83
Project of the Month winner for March 2010
This is how I did it, which is kind of what you do when you don’t know anything about scripting :V

@>Control Variables: [0001:Party_Members] = Party Members
@>Conditional Branch: Variable [0001:Party_Members] == 4
    @>Control Switches: [0001:Switch] = ON
Current Project: