tim-pohlmann / screeps-nooby-guide Goto Github PK
View Code? Open in Web Editor NEWCode used in my Screeps Nooby Guide video series
License: MIT License
Code used in my Screeps Nooby Guide video series
License: MIT License
Would it be possible to do a typescript conversion of your latest refactored code as another tutorial step?
so I was starting out your nooby guide part 2. When I ran the code I kept getting this in the console.
[6:31:02 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
[6:31:05 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
[6:31:08 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
[6:31:11 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
[6:31:14 PM][shard3]SyntaxError: Unexpected token && [main:4:36]
I don't know if its my code that I used from your tutorial so I will copy the code and put it here.
module.exports.loop = function () {
var creep = Game.creeps.Alaina;
if (creep.memory.working == true, &&_creep.carry.energy == 0) {
creep.memory.working = false;
}
else (creep.memory.working == false && creep.carry.energy == creep.carryCapacity) {
creep.memory.working = true;
}
if (creep.memory.working == true) {
if (creep.transfer(Game.spawns.Spawn1, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(Game.spawns.Spawn1);
}
}
else {
var source = creep.pos.findClosesetByPath (FIND_SOURCES);
if (creep.harvest(source) == ERR_NOT_IN_RANGE) {
creep.moveTo(source);
}
}
}
I do think its probably these &&
in the code.
I use sublime text 3
version 3.2.1
build 3207
When I run code to search for structures through Game and Rooms I'm not able to access their methods as I would expect.
To use your tower script as an example:
var towers = _.filter(Game.structures, (t) => t.structureType == STRUCTURE_TOWER);
console.log(towers) // array of objects as expected
console.log(towers[0]) // an object as expected
for (const tower in towers) {
console.log(tower); // Returns "0". What is this data type? It should be the object but isn't?
var target = tower.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
// if one is found...
if (target != undefined) {
// ...FIRE!
tower.attack(target);
}
}
tower.pos
and tower.attack
both return as undefined.
You can view my screeps repository for another example in the StructureManager.js script.
TypeError: Cannot read property 'harvester' of undefined at StructureSpawn.spawnCreepsIfNecessary (prototype.spawn:75:70) at Object.module.exports.loop (main:33:32) at __mainLoop:1:52
Starting a new spawn with your code. A harvester is spawned and begins collecting energy, but nothing else happens.
TypeError: Cannot read property 'harvester' of undefined
at StructureSpawn.spawnCreepsIfNecessary (prototype.spawn:75:70)
at Object.module.exports.loop (main:33:32)
at __mainLoop:1:52
Hey thPion,
I has seen the video's on the script, however, could you add a setup for the spawn that sets their memory based on certain variables?
This and building logic would would make it a good step closer to automation...
TypeError: Cannot read property 'find' of undefined
at Object.module.exports.loop (main:46:33)
at __mainLoop:1:52
at ContextifyScript.Script.runInContext (vm.js:35:29)
if(Game.spawns.Spawn1.energy >= 300){
//Game.spawns.Spawn1.createCreep's
if (!(name < 0)) {
console.log("Spawned new creep: " + name);
console.log("Spawned new builder: " + numberOfBuilders);
console.log("Spawned new upgrader: " + numberOfUpgraders);
console.log("Spawned new harvester: " + numberOfHarvesters);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.