def screen_x
# Return after calculating x-coordinate by order of members in party
if self.index != nil
return self.index == 0 ? 75 : self.index == 1 ? 165 : self.index == 2 ? 255 : self.index == 3 ? 345 : 0
else
return 0
end
end
I think that's what Moo meant but this wasn't actually tested to be properly alligned like you want and probably isn't. The way I did it though is an advanced way of using conditional branches. Here's an explanation on advanced "if" branches and a simpler explanation below it.
condition ? True : False
Condition is what you're checking. It could be something like "self.id != 0" or "@actors[index] != nil".
True is what'll happen if condition returns true.
False is what'll happen if condition returns false.
Basically what I did in the first code box I posted is that I used the advanced "if" branch to avoid a long, drawn out method that might lag the battles to no end. Lag in a battle is the one of the quickest ways to tick off a player.
This is what you can do if you didn't understand the above explanation.
def screen_x
# Return after calculating x-coordinate by order of members in party
if self.index != nil
if self.index == 0
return 50
if self.index == 1
return 40
if self.index == 2
return 30
if self.index == 3
return 20
else
return 0
end
end
If you're still unclear on anything, don't hesitate to ask.
@moo
Why in the world would you use $game_actors.party.actors when self.index means the same thing? After all, you would have to use $game_actor[index].screen_x/y/z to call the method anyways. The reason self works is because self is refering to the actor's index you used when you called the method.