Hi,
I'm trying my hand at making a game based on ERC 1155 tokens, I want to move an array of spaceships from one planet to another, when I pass just one element, it works, but when I pass an array of 2 or more elements, it gives the following error:
"transact to Ships.moveShipsToSpace errored: VM error: revert.
revert
The transaction has been reverted to the initial state."
This is my function:
function moveShipsToSpace(uint[] memory ships, uint16 fromSpace, uint16 toSpace) public{
for(uint8 i=0; i<ships.length; i++) {
// Move the last element into the place to delete
whichShipsAtSpace[msg.sender][fromSpace][i] = whichShipsAtSpace[msg.sender][fromSpace][whichShipsAtSpace[msg.sender][fromSpace].length - 1];
// Delete
whichShipsAtSpace[msg.sender][fromSpace].pop();
// Insert in new location
whichShipsAtSpace[msg.sender][toSpace].push(shipsArray(ships[i]));
}
}