Sorry. I wasn't paying enough attention there. Yes, that's the issue.
If you want to define things that will be globally accessible—which you need since you're using the on… event attributes—then you should:
- Place your code in a script section (Twine 2: Story JavaScript; Twine 1: script-tagged passage).
- Attach them directly to window or, for the purposes of namespacing, to an object you've attached to window.
For example—attaching them directly to window:
window.allowDrop = function (ev) {
ev.preventDefault();
};
window.drag = function (ev) {
ev.dataTransfer.setData("text", ev.target.id);
};
window.drop = function (ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
Engine.play("entrance");
};
NOTE: You do not have to alter how you're calling them in your markup, since properties of window are treated as globals.