我对 Screeps 比较陌生,我一直在努力构建自己的基本 AI 系统。但是,我在最初的测试中遇到了障碍。我有一个脚本可以确定要执行的工作,然后小兵请求可用的工作。我已经能够将 Job 对象存储到cree 的内存中,但我以后不记得了。
我可以在“内存”选项卡中确认所有信息都在那里,并且正确存储,但是当我尝试访问它时,我只会得到undefined
.
我使用这个模板函数创建我的工作:
jobFactory: function()
{
// Generates a blank JOB template
var job = {
'id': null, // id of job will double as id of the target
(ie. a energy source id)
'type': null, // used to classify job tickets to some extent
'spots': 0, // total # of creeps that can be assigned to this
'workers': [] // current # and IDs of creeps assigned
};
return job;
},
然后我可以很好地存储它:
creep.memory.job = job;
我尝试访问它的方式是:
console.log("Creep job: " + creep.memory.job);
我已经将它与游戏教程进行了比较,对于我的生活,我似乎无法弄清楚为什么我无法从内存中访问该对象。