实体具有嵌套数组结构的结构

时间:2019-08-11 16:22:21

标签: solidity

我目前正在制作一款稳定可靠的游戏 我想将我的世界数据存储如下:

contract WorldDB {
    struct ObjectData {
        uint16 objectId;
        uint256[] scriptIds;
    }
    struct MapData {
        address owner;
        ObjectData[] objects;
    }

    mapping(uint256 => MapData) private worlds;
    uint256 private nextId;

    function createWorld(MapData memory md) public returns(uint256) {
        uint256 key = nextId ++;

        // This line occurs the error
        worlds[key] = MapData({
            owner: msg.sender,
            objects: new ObjectData[](0)
        });

        return key;
    }
}

但是我遇到了错误

UnimplementedFeatureError: Copying of type struct WorldDB.ObjectData memory[] memory to storage not yet supported.

我该如何解决?

0 个答案:

没有答案