alexa-samples / skill-sample-nodejs-adventure-game

This tool provides an easy to use front-end that allows developers to instantly deploy code for your story, or use the generated code as a starting point for more complex projects.
Apache License 2.0
510 stars 218 forks source link

Creating an object #7

Open oliverbhull opened 7 years ago

oliverbhull commented 7 years ago

Im trying to create a "key" object that is behind door number one. And is required to open door two, however every time i save and upload the file, it regenerates and the code I just wrote is lost.

Any advice on how I should go about doing this/why the code is being removed?

UXVirtual commented 7 years ago

Hey @oliverbhull which file are you trying to modify? It seems that certain files are regenerated by the system (mainly config.json, intentSchema.json, scenes.json and utterances.txt). I'm looking at adding similar functionality myself.

oliverbhull commented 7 years ago

In intentHandlers_default.js I was able to create a session.attributes.key and set it equal to 0. If GetKetIntent was called session.attributes key = 1 and added a line to the UseKeyIntent that if key = 1 the door opens else an error message is returned

UXVirtual commented 7 years ago

Interesting approach storing the items as game flags in the session attributes. I spent several hours try to retrofit items into the editor without much luck as it's tricky to see how riot passes around the data loaded from the scenes.json file.

Doesn't seem like intentHandlers_default.js gets regenerated so your approach should in theory work. Unless you're modifying GetKeyIntent and UseKeyIntent that was generated in intentHandlers_generated?

There are gulp tasks available to just zip and upload the files to AWS Lambda without regenerating them, so you might want to try adding the following lines to gulp-tasks/_default.js:

gulp.task('upload', function () {
  runSequence('upload');
});

Running gulp upload from the Terminal while in the root folder of the project should upload the files.

UXVirtual commented 7 years ago

If you're interested I've implemented extra functionality to allow scene flags to be set on entry or exit of a scene. This can allow the user to pick up items (e.g. keys) which can then be used to access other scenes (e.g. opening locked doors). You could use the same system to create combination lock door puzzles where the user must flip switches in the right combination in order to open a door.

It has the GUI to support this in the editor and generates the correct JSON and other files to upload. I still need to add support for an alternate scene description if the user has specific scene flags set (e.g. not showing that there is a key in the room if the user has already picked up the key).

You can see the progress here on my feature branch.

rejamison commented 7 years ago

Just jumping in to confirm @HAZARDU5's comments. We're generating the skill assets so you can't really modify them directly. Looking forward to see how your feature branch progresses, these sound like great additions!

UXVirtual commented 7 years ago

I've now implemented alternate scene descriptions and fixed a few bugs which caused it to show the original scene description when the "repeat scene" or "go back" utterance. The session flags also now reset when using the "reset skill" utterance. There is also in-line help provided for most of the new fields in the edit scene panel.

I have an example game on my examples/items branch which showcases these new features.