Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
davidarcher opened this issue Jul 11, 2023 · 3 comments
Labels

Comments

@davidarcher
Copy link

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;
},
@nroutasuo
Copy link
Owner

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 nroutasuo added the bug label Jul 12, 2023
@davidarcher
Copy link
Author

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")

@nroutasuo
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants