Browse Source

Added hooks for rooms

tags/v0.1.0
Fen Dweller 6 years ago
parent
commit
1bc261531b
No known key found for this signature in database GPG Key ID: E80B35A6F11C3656
1 changed files with 19 additions and 1 deletions
  1. +19
    -1
      world.js

+ 19
- 1
world.js View File

@@ -23,6 +23,18 @@ function initRoomState(state) {
} }


function moveToRoom(dest, state) { function moveToRoom(dest, state) {
const room = world[dest];

console.log(room);

if (room.hooks) {
for (let hook of room.hooks) {
if (!hook(room, state)) {
return;
}
}
}

updateRoom(dest, state); updateRoom(dest, state);
} }


@@ -169,7 +181,13 @@ world = {
} }
] ]
} }
}
},
"hooks": [
(self, state) => {
print(["This is a test of the hooks"]);
return true;
}
]
}, },
"Locked Room": { "Locked Room": {
"id": "Locked Room", "id": "Locked Room",


Loading…
Cancel
Save