Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Adel chickenfoot88

View GitHub Profile
View role.builder.js
var roleBuilder = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.memory.building && creep.carry.energy == 0) {
creep.memory.building = false;
creep.say('🔄 harvest');
}
if(!creep.memory.building && creep.carry.energy == creep.carryCapacity) {
View role.upgrader.js
var roleUpgrader = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.carry.energy == 0) {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}
View role.harvester.js
var roleHarvester = {
/** @param {Creep} creep **/
run: function(creep) {
if(creep.carry.energy < creep.carryCapacity) {
var sources = creep.room.find(FIND_SOURCES);
if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0], {visualizePathStyle: {stroke: '#ffaa00'}});
}
}
View screeps.js
// create creep
Game.spawns['Spawn1'].spawnCreep( [WORK, CARRY, MOVE], 'Harvester1' );
Game.spawns['Spawn1'].spawnCreep( [WORK, CARRY, MOVE], 'Upgrader1' );
Game.spawns['Spawn1'].spawnCreep( [WORK, CARRY, MOVE], 'Builder1',
{ memory: { role: 'builder' } } );
// creeps memories
Game.creeps['Harvester1'].memory.role = 'harvester';
Game.creeps['Upgrader1'].memory.role = 'upgrader';
View axios-interceptors-refresh-token.js
let isRefreshing = false;
let refreshSubscribers = [];
const instance = axios.create({
baseURL: Config.API_URL,
});
instance.interceptors.response.use(response => {
return response;
}, error => {
@chickenfoot88
chickenfoot88 / index.html
Created Oct 29, 2018
Random character transition
View index.html
<div id="messenger"></div>
View hide on click
$(document).mouseup(function (e) {
var menu = $('.side-menu');
if (e.target !== menu[0] && !menu.has(e.target).length) {
hideSideMenu();
};
});
View math random
function mtRand(min, max) {
return Math.floor(Math.random() * (max - min + 1));
}
@chickenfoot88
chickenfoot88 / open-w-atom.reg
Created Apr 16, 2018 — forked from kyle-ilantzis/open-w-atom.reg
Adds 'Open in Atom' to context menu in Windows Explorer.
View open-w-atom.reg
Windows Registry Editor Version 5.00
;
; Adds 'Open in Atom' to context menu (when you right click) in Windows Explorer.
;
; Based on https://github.com/Zren/atom-windows-context-menu. It didn't work
; https://github.com/Zren/atom-windows-context-menu/issues/1.
;
; Save this file to disk with a .reg extension. Replace C:\\Atom\\atom.exe with
; the path to the atom executable on your machine.
@chickenfoot88
chickenfoot88 / index.js
Last active Apr 8, 2018
Simple JS timer
View index.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Timer Lesson</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
You can’t perform that action at this time.