Hello everyone!
I recently made a Coin Pickup system with 2 players in mind.
The way it works is the following:
- Coin Appears
- Coin Checks in a parrallel process if 1 of the 2 specified events runs on it
- Event continues depending who picked it up with Self-Switches
Here is the code:
Here is the error I get with it:
Can someone help me please? If you have any questions, I'll be happy to specify! Thank you!
I recently made a Coin Pickup system with 2 players in mind.
The way it works is the following:
- Coin Appears
- Coin Checks in a parrallel process if 1 of the 2 specified events runs on it
- Event continues depending who picked it up with Self-Switches
Here is the code:
Code:
var coinEvents = $gameMap.events().filter(function(event) { return event.event().name === 'coin' && !event._erased; });
var player1Event = $gameMap.events().filter(function(event) { return event.eventId() === 2; })[0];
var player2Event = $gameMap.events().filter(function(event) { return event.eventId() === 3; })[0];
coinEvents.forEach(function(coin) {
if (player1Event.x === coin.x && player1Event.y === coin.y) {
$gameSelfSwitches.setValue([$gameMap.mapId(), coin.eventId(), 'A'], true);
// code for scoring here
}
if (player2Event.x === coin.x && player2Event.y === coin.y) {
$gameSelfSwitches.setValue([$gameMap.mapId(), coin.eventId(), 'B'], true);
}
}
Here is the error I get with it:
Code:
SyntaxError: Unexpected end of input {stack: (...), message: "Unexpected end of input"}
Can someone help me please? If you have any questions, I'll be happy to specify! Thank you!