ThePix / QuestJS

A major re-write of Quest that is written in JavaScript and will run in the browser.
MIT License
74 stars 16 forks source link

Q5 to QJS Convertor: Errors while reading 'hasExit' #93

Open Zanderkat opened 1 year ago

Zanderkat commented 1 year ago

The following error occurs after game conversion:

_io.js:684 Uncaught TypeError: Cannot read properties of undefined (reading 'hasExit') at endTurnUI (_io.js:684:27) at io.init (_io.js:1689:3) at HTMLScriptElement.scriptOnLoad (_settings.js:213:10) endTurnUI @ _io.js:684 io.init @ _io.js:1689 scriptOnLoad @ _settings.js:213 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 load (async)
scriptOnLoad @ _settings.js:221 loadScript @ _settings.js:190 writeScript @ _settings.js:241 myScript.onload @ index.html:27 load (async)
(anonymous) @ index.html:26

In the _io.js file, it seems to be specifically complaining about the following line (684):

if (currentLocation.hasExit(exit.name, {excludeScenery:true}) || exit.type === 'nocmd')

Though this is probably not just a convertor-specific issue, since it is not in a file I have edited after conversion. I suppose the title can be changed if that is the case!

ThePix commented 1 year ago

This could be a tricky one, as the error does not give much to go on.

Are you using the latest official release, or the more recent upload to GitHub? I would recommend the latter, if only because then it is the same as I am using. I say this because the error on the first line looks to me to be line 687.

Also, in another issue you say player is not set. Have you resolved that here? If player is not set, currentLocation will not get set, which would give that error. This is a longshot, but worth checking.

I will upload a version of _io.js that will catch currentLocation not being set, which may then give a more helpful error message.

None of this is going to fix it. Would you be happy to upload the game as a zip file? Or better still cut out as much as you can from the files and upload that.

ThePix commented 1 year ago

I have uploaded a slightly modified version of the convertor following your point about verbs. Can you make sure you have the most recent version of all the files, by going to this page: https://github.com/ThePix/QuestJS

Click on Code and download as a ZIP file. Then copy across all the files from the library. _io.js has just been updated so will definitely different, others might be given the line numbers you are seeing.

That may resolve some, but not all o the issues. But if you could then zip up your game and upload it to here, I could take a look. It will not be for a few days, unfortunately, as I am away over the weekend.

Zanderkat commented 1 year ago

No worries, I was away for some time myself. As for the issue, I've followed your instructions and with the updated files. This issue only appears when the player object cannot be found, and the new error helpfully reads as such:

ERROR: currentLocation not set (nor is player)

I can still upload my game if you like, but I think this issue is only occurring because the player object is missing (due to other bugs in the data.js file). When I delete the non-player code in the file, the player is found and the currentLocation error does not show up.