Here is my story javascript(it's the tutorial script):
window.getInv = function() {
return state.active.variables.inventory;
}
macros.initInv = {
handler: function(place, macroName, params, parser) {
state.active.variables.inventory = [];
}
};
macros.addToInv = {
handler: function(place, macroName, params, parser) {
if (params.length == 0) {
throwError(place, "<<" + macroName + ">>: no parameters given");
return;
}
if (state.active.variables.inventory.indexOf(params[0]) == -1) {
state.active.variables.inventory.push(params[0]);
}
}
};
macros.removeFromInv = {
handler: function(place, macroName, params, parser) {
if (params.length == 0) {
throwError(place, "<<" + macroName + ">>: no parameters given");
return;
}
var index = state.active.variables.inventory.indexOf(params[0]);
if (index != -1) {
state.active.variables.inventory.splice(index, 1);
}
}
};
macros.inv = {
handler: function(place, macroName, params, parser) {
if (state.active.variables.inventory.length == 0) {
new Wikifier(place, 'nothing');
} else {
new Wikifier(place, state.active.variables.inventory.join(','));
}
}
};
macros.invWithLinks = {
handler: function(place, macroName, params, parser) {
if (state.active.variables.inventory.length == 0) {
new Wikifier(place, 'nothing');
} else {
new Wikifier(place, '
' + state.active.variables.inventory.join('<br>
') + '');
}
}
};
macros.emptyInv = {
handler: function(place, macroName, params, parser) {
state.active.variables.inventory = []
}
};
StoryInit: <<initinv>>
Backpack: <<if $inventory.length == 0>>You are have nothing.<<else>>You are carrying:
<<inv>> <<endif>>
What do I do if I want to have <<usagethings>> that drop things into certain inventories? For example, on the Sidebar is a
Journal link, that goes to a passage w/:
Entries,
Photos,
Evidence &
Objectives on it, I want to be able to have the note player found go into the
Evidence inv instead of the
Backpack when picked up &can I label them like: <<addToInv1>> or <<addToInv2>>? Is it possible to get this without re-writing/pasting the macros for each individual inventory?
Another inventory-related question: I have gotten the "add an inventory" tutorial script to work, but how do I make the listing drop down another line for every item? Instead of eventually developing into a long block of text? I've tried adding bullet pts. to the <<addToInv "a thing">> but after the first object added, it starts showing up as an actual asterisk, regardless of whether between "" when I want mult. words or single word additions or not.
I keep ending up w/ this:
(e.g. Backpack:
-spork, spoon)
When I want it to look like this:
(e.g. Backpack:
-spork
-spoon
-etcetera)
Comments
1. Have the existing system modified so that you can pass the name of an array variable to the macros, and the macros with use that array instead of the $inventory one.
2. Have additional sets of macros created, one for each type container you want to be able to store things in.
3. Use a different Inventory system.
re: listing drop down another line for every item
Change the your inv macro to something like the following, it replaces the coma with a new-line character.