(First: I apologize if there is an obvious answer, I'm new to hacking Twine)
Hi. As background, I'm planning on using Twine for a two-week high-school class I'm helping teach and my kids school. I'm still a bit of a twine novice, so I'm attempting to learn twine, learn the style (I'm planning on SugarCube 2.6), collect resources for the kids to learn this, and create some samples. (I have lots of technical experience, just not with these tools)
What I want to do is do some outdoor, location-based stories by leveraging the location api's in mobile Safari on an iPad. My thought about the right way to do this is to create a new SugarCube macro (like some of the examples such as the Shake ones) that accesses the location, and create a few variants (e.g., tell me if the location is within X meters of this long, lat). These are things I know how to do (dealing with location in javascript, etc).
BUT, given this, I was wondering what the best way might be to deal with updating the page when the player moves around. I was thinking of polling the location in Javascript, using a timer or requestAnimationFrame, etc. If the result of a location macro changes, it would seem the best thing to do would be to "re-evaluate" the whole page so that if an author creates a passage with a lot of dependencies on the location, things will work as expected. If I was just changing CSS or the DOM, I realize I can just make the change. I don't understand enough of the internals of twinejs to know if I need to do something else to cause twine to re-evaluate everything or if there's an obvious macro or function to call.
Thanks!
Hi. As background, I'm planning on using Twine for a two-week high-school class I'm helping teach and my kids school. I'm still a bit of a twine novice, so I'm attempting to learn twine, learn the style (I'm planning on SugarCube 2.6), collect resources for the kids to learn this, and create some samples. (I have lots of technical experience, just not with these tools)
What I want to do is do some outdoor, location-based stories by leveraging the location api's in mobile Safari on an iPad. My thought about the right way to do this is to create a new SugarCube macro (like some of the examples such as the Shake ones) that accesses the location, and create a few variants (e.g., tell me if the location is within X meters of this long, lat). These are things I know how to do (dealing with location in javascript, etc).
BUT, given this, I was wondering what the best way might be to deal with updating the page when the player moves around. I was thinking of polling the location in Javascript, using a timer or requestAnimationFrame, etc. If the result of a location macro changes, it would seem the best thing to do would be to "re-evaluate" the whole page so that if an author creates a passage with a lot of dependencies on the location, things will work as expected. If I was just changing CSS or the DOM, I realize I can just make the change. I don't understand enough of the internals of twinejs to know if I need to do something else to cause twine to re-evaluate everything or if there's an obvious macro or function to call.
Thanks!