As I believe TheMadExile can attest, I have absolutely NO experience with JavaScript, so I was wanting to do this as a passage, because I can already see how the code should be shaped in Twine/Sugarcube.
I want to have some code that will check to see if certain variables are true (equipped inventory items in this case), and return a variable for the passage. This way, I can have events which will be able to check and describe equipped items, and possible react to them, without having a huge pile of If/Else statements clumping up EVERY SINGLE TIME I want to pull this off.
I wouldn't worry too much about a few extra If Trees, but since I will almost certainly add more equipable items as I work, it would be nice to have a single function somewhere to add them to, instead of having to go hunting through every passage that does a clothes check.
EDIT: Is there some perfectly simple method of doing this that I'm completely missing?
Comments
1. You can use a passage to store commonly executed code but unfortunately a passage does not return a value, you can get around this by using a variable to store the result of that code instead.
notes:
. The following is an example of how to use a variable to return the result of code stored in a secondary passage, it is not an example of how to check the contents of an array.
. SugarCube 1.x does not have temporary variables so the example with use the setup object to store the result in, this is to stop the result from being stored in History.
1a. Use something like the following to call your Function Passage:
1b. An example Check Some Condition passage
2. A much better way to do the above is to create a <<widget>> because they support the formal passing of parameters, although they also don't return a value so you will need to use the variable updating technique here as well.
If you decide to use a <<widget>> instead I or another person can create you an example.
Actually, this is exactly what I was looking for. Thank you both!
...I'm going to go hide my head under a pillow now, for not spotting these before...
Also, yes, sorry, I'll be more specific about the version numbers going forward.