iftechfoundation / twine-cookbook

Twine Cookbook
131 stars 31 forks source link

Emulating ChoiceScript's fairmath system #8

Closed klembot closed 6 years ago

klembot commented 7 years ago

See http://choicescriptdev.wikia.com/wiki/Arithmetic_operators#Fairmath.

greyelf commented 6 years ago

I believe using the generic arithmetic terms addition and subtraction may confuse some end-users as they have no direct association to the subject matter of Fairmath, and I believe this is especially true for the naming of the Snowman function and the SugarCube widget.

Also would it not be a good idea to introduce the concept of Namespace (or an equivalent) in the Snowman example, as there have be a number of end-users using it that have no knowledge of either Javascript or DOM programming.

videlais commented 6 years ago

@greyelf: I agree about the name change. I've just updated the Harlowe entry and will work to update the others.

I'm not sure what you mean in the second paragraph. I agree that JavaScript usage should be limited, but I'm also not sure how to implement Fairmath without basically what I have now. It could become global attributes as part of something, say, window.twine, but it'd still be the same general code.

greyelf commented 6 years ago

I'm not sure what you mean in the second paragraph.

Two common issues end-users seem to have are:

  1. Understanding Javascript Scope and how it effect the accessibility of variables and functions.
  2. [Semi related] Understanding that you can inadvertently overwrite existing DOM functionality if you use the window object to overcome point 1.

As the functions currently stand they assume you understand what Scope they are available in (only the passage they were define in), and that might surprise someone that tries to use them in another passage or from the Console.

I was just suggesting using best practices for these types of issues (like a Namespace or equivalent) to containerise the Javascript functions, which would increase their Scope to something similar to that of the SugarCube widget equivalents.

videlais commented 6 years ago

That's what I thought you meant, but I'm glad you were able to clarify it for me. I agree that having the function be of a higher scope (and able to be used in any passage) is the best way to meet the two concerns you noted. I've now updated the code and description to note that. Good call.

greyelf commented 6 years ago

Could using twine as the namespace cause any potential confusion or namespace collision between the end-user's custom environment and the Twine 2 application's environment in Test / Play modes?

videlais commented 6 years ago

It shouldn't. Snowman doesn't use that namespace. But, just to be safe, I'll re-name it to "fairmath" in the next update.