Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

$game_party.actors[]

Hallo :D

I'm trying to script (failing at it as well) a common event conditional branch. This common event checks to see which character is the lead character and ignores the rest of the characters once triggered. Like if the character steps on a trap it will only activate once that character is on the trap.

What I am trying to do.

Conditional Branch:
Code:
if $game_party.actors[0] == $game_party.actors[2]

Of course it's failing because the snippet is erroneous but I have no idea how to properly write it without screwing up the syntax.
 
I'm moving this topic because it belongs more to RGSS Support than to Script Request.

First of all, you don't need the "if" when you are using scripts in a conditional branch.
Your script doesn't work because you are saying:
"If the first party member is the same as the third party member then do something".

Since you can't have multiple instance of the same actor in your party, this piece of code can't work.
If you want to compare a party actor to an actor from your database, you need to use $game_actors[id].
So your line of code should be
Code:
$game_party.actors[0] == $game_actors[2]
 
o.o *twitch* I tried that with -if- infront of it! I'm so dumb!

It's not working for some reason. What I'm trying to pull off is if the third party member is in the first position *due to party arrange script* it would trigger the event.
 
Well, if the 3rd party member is in the first position, it would mean the third one became the first one, right?
You need to use the 2 variables like this:
$game_party.actors[index]; index is the position in the party. $game_party.actors[0] will return the first actor in the party
$game_actors[id]; id is the ID of the actors in the database. $game_actors[1] would return the Actor object for the first actor in the database (by default Aluxes in XP, Ralph in VX)

So
Code:
$game_party.actors[0] == $game_actors[2]
would mean: "if the first member in the party is the second actor in the database, then do something"

Do you get any RGSS Errors or does it simply do nothing?
 

Zeriab

Sponsor

The problem at hand has been solved elsewhere. (Thanks for being so helpful Dargor ^^)

For the curious a custom script change the solution to the problem:
Code:
$game_party.actors[$game_player.main_actor] == $game_actors[2]

*hugs*
- Zeriab
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top