Hey Guys,
So basically I've been struggling for the last 3 weeks or so on accessing a certain variable called 'password' from an actor called 'ChipRider_PasswordSet' into an actor called 'ChipRider_SingleTicketButton'. (Weirdly named variable, I know.)
In the 'ChipRider_PasswordSet' actor, I have made a method which returns the variable 'password':
And I have called it in the actor 'ChipRider_SingleTicketButton' using this code:
But I keep getting a run-time error stating:
(Sorry, not sure whether I should submit that as code.)
Would anyone be able to help me fix this?
Thanks,
EIGNERT
public int getpassword()
{
return password;
}ChipRider_PasswordSet passwordset = (ChipRider_PasswordSet) getWorld().getObjects(ChipRider_PasswordSet.class).get(0);
int password = passwordset.getpassword();java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck(ArrayList.java:604) at java.util.ArrayList.get(ArrayList.java:382) at ChipRider_SingleTicketButton.act(ChipRider_SingleTicketButton.java:28) at greenfoot.core.Simulation.actActor(Simulation.java:568) at greenfoot.core.Simulation.runOneLoop(Simulation.java:526) at greenfoot.core.Simulation.runContent(Simulation.java:215) at greenfoot.core.Simulation.run(Simulation.java:205)
