level13 icon indicating copy to clipboard operation
level13 copied to clipboard

[JS Error] TypeError: Cannot read properties of undefined (reading 'get')

Open davidarcher opened this issue 2 years ago • 3 comments

Details: Tried turning on autoplay on a fairly new game (one camp, 4 followers, very little explored).

Seed: 7361 Position: 13.0.0 (inCamp: false) Stacktrace: TypeError: Cannot read properties of undefined (reading 'get') at constructor.move (https://nroutasuo.github.io/level13/src/game/systems/AutoPlaySystem.js?v=0.5.1:291:43) at constructor.updateExploring (https://nroutasuo.github.io/level13/src/game/systems/AutoPlaySystem.js?v=0.5.1:159:41) at constructor.update (https://nroutasuo.github.io/level13/src/game/systems/AutoPlaySystem.js?v=0.5.1:111:41) at constructor.update (https://nroutasuo.github.io/level13/lib/ash/ash.min.js?v=0.5.1:14:15165) at constructor.update (https://nroutasuo.github.io/level13/src/game/systems/GameManager.js?v=0.5.1:103:16) at r.execute (https://nroutasuo.github.io/level13/lib/ash/ash.min.js?v=0.5.1:14:4611) at n.Signal.dispatch (https://nroutasuo.github.io/level13/lib/ash/ash.min.js?v=0.5.1:14:6738) at constructor.tick (https://nroutasuo.github.io/level13/lib/brejep/tickprovider.js?v=0.5.1:48:29)

The function where the error originates has a guard clause that looks suspect. It checks to make sure directions is non-null but doesn't check if directions.sector is non-null.

in AutoPlaySystem.js:

move: function () {
	var autoPlayComponent = this.autoPlayNodes.head.autoPlay;
	let directions = GameGlobals.autoPlayHelper.getMoveSector(autoPlayComponent.explorationVO);
	
	if (!directions || directions.sector)
		return false;

	var playerPosition = GameGlobals.playerActionFunctions.playerPositionNodes.head.position;
	var sectorPosition = directions.sector.get(PositionComponent);
	if (playerPosition.level !== sectorPosition.level || playerPosition.sectorId() !== sectorPosition.sectorId()) {
		this.logStep("move to " + sectorPosition + " (" + directions.type + ")");
		GameGlobals.playerHelper.moveTo(sectorPosition.level, sectorPosition.sectorX, sectorPosition.sectorY, false);
		return true;
	}

	return false;
},

davidarcher avatar Jul 11 '23 18:07 davidarcher

Thanks for the report. AutoPlay is an old testing tool that I haven't updated in awhile, not surprised it doesn't work. How did you even turn it on live?

nroutasuo avatar Jul 12 '23 06:07 nroutasuo

How did you even turn it on live?

Breakpoint in chrome dev tools to override the config.js values at startup:

config.isCheatsEnabled = config.isDebugOutputEnabled = config.isDebugVersion = true

Then console commands to activate autoplay:

window.app.cheat("scavenge") window.app.cheat("autoplay camp 2")

davidarcher avatar Jul 12 '23 15:07 davidarcher

Thank you. I might try to close that loophole one day but for the time being, use at your own risk :)

nroutasuo avatar Jul 12 '23 15:07 nroutasuo