Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // === robot.js ===
- import { BCAbstractRobot } from 'battlecode';
- import Test from './test.js';
- class MyRobot extends BCAbstractRobot {
- constructor() {
- super();
- this.log("asdf"); // the log function does work
- // Test.setConsoleLog(this.log); // way 1
- // console.log = this.log; // way 2
- }
- turn() {
- Test.testFunction("hello");
- return this.move(0, 1);
- }
- }
- // === test.js ===
- let consoleLog = undefined;
- function setConsoleLog(c) {
- consoleLog = c;
- }
- function testFunction(s) {
- // consoleLog(s); // way 1
- // console.log(s); // way 2
- }
- export default { testFunction, consoleLog, setConsoleLog };
Add Comment
Please, Sign In to add comment