screeps

How do I interface with extern variables from Cheerp/js?

烂漫一生 提交于 2020-06-17 08:03:08
问题 Cheerp is a C++ to js/wasm transpiler. Screeps is a programming videogame. How do I read in the Game.time variable from my transpiled C++ code? (in screeps) #include <cheerp/client.h> #include <iostream> using namespace std; namespace client { class Game : public Object { public: static volatile double time; }; extern volatile Game &Game; } void webMain() { cout << __TIME__ << ": The current time is: " << client::Game.time << endl; } I have tried any number of variations on: extern , volatile

screeps: conditions won't work - clueless

半腔热情 提交于 2019-12-25 03:36:07
问题 So i have been trying this to automatically spawn Creeps in percentage to total living creeps. however when i run this, it just keeps on spawning harvesters, completely ignoring the conditions even though console.log returns the expected results . and now i'm clueless about what is going wrong //creepManager.creations() == counts total creeps and spawns creeps in function of total var spawnCreep = require('spawnCreep'); var counter = require('counter'); exports.creations=function(){ if(

Extend Source prototype to have a memory object

这一生的挚爱 提交于 2019-12-20 14:12:03
问题 I want to store some information about energy sources that I am harvesting. Ideally I would use mySource.memory.taken but Source does not have a memory property. I could implement something like this: Source.prototype.memory = function() { return Memory.sources[this.id]; } But can I implement the same thing as a property like other game objects rather than a method? Or is there a better approach than this? 回答1: Yes, you can. You have to implement Getter/Setter interface using Object

Game Screeps - IDE Integration

可紊 提交于 2019-12-10 08:21:10
问题 I'm playing Screeps (http://screeps.com/) Simulation Room mode. I've been testing some scripts and I don't want to only save them to my local browser, I want to use an IDE to develop the code and push it to my github account. Is it possible to do it? 回答1: One way is to set up "sync from repository" under "GitHub Integration" in your Screeps "Account Settings". Once this is done any IDE that pushes to that repository will be autmatically pulled into your account and executed. This will affect

Extend Source prototype to have a memory object

坚强是说给别人听的谎言 提交于 2019-12-03 04:16:41
I want to store some information about energy sources that I am harvesting. Ideally I would use mySource.memory.taken but Source does not have a memory property. I could implement something like this: Source.prototype.memory = function() { return Memory.sources[this.id]; } But can I implement the same thing as a property like other game objects rather than a method? Or is there a better approach than this? Yes, you can. You have to implement Getter/Setter interface using Object.defineProperty . Here is the complete solution based on the existing game code: Object.defineProperty(Source

Screeps score/modules got reset

删除回忆录丶 提交于 2019-12-02 15:44:56
问题 Yesterday I had a score of 1800 on the first map and now there is no more score. How could it be that this score was deleted? Furthermore, my scripts/modules were also deleted (I luckily saved them locally). Does it depend on cookies or something; what happened? 回答1: In Simulation Room, your modules and scores are stored in browser localStorage . You may be using another browser or another anonymous browser session. 回答2: I had the same thing when I went to http://www.screeps.com instead of

Screeps score/modules got reset

随声附和 提交于 2019-12-02 11:51:13
Yesterday I had a score of 1800 on the first map and now there is no more score. How could it be that this score was deleted? Furthermore, my scripts/modules were also deleted (I luckily saved them locally). Does it depend on cookies or something; what happened? In Simulation Room, your modules and scores are stored in browser localStorage . You may be using another browser or another anonymous browser session. I had the same thing when I went to http://www.screeps.com instead of http://screeps.com , notice the www part. these 2 store your data in different locations. 来源: https://stackoverflow