Skip to content

Commit

Permalink
Fixed issues in requirements and findValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ville Talonpoika committed Feb 27, 2016
1 parent ef11fde commit dd50a85
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ The format:
objectName,id,objectName,id,objectName...
```

If the path contains arrays, give the path to that array as the first parameter, then the array index as the next parameter, and then the path inside that object as the third parameter and so forth. An example that picks a choice from another scene:
If the path contains arrays, give the path to that array as the first parameter, then the array index as the next parameter, and then the path inside that object as the third parameter and so forth. If there are multiple arrays immediately inside each other, use an empty `objectName` (for example, `inventories,0,,1,value` refers to the item `1` in inventory `0`). An example that picks a choice from another scene:
```
scenes,1,choices,2,parsedText
```
Expand Down
2 changes: 1 addition & 1 deletion novel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1034,7 +1034,7 @@ SceneManager = (function() {
reqs.push(inventoryManager.checkRequirements(requirements));
}
if (choice.requirement !== void 0) {
reqs.push(inventoryManager.parseIfStatement(choice.requirement));
reqs.push(parser.parseStatement(choice.requirement));
}
success = true;
for (k = 0, len = reqs.length; k < len; k++) {
Expand Down
4 changes: 2 additions & 2 deletions novel.min.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions novel/novel.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
"setItem": "!introductionSeen,1",
"nextScene": "road"
},
{
"text": "Heyoo!!!",
"requirement": "inv.stick==0",
"nextScene": "road"
},
{
"name": "pickastick",
"addItem": "stick,1",
Expand Down Expand Up @@ -120,10 +125,10 @@
]
},
{
"text": "Increase sandwiches by 1",
"text": "Increase sandwiches by 1 in inventory 0",
"requirement": "inv.sandwich<10",
"increaseValue": [
{"path": "inventory,1,count", "value": 1}
{"path": "inventories,0,,1,value", "value": 1}
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "novel-js",
"version": "0.4.3",
"version": "0.4.4",
"description": "A lightweight JavaScript text game engine",
"author": "Ville Talonpoika <[email protected]> (http://nanof.us)",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions src/SceneManager.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ class SceneManager
reqs = []
if choice.itemRequirement != undefined
requirements = parser.parseItems choice.itemRequirement
reqs.push inventoryManager.checkRequirements(requirements)
reqs.push inventoryManager.checkRequirements requirements
if choice.requirement != undefined
reqs.push inventoryManager.parseIfStatement choice.requirement
reqs.push parser.parseStatement choice.requirement
success = true
for r in reqs
if r == false
Expand Down

0 comments on commit dd50a85

Please sign in to comment.